]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
subtype_resurrection(): The test suite with -l properly reported the
authorTim Peters <tim.peters@gmail.com>
Thu, 11 Jul 2002 18:30:02 +0000 (18:30 +0000)
committerTim Peters <tim.peters@gmail.com>
Thu, 11 Jul 2002 18:30:02 +0000 (18:30 +0000)
immortal object here as a leak.  Made the object mortal again at the end.

Lib/test/test_descr.py

index bbdcc0935efce37e25aab0434cf38de7e3709a21..903907723cfcbeb1a62fc59a4b3e0f1f38597e9e 100644 (file)
@@ -2982,6 +2982,7 @@ def copy_setstate():
     vereq(b.getfoo(), 24)
 
 def subtype_resurrection():
+    import gc
     if verbose:
         print "Testing resurrection of new-style instance..."
 
@@ -2994,12 +2995,22 @@ def subtype_resurrection():
 
     c = C()
     c.attr = 42
-    # The only interesting thing here is whether this blows up, due to flawed
+    # The most interesting thing here is whether this blows up, due to flawed
     #  GC tracking logic in typeobject.c's call_finalizer() (a 2.2.1 bug).
     del c
-    del C.container[-1]  # resurrect it again for the heck of it
+
+    # If that didn't blow up, it's also interesting to see whether clearing
+    # the last container slot works:  that will attempt to delete c again,
+    # which will cause c to get appended back to the container again "during"
+    # the del.
+    del C.container[-1]
+    vereq(len(C.container), 1)
     vereq(C.container[-1].attr, 42)
 
+    # Make c mortal again, so that the test framework with -l doesn't report
+    # it as a leak.
+    del C.__del__
+
 def test_main():
     class_docstrings()
     lists()