mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-127196: Fix crash in _interpreters
, when shared
had invalid encodings (#127220)
This commit is contained in:
parent
8af5781094
commit
087bb48aca
3 changed files with 20 additions and 2 deletions
|
@ -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):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue