From cbde052a0b24ccae66541fd95932d87bffa4a11f Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 6 Jun 2023 16:33:21 +0200 Subject: [PATCH] gh-105387: Limited C API implements Py_INCREF() as func In the limited C API version 3.12 and newer, Py_INCREF() and Py_DECREF() functions are now implemented as opaque function calls in the stable ABI to hide implementation details. --- Include/object.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Include/object.h b/Include/object.h index dc5b087db2f467b..bfd1ad819571511 100644 --- a/Include/object.h +++ b/Include/object.h @@ -610,8 +610,9 @@ PyAPI_FUNC(void) _Py_DecRef(PyObject *); static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op) { -#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) - // Stable ABI for Python built in debug mode +#if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG)) + // Stable ABI implements Py_INCREF() as a function call on limited C API + // version 3.12 and newer, and on Python built in debug mode _Py_IncRef(op); #else // Non-limited C API and limited C API for Python 3.9 and older access @@ -641,8 +642,9 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op) # define Py_INCREF(op) Py_INCREF(_PyObject_CAST(op)) #endif -#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) -// Stable ABI for Python built in debug mode +#if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG)) +// Stable ABI implements Py_DECREF() as a function call on limited C API +// version 3.12 and newer, and on Python built in debug mode static inline void Py_DECREF(PyObject *op) { _Py_DecRef(op); }