Use _PyCode_GetScriptXIData(). · python/cpython@4c04200 · GitHub
Skip to content

Commit 4c04200

Browse files
Use _PyCode_GetScriptXIData().
1 parent c1a9c8f commit 4c04200

4 files changed

Lines changed: 108 additions & 235 deletions

File tree

Lib/test/support/interpreters/channels.py

Lines changed: 1 addition & 1 deletion

Lib/test/test__interpreters.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,15 @@ def setUp(self):
474474

475475
def test_signatures(self):
476476
# See https://github.com/python/cpython/issues/126654
477-
msg = "expected 'shared' to be a dict"
477+
msg = r'_interpreters.exec\(\) argument 3 must be dict, not int'
478478
with self.assertRaisesRegex(TypeError, msg):
479479
_interpreters.exec(self.id, 'a', 1)
480480
with self.assertRaisesRegex(TypeError, msg):
481481
_interpreters.exec(self.id, 'a', shared=1)
482+
msg = r'_interpreters.run_string\(\) argument 3 must be dict, not int'
482483
with self.assertRaisesRegex(TypeError, msg):
483484
_interpreters.run_string(self.id, 'a', shared=1)
485+
msg = r'_interpreters.run_func\(\) argument 3 must be dict, not int'
484486
with self.assertRaisesRegex(TypeError, msg):
485487
_interpreters.run_func(self.id, lambda: None, shared=1)
486488

@@ -952,7 +954,8 @@ def test_invalid_syntax(self):
952954
""")
953955

954956
with self.subTest('script'):
955-
self.assert_run_failed(SyntaxError, script)
957+
with self.assertRaises(SyntaxError):
958+
_interpreters.run_string(self.id, script)
956959

957960
with self.subTest('module'):
958961
modname = 'spam_spam_spam'
@@ -1019,12 +1022,19 @@ def script():
10191022
with open(w, 'w', encoding="utf-8") as spipe:
10201023
with contextlib.redirect_stdout(spipe):
10211024
print('it worked!', end='')
1025+
failed = None
10221026
def f():
1023-
_interpreters.set___main___attrs(self.id, dict(w=w))
1024-
_interpreters.run_func(self.id, script)
1027+
nonlocal failed
1028+
try:
1029+
_interpreters.set___main___attrs(self.id, dict(w=w))
1030+
_interpreters.run_func(self.id, script)
1031+
except Exception as exc:
1032+
failed = exc
10251033
t = threading.Thread(target=f)
10261034
t.start()
10271035
t.join()
1036+
if failed:
1037+
raise Exception from failed
10281038

10291039
with open(r, encoding="utf-8") as outfile:
10301040
out = outfile.read()
@@ -1053,12 +1063,9 @@ def test_closure(self):
10531063
spam = True
10541064
def script():
10551065
assert spam
1056-
10571066
with self.assertRaises(ValueError):
10581067
_interpreters.run_func(self.id, script)
10591068

1060-
# XXX This hasn't been fixed yet.
1061-
@unittest.expectedFailure
10621069
def test_return_value(self):
10631070
def script():
10641071
return 'spam'

Lib/test/test_interpreters/test_api.py

Lines changed: 21 additions & 8 deletions

0 commit comments

Comments
 (0)