gh-134557: Revert "gh-132775: Use _PyCode GetScriptXIData()" (gh-134599)

This reverts commit 09e72cf091, AKA gh-134511.

We are reverting due to refleaks on free-threaded builds.
This commit is contained in:
Eric Snow 2025-05-23 14:04:20 -06:00 committed by GitHub
parent 9a2346df86
commit 8a793c4a36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 240 additions and 104 deletions

View file

@ -474,15 +474,13 @@ class CommonTests(TestBase):
def test_signatures(self):
# See https://github.com/python/cpython/issues/126654
msg = r'_interpreters.exec\(\) argument 3 must be dict, not int'
msg = "expected 'shared' to be a dict"
with self.assertRaisesRegex(TypeError, msg):
_interpreters.exec(self.id, 'a', 1)
with self.assertRaisesRegex(TypeError, msg):
_interpreters.exec(self.id, 'a', shared=1)
msg = r'_interpreters.run_string\(\) argument 3 must be dict, not int'
with self.assertRaisesRegex(TypeError, msg):
_interpreters.run_string(self.id, 'a', shared=1)
msg = r'_interpreters.run_func\(\) argument 3 must be dict, not int'
with self.assertRaisesRegex(TypeError, msg):
_interpreters.run_func(self.id, lambda: None, shared=1)
@ -954,8 +952,7 @@ class RunFailedTests(TestBase):
""")
with self.subTest('script'):
with self.assertRaises(SyntaxError):
_interpreters.run_string(self.id, script)
self.assert_run_failed(SyntaxError, script)
with self.subTest('module'):
modname = 'spam_spam_spam'
@ -1022,19 +1019,12 @@ class RunFuncTests(TestBase):
with open(w, 'w', encoding="utf-8") as spipe:
with contextlib.redirect_stdout(spipe):
print('it worked!', end='')
failed = None
def f():
nonlocal failed
try:
_interpreters.set___main___attrs(self.id, dict(w=w))
_interpreters.run_func(self.id, script)
except Exception as exc:
failed = exc
_interpreters.set___main___attrs(self.id, dict(w=w))
_interpreters.run_func(self.id, script)
t = threading.Thread(target=f)
t.start()
t.join()
if failed:
raise Exception from failed
with open(r, encoding="utf-8") as outfile:
out = outfile.read()
@ -1063,16 +1053,19 @@ class RunFuncTests(TestBase):
spam = True
def script():
assert spam
with self.assertRaises(ValueError):
with self.assertRaises(TypeError):
_interpreters.run_func(self.id, script)
# XXX This hasn't been fixed yet.
@unittest.expectedFailure
def test_return_value(self):
def script():
return 'spam'
with self.assertRaises(ValueError):
_interpreters.run_func(self.id, script)
# @unittest.skip("we're not quite there yet")
@unittest.skip("we're not quite there yet")
def test_args(self):
with self.subTest('args'):
def script(a, b=0):