ensure gc tracking is off when invoking weakref callbacks (closes #26617)

This commit is contained in:
Benjamin Peterson 2016-10-04 00:00:02 -07:00
parent b47c9d29d7
commit 8f657c35b9
3 changed files with 23 additions and 12 deletions

View file

@ -845,6 +845,14 @@ class ReferencesTestCase(TestBase):
with self.assertRaises(AttributeError):
ref1.__callback__ = lambda ref: None
def test_callback_gcs(self):
class ObjectWithDel(Object):
def __del__(self): pass
x = ObjectWithDel(1)
ref1 = weakref.ref(x, lambda ref: support.gc_collect())
del x
support.gc_collect()
class SubclassableWeakrefTestCase(TestBase):