summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-11-13 21:59:32 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-11-13 21:59:32 (GMT)
commitf7f9e9966bbb5f8bf393006720d2e87167e81847 (patch)
tree468a42b6c24c2694c7b6f76025c82edb6c642b46 /Lib/test
parent981a91857515d66c4faf60c0f63a9de0d770d217 (diff)
downloadcpython-f7f9e9966bbb5f8bf393006720d2e87167e81847.zip
cpython-f7f9e9966bbb5f8bf393006720d2e87167e81847.tar.gz
cpython-f7f9e9966bbb5f8bf393006720d2e87167e81847.tar.bz2
subtype_dealloc(): A more complete fix for critical bug 840829 +
expanded the test case with a piece that needs the more-complete fix. I'll backport this to 2.3 maint.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_weakref.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 9149318..093133e 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -318,6 +318,25 @@ class ReferencesTestCase(TestBase):
wr = weakref.ref(c, lambda ignore: gc.collect())
del c
+ # There endeth the first part. It gets worse.
+ del wr
+
+ c1 = C()
+ c1.i = C()
+ wr = weakref.ref(c1.i, lambda ignore: gc.collect())
+
+ c2 = C()
+ c2.c1 = c1
+ del c1 # still alive because c2 points to it
+
+ # Now when subtype_dealloc gets called on c2, it's not enough just
+ # that c2 is immune from gc while the weakref callbacks associated
+ # with c2 execute (there are none in this 2nd half of the test, btw).
+ # subtype_dealloc goes on to call the base classes' deallocs too,
+ # so any gc triggered by weakref callbacks associated with anything
+ # torn down by a base class dealloc can also trigger double
+ # deallocation of c2.
+ del c2
class Object:
def __init__(self, arg):