mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
[3.13] gh-127196: Fix crash in _interpreters
, when shared
had invalid encodings (GH-127220) (#128689)
gh-127196: Fix crash in `_interpreters`, when `shared` had invalid encodings (GH-127220)
(cherry picked from commit 087bb48aca
)
Co-authored-by: sobolevn <mail@sobolevn.me>
This commit is contained in:
parent
c57ef49337
commit
0d2b9abd18
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