Skip to content

Commit df45b98

Browse files
committed
Merge branch 'gh-117683-test_free_different_thread' into nogil-integration
2 parents 7bc49a7 + b775561 commit df45b98

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Lib/test/test_code.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
ctypes = None
142142
from test.support import (cpython_only,
143143
check_impl_detail, requires_debug_ranges,
144-
gc_collect)
144+
gc_collect, Py_GIL_DISABLED)
145145
from test.support.script_helper import assert_python_ok
146146
from test.support import threading_helper, import_helper
147147
from test.support.bytecode_helper import instructions_with_positions
@@ -866,7 +866,11 @@ def __init__(self, f, test):
866866
def run(self):
867867
del self.f
868868
gc_collect()
869-
self.test.assertEqual(LAST_FREED, 500)
869+
# gh-117683: In the free-threaded build, the code object's
870+
# destructor may still be running concurrently in the main
871+
# thread.
872+
if not Py_GIL_DISABLED:
873+
self.test.assertEqual(LAST_FREED, 500)
870874

871875
SetExtra(f.__code__, FREE_INDEX, ctypes.c_voidp(500))
872876
tt = ThreadTest(f, self)

0 commit comments

Comments
 (0)