[3.13] gh-118846: Fix free-threading test failures when run sequentially (GH-118864) (#118927)

The free-threaded build currently immortalizes some objects once the
first thread is started. This can lead to test failures depending on the
order in which tests are run. This PR addresses those failures by
suppressing immortalization or skipping the affected tests.
(cherry picked from commit b309c8ebff)

Co-authored-by: Sam Gross <colesbury@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-05-10 22:50:59 +02:00 committed by GitHub
parent b3074f0d5e
commit cceb758c78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 35 additions and 6 deletions

View file

@ -34,7 +34,7 @@ try:
except ImportError:
ThreadPoolExecutor = None
from test.support import cpython_only, import_helper
from test.support import cpython_only, import_helper, suppress_immortalization
from test.support import MISSING_C_DOCSTRINGS, ALWAYS_EQ
from test.support.import_helper import DirsOnSysPath, ready_to_import
from test.support.os_helper import TESTFN, temp_cwd
@ -768,6 +768,7 @@ class TestRetrievingSourceCode(GetSourceBase):
inspect.getfile(list.append)
self.assertIn('expected, got', str(e_append.exception))
@suppress_immortalization()
def test_getfile_class_without_module(self):
class CM(type):
@property
@ -2430,6 +2431,7 @@ class TestGetattrStatic(unittest.TestCase):
self.assertFalse(test.called)
@suppress_immortalization()
def test_cache_does_not_cause_classes_to_persist(self):
# regression test for gh-118013:
# check that the internal _shadowed_dict cache does not cause