[Python-checkins] python/dist/src/Lib/test test_descr.py,1.144,1.145

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Wed, 10 Jul 2002 23:56:09 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv30463/python/Lib/test

Modified Files:
	test_descr.py 
Log Message:
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.


Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.144
retrieving revision 1.145
diff -C2 -d -r1.144 -r1.145
*** test_descr.py	24 Jun 2002 13:08:16 -0000	1.144
--- test_descr.py	11 Jul 2002 06:56:07 -0000	1.145
***************
*** 3184,3187 ****
--- 3184,3206 ----
      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():
***************
*** 3275,3278 ****
--- 3294,3298 ----
      copy_setstate()
      slices()
+     subtype_resurrection()
      if verbose: print "All OK"