[Python-checkins] python/dist/src/Lib/test test_descr.py,1.113.4.19,1.113.4.20

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Thu, 11 Jul 2002 00:06:45 -0700


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

Modified Files:
      Tag: release22-maint
	test_descr.py 
Log Message:
Attempting to resurrect a dying instance of a new-style class in a
__del__ method died with

    Fatal Python error: GC object already in linked list

in both release and debug builds.  Fixed that.  Added a new test that
dies without the fix.


Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.113.4.19
retrieving revision 1.113.4.20
diff -C2 -d -r1.113.4.19 -r1.113.4.20
*** test_descr.py	24 Jun 2002 13:25:41 -0000	1.113.4.19
--- test_descr.py	11 Jul 2002 07:06:42 -0000	1.113.4.20
***************
*** 2982,2985 ****
--- 2982,3005 ----
      vereq(b.getfoo(), 24)
  
+ 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 test_main():
      class_docstrings()
***************
*** 3042,3045 ****
--- 3062,3066 ----
      imulbug()
      copy_setstate()
+     subtype_resurrection()
      if verbose: print "All OK"