diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 4a21b25c9bf6a51..67bc2ed033802e5 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -3526,3 +3526,16 @@ ssl that applies even when an application supplies its own root CA bundle, and regardless of whether the platform trust store has removed trust. (Contributed by Christian Heimes in :gh:`160040` for :cve:`2026-115557`.) + + +Notable changes in 3.14.11 +========================== + +C API changes +------------- + +* :c:func:`Py_INCREF`, :c:func:`Py_XINCREF`, :c:func:`Py_DECREF` and + :c:func:`Py_XDECREF` are now implemented as function calls on all limited C + API versions. Previously, they were only implemented as function calls on + the limited C API version 3.12 or newer. Patch by Victor Stinner: + (Contributed by Victor Stinner in :gh:`158401`.) diff --git a/Include/refcount.h b/Include/refcount.h index 5c1cdae5dfb3935..61cbd27ee3db3bb 100644 --- a/Include/refcount.h +++ b/Include/refcount.h @@ -251,12 +251,12 @@ PyAPI_FUNC(void) _Py_DecRef(PyObject *); static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op) { -#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() - // was added to Python 3.10.0a7, use Py_IncRef() on older Python versions. - // Py_IncRef() accepts NULL whereas _Py_IncRef() doesn't. -# if Py_LIMITED_API+0 >= 0x030a00A7 +#if defined(Py_LIMITED_API) + // gh-158401: The stable ABI now implements Py_INCREF() as a function + // call on all limited C API versions. _Py_IncRef() was added to Python + // 3.10.0a7, use Py_IncRef() on older versions. Py_IncRef() accepts NULL, + // whereas _Py_IncRef() doesn't. +# if Py_LIMITED_API+0 >= 0x030a0000 _Py_IncRef(op); # else Py_IncRef(op); @@ -319,13 +319,13 @@ PyAPI_FUNC(void) _Py_DecRefSharedDebug(PyObject *, const char *, int); PyAPI_FUNC(void) _Py_MergeZeroLocalRefcount(PyObject *); #endif -#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. _Py_DecRef() was -// added to Python 3.10.0a7, use Py_DecRef() on older Python versions. -// Py_DecRef() accepts NULL whereas _Py_DecRef() doesn't. +#if defined(Py_LIMITED_API) +// gh-158401: The stable ABI now implements Py_DECREF() as a function call +// on all limited C API versions. _Py_DecRef() was added to Python 3.10.0a7, +// use Py_DecRef() on older versions. Py_DecRef() accepts NULL, whereas +// _Py_DecRef() doesn't. static inline void Py_DECREF(PyObject *op) { -# if Py_LIMITED_API+0 >= 0x030a00A7 +# if Py_LIMITED_API+0 >= 0x030a0000 _Py_DecRef(op); # else Py_DecRef(op); diff --git a/Misc/NEWS.d/next/C_API/2026-11-16-17-25-12.gh-issue-158401.ADBBRG.rst b/Misc/NEWS.d/next/C_API/2026-11-16-17-25-12.gh-issue-158401.ADBBRG.rst new file mode 100644 index 000000000000000..f1b59a75095b2a0 --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2026-11-16-17-25-12.gh-issue-158401.ADBBRG.rst @@ -0,0 +1,4 @@ +:c:func:`Py_INCREF`, :c:func:`Py_XINCREF`, :c:func:`Py_DECREF` and +:c:func:`Py_XDECREF` are now implemented as function calls on all limited C +API versions. Previously, they were only implemented as function calls on +the limited C API version 3.12 or newer. Patch by Victor Stinner: