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:
Sam Gross 2024-10-24 18:09:59 -04:00 committed by GitHub
parent 1306f33c84
commit 332356b880
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 36 additions and 137 deletions

View file

@ -13,7 +13,7 @@ import random
import textwrap
from test import support
from test.support import script_helper, ALWAYS_EQ, suppress_immortalization
from test.support import script_helper, ALWAYS_EQ
from test.support import gc_collect
from test.support import import_helper
from test.support import threading_helper
@ -659,7 +659,6 @@ class ReferencesTestCase(TestBase):
# deallocation of c2.
del c2
@suppress_immortalization()
def test_callback_in_cycle(self):
import gc
@ -752,7 +751,6 @@ class ReferencesTestCase(TestBase):
del c1, c2, C, D
gc.collect()
@suppress_immortalization()
def test_callback_in_cycle_resurrection(self):
import gc
@ -888,7 +886,6 @@ class ReferencesTestCase(TestBase):
# No exception should be raised here
gc.collect()
@suppress_immortalization()
def test_classes(self):
# Check that classes are weakrefable.
class A(object):