Skip to content

Commit a1caec9

Browse files
committed
Skip subinterpreter init test unless GIL disabled
Use an exec wrapper for subinterpreter execution and assert None results instead of calling support.run_in_subinterp
1 parent 4492520 commit a1caec9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Lib/test/test_struct.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,16 +800,19 @@ def test_c_complex_round_trip(self):
800800
round_trip = struct.unpack(f, struct.pack(f, z))[0]
801801
self.assertComplexesAreIdentical(z, round_trip)
802802

803+
@unittest.skipUnless(support.Py_GIL_DISABLED, 'this test can only possibly fail with GIL disabled')
803804
def test_endian_table_init_subinterpreters(self):
804805
# Verify that the _struct extension module can be initialized
805806
# concurrently in subinterpreters (gh-140260).
806807
from concurrent.futures import InterpreterPoolExecutor
807808

809+
def _exec_code(code_str):
810+
exec(code_str)
811+
808812
code = "import struct"
809813
with InterpreterPoolExecutor(max_workers=5) as executor:
810-
results = executor.map(support.run_in_subinterp, [code] * 5)
811-
for ret in results:
812-
self.assertEqual(ret, 0)
814+
results = executor.map(_exec_code, [code] * 5)
815+
self.assertListEqual(list(results), [None] * 5)
813816

814817

815818
class UnpackIteratorTest(unittest.TestCase):

0 commit comments

Comments
 (0)