summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2004-08-03 10:21:03 (GMT)
committerMichael W. Hudson <mwh@python.net>2004-08-03 10:21:03 (GMT)
commit3f3b66823f899868b86722d586a6cd00df4cbad9 (patch)
treeb848a249f44b6e2278252ce9fcda1ab4b4588820 /Objects
parent3bfed9c22547d1f950bb4bcbb54acae894e9b343 (diff)
downloadcpython-3f3b66823f899868b86722d586a6cd00df4cbad9.zip
cpython-3f3b66823f899868b86722d586a6cd00df4cbad9.tar.gz
cpython-3f3b66823f899868b86722d586a6cd00df4cbad9.tar.bz2
Repair the same thinko in two places about handling of _Py_RefTotal in
the case of __del__ resurrecting an object. This makes the apparent reference leaks in test_descr go away (which I expected) and also kills off those in test_gc (which is more surprising but less so once you actually think about it a bit).
Diffstat (limited to 'Objects')
-rw-r--r--Objects/classobject.c13
-rw-r--r--Objects/typeobject.c9
2 files changed, 12 insertions, 10 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 17a5646..bdbcd6a 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -670,13 +670,14 @@ instance_dealloc(register PyInstanceObject *inst)
_Py_NewReference((PyObject *)inst);
inst->ob_refcnt = refcnt;
_PyObject_GC_TRACK(inst);
- /* If Py_REF_DEBUG, the original decref dropped _Py_RefTotal,
- * but _Py_NewReference bumped it again, so that's a wash.
- * If Py_TRACE_REFS, _Py_NewReference re-added self to the
- * object chain, so no more to do there either.
+ /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
+ * we need to undo that. */
+ _Py_DEC_REFTOTAL;
+ /* If Py_TRACE_REFS, _Py_NewReference re-added self to the
+ * object chain, so no more to do there.
* If COUNT_ALLOCS, the original decref bumped tp_frees, and
- * _Py_NewReference bumped tp_allocs: both of those need to
- * be undone.
+ * _Py_NewReference bumped tp_allocs: both of those need to be
+ * undone.
*/
#ifdef COUNT_ALLOCS
--inst->ob_type->tp_frees;
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 1a052c7..b33b21c 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -4837,10 +4837,11 @@ slot_tp_del(PyObject *self)
}
assert(!PyType_IS_GC(self->ob_type) ||
_Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
- /* If Py_REF_DEBUG, the original decref dropped _Py_RefTotal, but
- * _Py_NewReference bumped it again, so that's a wash.
- * If Py_TRACE_REFS, _Py_NewReference re-added self to the object
- * chain, so no more to do there either.
+ /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
+ * we need to undo that. */
+ _Py_DEC_REFTOTAL;
+ /* If Py_TRACE_REFS, _Py_NewReference re-added self to the object
+ * chain, so no more to do there.
* If COUNT_ALLOCS, the original decref bumped tp_frees, and
* _Py_NewReference bumped tp_allocs: both of those need to be
* undone.