diff options
author | Guido van Rossum <guido@python.org> | 2003-06-13 20:54:40 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-06-13 20:54:40 (GMT) |
commit | 59195fdf40c3e3f066390ed2e23873aed1286e86 (patch) | |
tree | 0a8cf5a2bd5dd0efea139945ff6733f7418d2706 /Objects | |
parent | d321efda262d0d508716f60c64daab859a1ad2f0 (diff) | |
download | cpython-59195fdf40c3e3f066390ed2e23873aed1286e86.zip cpython-59195fdf40c3e3f066390ed2e23873aed1286e86.tar.gz cpython-59195fdf40c3e3f066390ed2e23873aed1286e86.tar.bz2 |
- SF patch 751998 fixes an unwanted side effect of the previous fix
for SF bug 742860 (the next item).
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 248345e..df9e617 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -638,18 +638,17 @@ subtype_dealloc(PyObject *self) --_PyTrash_delete_nesting; _PyObject_GC_TRACK(self); /* We'll untrack for real later */ - /* Find the nearest base with a different tp_dealloc - and clear slots while we're at it */ + /* Find the nearest base with a different tp_dealloc */ base = type; while ((basedealloc = base->tp_dealloc) == subtype_dealloc) { - if (base->ob_size) - clear_slots(base, self); base = base->tp_base; assert(base); } /* If we added a weaklist, we clear it. Do this *before* calling - the finalizer (__del__) or clearing the instance dict. */ + the finalizer (__del__), clearing slots, or clearing the instance + dict. */ + if (type->tp_weaklistoffset && !base->tp_weaklistoffset) PyObject_ClearWeakRefs(self); @@ -660,6 +659,15 @@ subtype_dealloc(PyObject *self) goto endlabel; } + /* Clear slots up to the nearest base with a different tp_dealloc */ + base = type; + while ((basedealloc = base->tp_dealloc) == subtype_dealloc) { + if (base->ob_size) + clear_slots(base, self); + base = base->tp_base; + assert(base); + } + /* If we added a dict, DECREF it */ if (type->tp_dictoffset && !base->tp_dictoffset) { PyObject **dictptr = _PyObject_GetDictPtr(self); |