bpo-39542: Simplify _Py_NewReference() (GH-18332)

* Remove _Py_INC_REFTOTAL and _Py_DEC_REFTOTAL macros: modify
  directly _Py_RefTotal.
* _Py_ForgetReference() is no longer defined if the Py_TRACE_REFS
  macro is not defined.
* Remove _Py_NewReference() implementation from object.c:
  unify the two implementations in object.h inline function.
* Fix Py_TRACE_REFS build: _Py_INC_TPALLOCS() macro has been removed.
This commit is contained in:
Victor Stinner 2020-02-03 17:55:05 +01:00 committed by GitHub
parent 24e5ad4689
commit 49932fec62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 60 additions and 58 deletions

View file

@ -3586,9 +3586,11 @@ slot_tp_del(PyObject *self)
self->ob_refcnt = refcnt;
}
assert(!PyType_IS_GC(Py_TYPE(self)) || _PyObject_GC_IS_TRACKED(self));
/* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
* we need to undo that. */
_Py_DEC_REFTOTAL;
/* If Py_REF_DEBUG macro is defined, _Py_NewReference() increased
_Py_RefTotal, so we need to undo that. */
#ifdef Py_REF_DEBUG
_Py_RefTotal--;
#endif
}
static PyObject *