]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-117683: Fix test_free_different_thread failures with GIL disabled (#117685)
authorSam Gross <colesbury@gmail.com>
Tue, 16 Apr 2024 15:55:56 +0000 (11:55 -0400)
committerGitHub <noreply@github.com>
Tue, 16 Apr 2024 15:55:56 +0000 (11:55 -0400)
Lib/test/test_code.py

index 5c0fdc8edc31b66944424bfcec96bde583d86217..fe8c672e71a7b556f75163bfbd6020eace1fb48a 100644 (file)
@@ -141,7 +141,7 @@ except ImportError:
     ctypes = None
 from test.support import (cpython_only,
                           check_impl_detail, requires_debug_ranges,
-                          gc_collect)
+                          gc_collect, Py_GIL_DISABLED)
 from test.support.script_helper import assert_python_ok
 from test.support import threading_helper, import_helper
 from test.support.bytecode_helper import instructions_with_positions
@@ -866,7 +866,11 @@ if check_impl_detail(cpython=True) and ctypes is not None:
                 def run(self):
                     del self.f
                     gc_collect()
-                    self.test.assertEqual(LAST_FREED, 500)
+                    # gh-117683: In the free-threaded build, the code object's
+                    # destructor may still be running concurrently in the main
+                    # thread.
+                    if not Py_GIL_DISABLED:
+                        self.test.assertEqual(LAST_FREED, 500)
 
             SetExtra(f.__code__, FREE_INDEX, ctypes.c_voidp(500))
             tt = ThreadTest(f, self)