summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-07-11 06:56:07 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-07-11 06:56:07 (GMT)
commit2484aaea15a8fd0bbd5397c58699b2fa773a6aa2 (patch)
treeefc6951b855e9a293612da6697b6883af989dcbc
parent3459251d5a2b9589e03e818effc357e5e60ee4a9 (diff)
downloadcpython-2484aaea15a8fd0bbd5397c58699b2fa773a6aa2.zip
cpython-2484aaea15a8fd0bbd5397c58699b2fa773a6aa2.tar.gz
cpython-2484aaea15a8fd0bbd5397c58699b2fa773a6aa2.tar.bz2
Added a test that provokes the hypothesized (in my last checkin comment)
debug-build failure when an instance of a new-style class is resurrected by a __del__ method -- we simply never had any code that tried this. This is already fixed in 2.3 CVS. In 2.2.1, it blows up via Fatal Python error: GC object already in linked list I'll fix it in 2.2.1 CVS next.
-rw-r--r--Lib/test/test_descr.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index ea67c4e..4069403 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -3183,6 +3183,25 @@ def slices():
a.__setitem__(slice(0, 2, 1), [2,3])
vereq(a, [2,3,1])
+def subtype_resurrection():
+ if verbose:
+ print "Testing resurrection of new-style instance."
+
+ class C(object):
+ container = []
+
+ def __del__(self):
+ # resurrect the instance
+ C.container.append(self)
+
+ c = C()
+ c.attr = 42
+ # The only interesting thing here is whether this blows up in a
+ # debug build, 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
+ vereq(C.container[-1].attr, 42)
def do_this_first():
if verbose:
@@ -3274,6 +3293,7 @@ def test_main():
string_exceptions()
copy_setstate()
slices()
+ subtype_resurrection()
if verbose: print "All OK"
if __name__ == "__main__":