gh-105387: Limited C API implements Py_INCREF() as func (#105388) · python/cpython@b542972

GitHub

Original file line numberDiff line numberDiff line change@@ -610,10 +610,11 @@ PyAPI_FUNC(void) _Py_DecRef(PyObject *);

610610611611staticinlinePy_ALWAYS_INLINEvoidPy_INCREF(PyObject*op)

612612{

613-#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API)

614-// Stable ABI for Python built in debug mode. _Py_IncRef() was added to

615-// Python 3.10.0a7, use Py_IncRef() on older Python versions. Py_IncRef()

616-// accepts NULL whereas _Py_IncRef() doesn't.

613+#if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000|| defined(Py_REF_DEBUG))

614+// Stable ABI implements Py_INCREF() as a function call on limited C API

615+// version 3.12 and newer, and on Python built in debug mode. _Py_IncRef()

616+// was added to Python 3.10.0a7, use Py_IncRef() on older Python versions.

617+// Py_IncRef() accepts NULL whereas _Py_IncRef() doesn't.

617618# ifPy_LIMITED_API+0 >= 0x030a00A7

618619_Py_IncRef(op);

619620# else

@@ -647,10 +648,11 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)

647648# definePy_INCREF(op) Py_INCREF(_PyObject_CAST(op))

648649#endif

649650650-#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API)

651-// Stable ABI for Python built in debug mode. _Py_DecRef() was added to Python

652-// 3.10.0a7, use Py_DecRef() on older Python versions. Py_DecRef() accepts NULL

653-// whereas _Py_IncRef() doesn't.

651+#if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000|| defined(Py_REF_DEBUG))

652+// Stable ABI implements Py_DECREF() as a function call on limited C API

653+// version 3.12 and newer, and on Python built in debug mode. _Py_DecRef() was

654+// added to Python 3.10.0a7, use Py_DecRef() on older Python versions.

655+// Py_DecRef() accepts NULL whereas _Py_IncRef() doesn't.

654656staticinlinevoidPy_DECREF(PyObject*op) {

655657# ifPy_LIMITED_API+0 >= 0x030a00A7

656658_Py_DecRef(op);