[3.14] gh-132775: Use _PyCode GetScriptXIData() (gh-134515)

(cherry picked from commit 09e72cf091, AKA gh-134511)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-05-22 17:07:11 +02:00 committed by GitHub
parent c31b25c705
commit bbf8048c0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 106 additions and 242 deletions

View file

@ -839,9 +839,16 @@ def test_bad_script(self):
interp.exec(10)
def test_bytes_for_script(self):
r, w = self.pipe()
RAN = b'R'
DONE = b'D'
interp = interpreters.create()
with self.assertRaises(TypeError):
interp.exec(b'print("spam")')
interp.exec(f"""if True:
import os
os.write({w}, {RAN!r})
""")
os.write(w, DONE)
self.assertEqual(os.read(r, 1), RAN)
def test_with_background_threads_still_running(self):
r_interp, w_interp = self.pipe()
@ -1010,8 +1017,6 @@ def test_call(self):
for i, (callable, args, kwargs) in enumerate([
(call_func_noop, (), {}),
(call_func_return_shareable, (), {}),
(call_func_return_not_shareable, (), {}),
(Spam.noop, (), {}),
]):
with self.subTest(f'success case #{i+1}'):
@ -1036,6 +1041,8 @@ def test_call(self):
(call_func_complex, ('custom', 'spam!'), {}),
(call_func_complex, ('custom-inner', 'eggs!'), {}),
(call_func_complex, ('???',), {'exc': ValueError('spam')}),
(call_func_return_shareable, (), {}),
(call_func_return_not_shareable, (), {}),
]):
with self.subTest(f'invalid case #{i+1}'):
with self.assertRaises(Exception):
@ -1051,8 +1058,6 @@ def test_call_in_thread(self):
for i, (callable, args, kwargs) in enumerate([
(call_func_noop, (), {}),
(call_func_return_shareable, (), {}),
(call_func_return_not_shareable, (), {}),
(Spam.noop, (), {}),
]):
with self.subTest(f'success case #{i+1}'):
@ -1079,6 +1084,8 @@ def test_call_in_thread(self):
(call_func_complex, ('custom', 'spam!'), {}),
(call_func_complex, ('custom-inner', 'eggs!'), {}),
(call_func_complex, ('???',), {'exc': ValueError('spam')}),
(call_func_return_shareable, (), {}),
(call_func_return_not_shareable, (), {}),
]):
with self.subTest(f'invalid case #{i+1}'):
if args or kwargs:
@ -1618,8 +1625,8 @@ def test_exec(self):
def test_call(self):
with self.subTest('no args'):
interpid = _interpreters.create()
exc = _interpreters.call(interpid, call_func_return_shareable)
self.assertIs(exc, None)
with self.assertRaises(ValueError):
_interpreters.call(interpid, call_func_return_shareable)
with self.subTest('uncaught exception'):
interpid = _interpreters.create()