Skip to content

Commit fd5ea22

Browse files
ambvclaude
andcommitted
Mark GC-dependent weakref tests as thread-unsafe
Under --parallel-threads a concurrent collection can turn a test's own gc.collect() into a no-op, leaving its cycles uncollected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 2bf4d51 commit fd5ea22

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Lib/test/test_frame.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ def test_weakref_basic(self):
309309
support.gc_collect()
310310
self.assertIsNone(ref())
311311

312+
@support.thread_unsafe("relies on gc.collect() reclaiming its cycles")
312313
def test_weakref_live_frame(self):
313314
refs = []
314315
def func():
@@ -357,6 +358,7 @@ def test_multiple_weakrefs(self):
357358
self.assertIsNone(ref())
358359
self.assertEqual({id(r) for r in called}, {id(refs[3]), id(refs[4])})
359360

361+
@support.thread_unsafe("relies on gc.collect() reclaiming its cycles")
360362
def test_weak_key_dictionary(self):
361363
wkd = weakref.WeakKeyDictionary()
362364
def _fill():
@@ -367,6 +369,7 @@ def _fill():
367369
support.gc_collect()
368370
self.assertEqual(len(wkd), 0)
369371

372+
@support.thread_unsafe("relies on gc.collect() reclaiming its cycles")
370373
def test_weak_value_dictionary(self):
371374
wvd = weakref.WeakValueDictionary()
372375
def _fill():
@@ -377,6 +380,7 @@ def _fill():
377380
support.gc_collect()
378381
self.assertEqual(len(wvd), 0)
379382

383+
@support.thread_unsafe("relies on gc.collect() reclaiming its cycles")
380384
def test_weakref_traceback_frames(self):
381385
# Frames that participate in reference cycles are cleaned up
382386
# by the cyclic garbage collector.

0 commit comments

Comments
 (0)