vereq(b.foo, 24)
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()
lists()
docdescriptor()
imulbug()
copy_setstate()
+ subtype_resurrection()
if verbose: print "All OK"
if __name__ == "__main__":
Core and builtins
+- If a dying instance of a new-style class got resurrected by its class's
+ __del__ method, Python aborted with a fatal error.
+
- Source that creates parse nodes with an extremely large number of
children (e.g., test_longexp.py) triggers problems with the
platform realloc() under several platforms (e.g., MacPython, and
#ifdef COUNT_ALLOCS
self->ob_type->tp_frees--;
#endif
- _PyObject_GC_TRACK(self);
+ /* This should still be a tracked gc'ed object. */
+ assert(((PyGC_Head *)(self)-1)->gc.gc_next != NULL);
return -1; /* __del__ added a reference; don't delete now */
}
#ifdef Py_TRACE_REFS