8000 [3.14] gh-134557: Revert "[3.14] gh-132775: Use _PyCode GetScriptXID… · python/cpython@7476f90 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7476f90

Browse files
[3.14] gh-134557: Revert "[3.14] gh-132775: Use _PyCode GetScriptXIData()" (gh-134600)
This reverts commit bbf8048, AKA gh-134515. We are reverting due to refleaks on free-threaded builds.
1 parent 09a34f1 commit 7476f90

File tree

4 files changed

+240
-104
lines changed

4 files changed

+240
-104
lines changed

Lib/test/support/interpreters/channels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def list_all():
6969
if not hasattr(send, '_unboundop'):
7070
send._set_unbound(unboundop)
7171
else:
72-
assert send._unbound[0] == unboundop
72+
assert send._unbound[0] == op
7373
channels.append(chan)
7474
return channels
7575

Lib/test/test__interpreters.py

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

475475
def test_signatures(self):
476476
# See https://github.com/python/cpython/issues/126654
477-
msg = r'_interpreters.exec\(\) argument 3 must be dict, not int'
477+
msg = "expected 'shared' to be a dict"
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'
483482
with self.assertRaisesRegex(TypeError, msg):
484483
_interpreters.run_string(self.id, 'a', shared=1)
485-
msg = r'_interpreters.run_func\(\) argument 3 must be dict, not int'
486484
with self.assertRaisesRegex(TypeError, msg):
487485
_interpreters.run_func(self.id, lambda: None, shared=1)
488486

@@ -954,8 +952,7 @@ def test_invalid_syntax(self):
954952
""")
955953

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

960957
with self.subTest('module'):
961958
modname = 'spam_spam_spam'
@@ -1022,19 +1019,12 @@ def script():
10221019
with open(w, 'w', encoding="utf-8") as spipe:
10231020
with contextlib.redirect_stdout(spipe):
10241021
print('it worked!', end='')
1025-
failed = None
10261022
def f():
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
1023+
_interpreters.set___main___attrs(self.id, dict(w=w))
1024+
_interpreters.run_func(self.id, script)
10331025
t = threading.Thread(target=f)
10341026
t.start()
10351027
t.join()
1036-
if failed:
1037-
raise Exception from failed
10381028

10391029
with open(r, encoding="utf-8") as outfile:
10401030
out = outfile.read()
@@ -1063,16 +1053,19 @@ def test_closure(self):
10631053
spam = True
10641054
def script():
10651055
assert spam
1066-
with self.assertRaises(ValueError):
1056+
1057+
with self.assertRaises(TypeError):
10671058
_interpreters.run_func(self.id, script)
10681059

1060+
# XXX This hasn't been fixed yet.
1061+
@unittest.expectedFailure
10691062
def test_return_value(self):
10701063
def script():
10711064
return 'spam'
10721065
with self.assertRaises(ValueError):
10731066
_interpreters.run_func(self.id, script)
10741067

1075-
# @unittest.skip("we're not quite there yet")
1068+
@unittest.skip("we're not quite there yet")
10761069
def test_args(self):
10771070
with self.subTest('args'):
10781071
def script(a, b=0):

Lib/test/test_interpreters/test_api.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -839,16 +839,9 @@ def test_bad_script(self):
839839
interp.exec(10)
840840

841841
def test_bytes_for_script(self):
842-
r, w = self.pipe()
843-
RAN = b'R'
844-
DONE = b'D'
845842
interp = interpreters.create()
846-
interp.exec(f"""if True:
847-
import os
848-
os.write({w}, {RAN!r})
849-
""")
850-
os.write(w, DONE)
851-
self.assertEqual(os.read(r, 1), RAN)
843+
with self.assertRaises(TypeError):
844+
interp.exec(b'print("spam")')
852845

853846
def test_with_background_threads_still_running(self):
854847
r_interp, w_interp = self.pipe()
@@ -1017,6 +1010,8 @@ def test_call(self):
10171010

10181011
for i, (callable, args, kwargs) in enumerate([
10191012
(call_func_noop, (), {}),
1013+
(call_func_return_shareable, (), {}),
1014+
(call_func_return_not_shareable, (), {}),
10201015
(Spam.noop, (), {}),
10211016
]):
10221017
with self.subTest(f'success case #{i+1}'):
@@ -1041,8 +1036,6 @@ def test_call(self):
10411036
(call_func_complex, ('custom', 'spam!'), {}),
10421037
(call_func_complex, ('custom-inner', 'eggs!'), {}),
10431038
(call_func_complex, ('???',), {'exc': ValueError('spam')}),
1044-
(call_func_return_shareable, (), {}),
1045-
(call_func_return_not_shareable, (), {}),
10461039
]):
10471040
with self.subTest(f'invalid case #{i+1}'):
10481041
with self.assertRaises(Exception):
@@ -1058,6 +1051,8 @@ def test_call_in_thread(self):
10581051

10591052
for i, (callable, args, kwargs) in enumerate([
10601053
(call_func_noop, (), {}),
1054+
(call_func_return_shareable, (), {}),
1055+
(call_func_return_not_shareable, (), {}),
10611056
(Spam.noop, (), {}),
10621057
]):
10631058
with self.subTest(f'success case #{i+1}'):
@@ -1084,8 +1079,6 @@ def test_call_in_thread(self):
10841079
(call_func_complex, ('custom', 'spam!'), {}),
10851080
(call_func_complex, ('custom-inner', 'eggs!'), {}),
10861081
(call_func_complex, ('???',), {'exc': ValueError('spam')}),
1087-
(call_func_return_shareable, (), {}),
1088-
(call_func_return_not_shareable, (), {}),
10891082
]):
10901083
with self.subTest(f'invalid case #{i+1}'):
10911084
if args or kwargs:
@@ -1625,8 +1618,8 @@ def test_exec(self):
16251618
def test_call(self):
16261619
with self.subTest('no args'):
16271620
interpid = _interpreters.create()
1628-
with self.assertRaises(ValueError):
1629-
_interpreters.call(interpid, call_func_return_shareable)
1621+
exc = _interpreters.call(interpid, call_func_return_shareable)
1622+
self.assertIs(exc, None)
16301623

16311624
with self.subTest('uncaught exception'):
16321625
interpid = _interpreters.create()

0 commit comments

Comments
 (0)
0