Mailing List Archive

gh-117683: Fix test_free_different_thread failures with GIL disabled (#117685)
https://github.com/python/cpython/commit/df0f3a738f8bd414e0a3164ad65f71acfa83c085
commit: df0f3a738f8bd414e0a3164ad65f71acfa83c085
branch: main
author: Sam Gross <colesbury@gmail.com>
committer: colesbury <colesbury@gmail.com>
date: 2024-04-16T11:55:56-04:00
summary:

gh-117683: Fix test_free_different_thread failures with GIL disabled (#117685)

files:
M Lib/test/test_code.py

diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py
index 5c0fdc8edc31b6..fe8c672e71a7b5 100644
--- a/Lib/test/test_code.py
+++ b/Lib/test/test_code.py
@@ -141,7 +141,7 @@
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 @@ def __init__(self, f, test):
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)

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-leave@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: list-python-checkins@lists.gossamer-threads.com