Currently, the _testlimitedcapi extension module is not built with the limited C API on Free Threading which is misleading and defeats the purpose of this extension.
PEP 803 added Py_TARGET_ABI3T macro to Python 3.15 which makes it possible to build a C extension using the limited C API when using Free Threading. So I propose building _testlimitedcapi using Py_TARGET_ABI3T to test properly the limited C API on Free Threading.
One limitation is that Py_TARGET_ABI3T minimum version is Python 3.15, whereas _testlimitedcapi/<file>.c files target older Python versions. Anyway, we have to only define Py_TARGET_ABI3T on Free Threading, or define Py_LIMITED_API macro otherwise (build with GIL). Example:
#include "pyconfig.h" // Py_GIL_DISABLED
#ifdef Py_GIL_DISABLED
# define Py_TARGET_ABI3T 0x030f0000
#else
// Need limited C API version 3.13 for Py_GetConstant()
# define Py_LIMITED_API 0x030d0000
#endif
Linked PRs
Currently, the
_testlimitedcapiextension module is not built with the limited C API on Free Threading which is misleading and defeats the purpose of this extension.PEP 803 added
Py_TARGET_ABI3Tmacro to Python 3.15 which makes it possible to build a C extension using the limited C API when using Free Threading. So I propose building_testlimitedcapiusingPy_TARGET_ABI3Tto test properly the limited C API on Free Threading.One limitation is that
Py_TARGET_ABI3Tminimum version is Python 3.15, whereas_testlimitedcapi/<file>.cfiles target older Python versions. Anyway, we have to only definePy_TARGET_ABI3Ton Free Threading, or definePy_LIMITED_APImacro otherwise (build with GIL). Example:Linked PRs