From cd6034db942621a1c7e0d7a030b4aee91a11621d Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Wed, 5 Mar 2025 22:03:40 +0000 Subject: [PATCH] gh-130851: Skip test_unusual_constants under refleak checker The test immortalizes some regular object instances, which causes the refleak checks to fail. --- Lib/test/test_code.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py index 34110dbcace7e1..51dc998475c14f 100644 --- a/Lib/test/test_code.py +++ b/Lib/test/test_code.py @@ -212,7 +212,7 @@ check_impl_detail, requires_debug_ranges, 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 import threading_helper, import_helper, refleak_helper from test.support.bytecode_helper import instructions_with_positions from opcode import opmap, opname from _testcapi import code_offset_to_line @@ -667,6 +667,11 @@ def func2(): @cpython_only def test_unusual_constants(self): + # We cannot use the @skipIf here because hunting_for_refleaks() + # is only true once we start executing the test. + if Py_GIL_DISABLED and refleak_helper.hunting_for_refleaks(): + raise unittest.SkipTest("Immortalized objects trigger refleak detection") + # gh-130851: Code objects constructed with constants that are not # types generated by the bytecode compiler should not crash the # interpreter.