summaryrefslogtreecommitdiffstats
path: root/Lib/test/_test_multiprocessing.py
diff options
context:
space:
mode:
authorAntoine Pitrou <antoine@python.org>2020-04-20 18:54:55 (GMT)
committerGitHub <noreply@github.com>2020-04-20 18:54:55 (GMT)
commiteba9f6155df59c9beed97fb5764c9f01dd941af0 (patch)
treef07cef322962795cd4ed0d71f74f9069580b16a5 /Lib/test/_test_multiprocessing.py
parent5dd21f5d1c9b5a9316deca4535932675f04efeee (diff)
downloadcpython-eba9f6155df59c9beed97fb5764c9f01dd941af0.zip
cpython-eba9f6155df59c9beed97fb5764c9f01dd941af0.tar.gz
cpython-eba9f6155df59c9beed97fb5764c9f01dd941af0.tar.bz2
bpo-40330: Fix utf-8 size check in ShareableList (GH-19606)
The item size must be checked after encoding to bytes, not before. Automerge-Triggered-By: @pitrou
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r--Lib/test/_test_multiprocessing.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index d00e928..d633e02 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -3995,9 +3995,21 @@ class _TestSharedMemory(BaseTestCase):
sl[4] = 'some' # Change type at a given position.
self.assertEqual(sl[4], 'some')
self.assertEqual(sl.format, '8s8sdq8sxxxxxxx?q')
- with self.assertRaises(ValueError):
- sl[4] = 'far too many' # Exceeds available storage.
+ with self.assertRaisesRegex(ValueError,
+ "exceeds available storage"):
+ sl[4] = 'far too many'
self.assertEqual(sl[4], 'some')
+ sl[0] = 'encodés' # Exactly 8 bytes of UTF-8 data
+ self.assertEqual(sl[0], 'encodés')
+ self.assertEqual(sl[1], b'HoWdY') # no spillage
+ with self.assertRaisesRegex(ValueError,
+ "exceeds available storage"):
+ sl[0] = 'encodées' # Exactly 9 bytes of UTF-8 data
+ self.assertEqual(sl[1], b'HoWdY')
+ with self.assertRaisesRegex(ValueError,
+ "exceeds available storage"):
+ sl[1] = b'123456789'
+ self.assertEqual(sl[1], b'HoWdY')
# Exercise count().
with warnings.catch_warnings():