Mercurial > cpython-lru_cache-weakref
diff Objects/typeobject.c @ 29442:6fecc99afa69 legacy-trunk
- SF patch 751998 fixes an unwanted side effect of the previous fix
for SF bug 742860 (the next item).
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 13 Jun 2003 20:54:40 +0000 |
| parents | 31b2cba64b39 |
| children | 60b53db14aa3 |
line wrap: on
line diff
--- a/Objects/typeobject.c Fri Jun 13 20:49:55 2003 +0000 +++ b/Objects/typeobject.c Fri Jun 13 20:54:40 2003 +0000 @@ -638,18 +638,17 @@ --_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 @@ 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);
