summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorsobolevn <mail@sobolevn.me>2025-01-09 19:45:35 (GMT)
committerGitHub <noreply@github.com>2025-01-09 19:45:35 (GMT)
commit087bb48acac997c06e69dae25bae2dd75194b980 (patch)
treea93efb8d96f4835130f3ae5be0538575afe6e8d2 /Lib/test
parent8af57810946c216b3e18c94c8f0ee3c0c96566a9 (diff)
downloadcpython-087bb48acac997c06e69dae25bae2dd75194b980.zip
cpython-087bb48acac997c06e69dae25bae2dd75194b980.tar.gz
cpython-087bb48acac997c06e69dae25bae2dd75194b980.tar.bz2
gh-127196: Fix crash in `_interpreters`, when `shared` had invalid encodings (#127220)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test__interpreters.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test__interpreters.py b/Lib/test/test__interpreters.py
index bf3165e..fd444f1 100644
--- a/Lib/test/test__interpreters.py
+++ b/Lib/test/test__interpreters.py
@@ -557,7 +557,7 @@ class CommonTests(TestBase):
self.id = _interpreters.create()
def test_signatures(self):
- # for method in ['exec', 'run_string', 'run_func']:
+ # See https://github.com/python/cpython/issues/126654
msg = "expected 'shared' to be a dict"
with self.assertRaisesRegex(TypeError, msg):
_interpreters.exec(self.id, 'a', 1)
@@ -568,6 +568,17 @@ class CommonTests(TestBase):
with self.assertRaisesRegex(TypeError, msg):
_interpreters.run_func(self.id, lambda: None, shared=1)
+ def test_invalid_shared_encoding(self):
+ # See https://github.com/python/cpython/issues/127196
+ bad_shared = {"\uD82A": 0}
+ msg = 'surrogates not allowed'
+ with self.assertRaisesRegex(UnicodeEncodeError, msg):
+ _interpreters.exec(self.id, 'a', shared=bad_shared)
+ with self.assertRaisesRegex(UnicodeEncodeError, msg):
+ _interpreters.run_string(self.id, 'a', shared=bad_shared)
+ with self.assertRaisesRegex(UnicodeEncodeError, msg):
+ _interpreters.run_func(self.id, lambda: None, shared=bad_shared)
+
class RunStringTests(TestBase):