[Python-checkins] python/dist/src/Objects typeobject.c,2.233,2.234
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Thu, 29 May 2003 07:29:26 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv22604
Modified Files:
typeobject.c
Log Message:
Fix for SF 742911. We now clear the weakrefs *before* calling __del__
or emptying __dict__, just as we do for classic classes.
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.233
retrieving revision 2.234
diff -C2 -d -r2.233 -r2.234
*** typeobject.c 21 May 2003 21:29:48 -0000 2.233
--- typeobject.c 29 May 2003 14:29:23 -0000 2.234
***************
*** 639,649 ****
_PyObject_GC_TRACK(self); /* We'll untrack for real later */
- /* Maybe call finalizer; exit early if resurrected */
- if (type->tp_del) {
- type->tp_del(self);
- if (self->ob_refcnt > 0)
- goto endlabel;
- }
-
/* Find the nearest base with a different tp_dealloc
and clear slots while we're at it */
--- 639,642 ----
***************
*** 656,659 ****
--- 649,664 ----
}
+ /* If we added a weaklist, we clear it. Do this *before* calling
+ the finalizer (__del__) or clearing the instance dict. */
+ if (type->tp_weaklistoffset && !base->tp_weaklistoffset)
+ PyObject_ClearWeakRefs(self);
+
+ /* Maybe call finalizer; exit early if resurrected */
+ if (type->tp_del) {
+ type->tp_del(self);
+ if (self->ob_refcnt > 0)
+ goto endlabel;
+ }
+
/* If we added a dict, DECREF it */
if (type->tp_dictoffset && !base->tp_dictoffset) {
***************
*** 667,674 ****
}
}
-
- /* If we added weaklist, we clear it */
- if (type->tp_weaklistoffset && !base->tp_weaklistoffset)
- PyObject_ClearWeakRefs(self);
/* Finalize GC if the base doesn't do GC and we do */
--- 672,675 ----