Skip to content

Commit

Permalink
Put a bandaid on the test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroIntensity committed Nov 2, 2024
1 parent 5a58035 commit 754f44a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Lib/test/test_gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,17 +1082,31 @@ def __del__(self):
gc.collect()
self.assertTrue(collected)

@support.requires_subprocess()
def test_traverse_frozen_objects(self):
# See GH-126312: Objects that were not frozen could traverse over
# a frozen object on the free-threaded build, which would cause
# a negative reference count.
import subprocess
import textwrap

# We have to run this in subprocess because
# freezing the GC alongside deferred reference counting
# causes a seperate bug, that needs to get addressed in another PR.
source = textwrap.dedent("""
import gc
x = [1, 2, 3]
gc.freeze()
y = [x]
y.append(y)
del y
gc.collect()
gc.unfreeze()
""")
proc = subprocess.Popen([sys.executable, "-c", source])
proc.wait()
self.assertEqual(proc.returncode, 0)


class IncrementalGCTests(unittest.TestCase):
Expand Down

0 comments on commit 754f44a

Please sign in to comment.