From: Guido van Rossum Date: Wed, 12 Jun 2002 14:41:50 +0000 (+0000) Subject: Backport 1.15: X-Git-Tag: v2.2.2b1~331 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=76c63a4980c7c08052b2284300af6a31fd8c650a;p=thirdparty%2FPython%2Fcpython.git Backport 1.15: Add a testcase to ensure that cycles going through the __class__ link of a new-style instance are detected by the garbage collector. --- diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py index 22f7e74114be..23bb7c5cc9eb 100644 --- a/Lib/test/test_gc.py +++ b/Lib/test/test_gc.py @@ -83,6 +83,12 @@ def test_newinstance(): gc.collect() del a expect_nonzero(gc.collect(), "newinstance(2)") + del B, C + expect_nonzero(gc.collect(), "newinstance(3)") + A.a = A() + del A + expect_nonzero(gc.collect(), "newinstance(4)") + expect(gc.collect(), 0, "newinstance(5)") def test_method(): # Tricky: self.__init__ is a bound method, it references the instance.