You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
C API: Enable limited C API tests on Free Threading #155561
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#ifdefPy_GIL_DISABLED# definePy_TARGET_ABI3T 0x030f0000
#else// Need limited C API version 3.13 for Py_GetConstant()# definePy_LIMITED_API 0x030d0000
#endif
Most parts of _testlimitedcapi are now built with the limited C API on Free Threading.
Modules/_testlimitedcapi.c doesn't use PySlot API because WASI builds _testlimitedcapi as a built-in module, and built-in module are expected to implement a PyInit function. Adding support for PyExport functions in Modules/config.c is quite complicated. I prefer to stop here.
Activity
gh-155561: Build most _testlimitedcapi files with Py_TARGET_ABI3T (#1…
pythongh-155561: Use PySlot API in Modules/_testlimitedcapi.c
pythongh-155561: Build most _testlimitedcapi files with Py_TARGET_ABI…
gh-155561: Use multi-phase init for Modules/_testlimitedcapi.c (GH-15…
pythongh-155561: Use multi-phase init for Modules/_testlimitedcapi.c (p…
[3.15] gh-155561: Build most _testlimitedcapi files with Py_TARGET_AB…
vstinner commentedon Oct 20, 2026
Most parts of _testlimitedcapi are now built with the limited C API on Free Threading.
Modules/_testlimitedcapi.cdoesn't usePySlotAPI because WASI builds_testlimitedcapias a built-in module, and built-in module are expected to implement aPyInitfunction. Adding support for PyExport functions in Modules/config.c is quite complicated. I prefer to stop here.