]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-118846: Fix PGO tests in free-threaded build (GH-118862) (#118867)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 9 May 2024 20:34:22 +0000 (22:34 +0200)
committerGitHub <noreply@github.com>
Thu, 9 May 2024 20:34:22 +0000 (20:34 +0000)
Avoid immortalizing objects in tests that verify garbage collection of
classes or modules.

This fixes test_ordered_dict and test_struct.
(cherry picked from commit 1b1db2fd9a531e26b79b34667bccfb938c4d184d)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Lib/test/test_ordered_dict.py
Lib/test/test_struct.py

index 4571b23dfe7c1ac74e0d09c3c04e51654578b848..06a0e81227188c81360080261eee35611146f871 100644 (file)
@@ -10,7 +10,7 @@ import unittest
 import weakref
 from collections.abc import MutableMapping
 from test import mapping_tests, support
-from test.support import import_helper
+from test.support import import_helper, suppress_immortalization
 
 
 py_coll = import_helper.import_fresh_module('collections',
@@ -667,6 +667,7 @@ class OrderedDictTests:
         dict.update(od, [('spam', 1)])
         self.assertNotIn('NULL', repr(od))
 
+    @suppress_immortalization()
     def test_reference_loop(self):
         # Issue 25935
         OrderedDict = self.OrderedDict
index 15f6ee06ffe19b603ef122f8200cced905f4aad5..5508cc3eec85c8327714e5257415e2264a1961d6 100644 (file)
@@ -9,7 +9,7 @@ import sys
 import weakref
 
 from test import support
-from test.support import import_helper
+from test.support import import_helper, suppress_immortalization
 from test.support.script_helper import assert_python_ok
 
 ISBIGENDIAN = sys.byteorder == "big"
@@ -674,6 +674,7 @@ class StructTest(unittest.TestCase):
         self.assertIn(b"Exception ignored in:", stderr)
         self.assertIn(b"C.__del__", stderr)
 
+    @suppress_immortalization()
     def test__struct_reference_cycle_cleaned_up(self):
         # Regression test for python/cpython#94207.