Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55cf434

Browse files
committed
further testing indicates that the simplified version of the test
(re-using an existing test object class) no longer triggered the original segfault when the fix was backed out; restoring the local test object class to make the test effective the assignment of the ref created at the end does not affect the test, since the segfault happended before weakref.ref() returned; removing the assignment
1 parent 7a6d297 commit 55cf434

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Lib/test/test_weakref.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,21 +602,23 @@ def check_gc_during_creation(self, makeref):
602602
thresholds = gc.get_threshold()
603603
gc.set_threshold(1, 1, 1)
604604
gc.collect()
605+
class A:
606+
pass
605607

606608
def callback(*args):
607609
pass
608610

609-
referenced = C()
611+
referenced = A()
610612

611-
a = C()
613+
a = A()
612614
a.a = a
613615
a.wr = makeref(referenced)
614616

615617
try:
616618
# now make sure the object and the ref get labeled as
617619
# cyclic trash:
618-
a = C()
619-
a.wrc = weakref.ref(referenced, callback)
620+
a = A()
621+
weakref.ref(referenced, callback)
620622

621623
finally:
622624
gc.set_threshold(*thresholds)

0 commit comments

Comments
 (0)