mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
[3.14] gh-132775: Unrevert "Use _PyCode GetScriptXIData()" (gh-134736)
This reverts commit7476f90af2, AKA gh-134600. This effectively unreverts commitbbf8048c0f(gh-134515).
This commit is contained in:
parent
74f5667bd9
commit
e86efabaee
4 changed files with 106 additions and 242 deletions
|
|
@ -69,7 +69,7 @@ def list_all():
|
|||
if not hasattr(send, '_unboundop'):
|
||||
send._set_unbound(unboundop)
|
||||
else:
|
||||
assert send._unbound[0] == op
|
||||
assert send._unbound[0] == unboundop
|
||||
channels.append(chan)
|
||||
return channels
|
||||
|
||||
|
|
|
|||
|
|
@ -474,13 +474,15 @@ class CommonTests(TestBase):
|
|||
|
||||
def test_signatures(self):
|
||||
# See https://github.com/python/cpython/issues/126654
|
||||
msg = "expected 'shared' to be a dict"
|
||||
msg = r'_interpreters.exec\(\) argument 3 must be dict, not int'
|
||||
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)
|
||||
|
||||
|
|
@ -952,7 +954,8 @@ class RunFailedTests(TestBase):
|
|||
""")
|
||||
|
||||
with self.subTest('script'):
|
||||
self.assert_run_failed(SyntaxError, script)
|
||||
with self.assertRaises(SyntaxError):
|
||||
_interpreters.run_string(self.id, script)
|
||||
|
||||
with self.subTest('module'):
|
||||
modname = 'spam_spam_spam'
|
||||
|
|
@ -1019,12 +1022,19 @@ 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():
|
||||
_interpreters.set___main___attrs(self.id, dict(w=w))
|
||||
_interpreters.run_func(self.id, script)
|
||||
nonlocal failed
|
||||
try:
|
||||
_interpreters.set___main___attrs(self.id, dict(w=w))
|
||||
_interpreters.run_func(self.id, script)
|
||||
except Exception as exc:
|
||||
failed = exc
|
||||
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()
|
||||
|
|
@ -1053,19 +1063,16 @@ class RunFuncTests(TestBase):
|
|||
spam = True
|
||||
def script():
|
||||
assert spam
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
with self.assertRaises(ValueError):
|
||||
_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):
|
||||
|
|
|
|||
|
|
@ -839,9 +839,16 @@ class TestInterpreterExec(TestBase):
|
|||
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 @@ class TestInterpreterCall(TestBase):
|
|||
|
||||
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 @@ class TestInterpreterCall(TestBase):
|
|||
(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 @@ class TestInterpreterCall(TestBase):
|
|||
|
||||
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 @@ class TestInterpreterCall(TestBase):
|
|||
(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 @@ class LowLevelTests(TestBase):
|
|||
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue