Skip to content

Commit 1b1db2f

Browse files
authored
gh-118846: Fix PGO tests in free-threaded build (#118862)
Avoid immortalizing objects in tests that verify garbage collection of classes or modules. This fixes test_ordered_dict and test_struct.
1 parent 71cc065 commit 1b1db2f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Lib/test/test_ordered_dict.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import weakref
1111
from collections.abc import MutableMapping
1212
from test import mapping_tests, support
13-
from test.support import import_helper
13+
from test.support import import_helper, suppress_immortalization
1414

1515

1616
py_coll = import_helper.import_fresh_module('collections',
@@ -667,6 +667,7 @@ def test_dict_update(self):
667667
dict.update(od, [('spam', 1)])
668668
self.assertNotIn('NULL', repr(od))
669669

670+
@suppress_immortalization()
670671
def test_reference_loop(self):
671672
# Issue 25935
672673
OrderedDict = self.OrderedDict

Lib/test/test_struct.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import weakref
1010

1111
from test import support
12-
from test.support import import_helper
12+
from test.support import import_helper, suppress_immortalization
1313
from test.support.script_helper import assert_python_ok
1414

1515
ISBIGENDIAN = sys.byteorder == "big"
@@ -674,6 +674,7 @@ def __del__(self):
674674
self.assertIn(b"Exception ignored in:", stderr)
675675
self.assertIn(b"C.__del__", stderr)
676676

677+
@suppress_immortalization()
677678
def test__struct_reference_cycle_cleaned_up(self):
678679
# Regression test for python/cpython#94207.
679680

0 commit comments

Comments
 (0)