mirror of
https://github.com/python/cpython.git
synced 2025-08-26 11:45:20 +00:00
gh-125900: Clean-up logic around immortalization in free-threading (#125901)
* Remove `@suppress_immortalization` decorator * Make suppression flag per-thread instead of per-interpreter * Suppress immortalization in `eval()` to avoid refleaks in three tests (test_datetime.test_roundtrip, test_logging.test_config8_ok, and test_random.test_after_fork). * frozenset() is constant, but not a singleton. When run multiple times, the test could fail due to constant interning.
This commit is contained in:
parent
1306f33c84
commit
332356b880
23 changed files with 36 additions and 137 deletions
|
@ -141,9 +141,7 @@ except ImportError:
|
|||
ctypes = None
|
||||
from test.support import (cpython_only,
|
||||
check_impl_detail, requires_debug_ranges,
|
||||
gc_collect, Py_GIL_DISABLED,
|
||||
suppress_immortalization,
|
||||
skip_if_suppress_immortalization)
|
||||
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
|
||||
|
@ -579,7 +577,6 @@ class CodeConstsTest(unittest.TestCase):
|
|||
|
||||
@cpython_only
|
||||
@unittest.skipUnless(Py_GIL_DISABLED, "does not intern all constants")
|
||||
@skip_if_suppress_immortalization()
|
||||
def test_interned_constants(self):
|
||||
# compile separately to avoid compile time de-duping
|
||||
|
||||
|
@ -599,7 +596,6 @@ class CodeConstsTest(unittest.TestCase):
|
|||
|
||||
class CodeWeakRefTest(unittest.TestCase):
|
||||
|
||||
@suppress_immortalization()
|
||||
def test_basic(self):
|
||||
# Create a code object in a clean environment so that we know we have
|
||||
# the only reference to it left.
|
||||
|
@ -850,7 +846,6 @@ if check_impl_detail(cpython=True) and ctypes is not None:
|
|||
self.assertEqual(GetExtra(f.__code__, FREE_INDEX+100,
|
||||
ctypes.c_voidp(100)), 0)
|
||||
|
||||
@suppress_immortalization()
|
||||
def test_free_called(self):
|
||||
# Verify that the provided free function gets invoked
|
||||
# when the code object is cleaned up.
|
||||
|
@ -878,7 +873,6 @@ if check_impl_detail(cpython=True) and ctypes is not None:
|
|||
del f
|
||||
|
||||
@threading_helper.requires_working_threading()
|
||||
@suppress_immortalization()
|
||||
def test_free_different_thread(self):
|
||||
# Freeing a code object on a different thread then
|
||||
# where the co_extra was set should be safe.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue