This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients vstinner
Date 2021-04-01.06:47:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Currently, doesn't build xxlimited and xxlimited_35 extension modules with the limited C API if Python is built in debug mode. I only found two functions affected by Py_DEBUG macro in the limited C API: Py_INCREF() and Py_DECREF().

#if defined(Py_DEBUG) && !defined(Py_REF_DEBUG)
#define Py_REF_DEBUG

static inline void _Py_INCREF(PyObject *op)
#ifdef Py_REF_DEBUG
#define Py_INCREF(op) _Py_INCREF(_PyObject_CAST(op))

If Py_DEBUG is defined (Python built in debug mode), Py_INCREF() increments the private _Py_RefTotal variable.

The limited C API is supposed to provide a stable ABI, but Py_INCREF() leaks _Py_RefTotal implementation if Python is built in debug mode.

I propose to modify Py_INCREF() and Py_DECREF() of the limited C API to always declare them as opaque function calls. The regular (non limited) C API will continue to use the same static inline functions.

See also and bpo-41111 "[C API] Convert a few stdlib extensions to the limited C API (PEP 384)".

Note: Py_XINCREF() and Py_XDECREF() should be fine.
Date User Action Args
2021-04-01 06:47:31vstinnersetrecipients: + vstinner
2021-04-01 06:47:31vstinnersetmessageid: <>
2021-04-01 06:47:31vstinnerlinkissue43688 messages
2021-04-01 06:47:30vstinnercreate