]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix Py_INCREF() statistics in limited C API 3.10 (#96120)
authorVictor Stinner <vstinner@python.org>
Mon, 29 Aug 2022 12:55:46 +0000 (14:55 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Aug 2022 12:55:46 +0000 (14:55 +0200)
In the limited C API with a debug build, Py_INCREF() is implemented
by calling _Py_IncRef() which calls Py_INCREF(). Only call
_Py_INCREF_STAT_INC() once.

Include/object.h

index 21d3a75834eba5e6203e5eb490e426c226007809..75624fe8c77a514d8dca94e463bc12e74a8e3591 100644 (file)
@@ -511,11 +511,11 @@ PyAPI_FUNC(void) _Py_DecRef(PyObject *);
 
 static inline void Py_INCREF(PyObject *op)
 {
-    _Py_INCREF_STAT_INC();
 #if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030A0000
     // Stable ABI for Python 3.10 built in debug mode.
     _Py_IncRef(op);
 #else
+    _Py_INCREF_STAT_INC();
     // Non-limited C API and limited C API for Python 3.9 and older access
     // directly PyObject.ob_refcnt.
 #ifdef Py_REF_DEBUG