summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Include/cpython/object.h1
-rw-r--r--Modules/_testcapi/gc.c4
-rw-r--r--Objects/object.c15
3 files changed, 14 insertions, 6 deletions
diff --git a/Include/cpython/object.h b/Include/cpython/object.h
index d6482f4..c939316 100644
--- a/Include/cpython/object.h
+++ b/Include/cpython/object.h
@@ -4,6 +4,7 @@
PyAPI_FUNC(void) _Py_NewReference(PyObject *op);
PyAPI_FUNC(void) _Py_NewReferenceNoTotal(PyObject *op);
+PyAPI_FUNC(void) _Py_ResurrectReference(PyObject *op);
#ifdef Py_REF_DEBUG
/* These are useful as debugging aids when chasing down refleaks. */
diff --git a/Modules/_testcapi/gc.c b/Modules/_testcapi/gc.c
index 829200a..f4feaaa 100644
--- a/Modules/_testcapi/gc.c
+++ b/Modules/_testcapi/gc.c
@@ -126,9 +126,7 @@ slot_tp_del(PyObject *self)
* never happened.
*/
{
- Py_ssize_t refcnt = Py_REFCNT(self);
- _Py_NewReferenceNoTotal(self);
- Py_SET_REFCNT(self, refcnt);
+ _Py_ResurrectReference(self);
}
assert(!PyType_IS_GC(Py_TYPE(self)) || PyObject_GC_IsTracked(self));
}
diff --git a/Objects/object.c b/Objects/object.c
index d970a26..587c552 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -509,9 +509,7 @@ PyObject_CallFinalizerFromDealloc(PyObject *self)
/* tp_finalize resurrected it! Make it look like the original Py_DECREF
* never happened. */
- Py_ssize_t refcnt = Py_REFCNT(self);
- _Py_NewReferenceNoTotal(self);
- Py_SET_REFCNT(self, refcnt);
+ _Py_ResurrectReference(self);
_PyObject_ASSERT(self,
(!_PyType_IS_GC(Py_TYPE(self))
@@ -2389,6 +2387,17 @@ _Py_NewReferenceNoTotal(PyObject *op)
new_reference(op);
}
+void
+_Py_ResurrectReference(PyObject *op)
+{
+ if (_PyRuntime.tracemalloc.config.tracing) {
+ _PyTraceMalloc_NewReference(op);
+ }
+#ifdef Py_TRACE_REFS
+ _Py_AddToAllObjects(op);
+#endif
+}
+
#ifdef Py_TRACE_REFS
void