This PR adds the ability to enable the GIL if it was disabled at
interpreter startup, and modifies the multi-phase module initialization
path to enable the GIL when loading a module, unless that module's spec
includes a slot indicating it can run safely without the GIL.
PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went
with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148.
A warning will be issued up to once per interpreter for the first
GIL-using module that is loaded. If `-v` is given, a shorter message
will be printed to stderr every time a GIL-using module is loaded
(including the first one that issues a warning).
* Only add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED to limited C API
version 3.13.
* errno, xxlimited and _ctypes_test extensions now need the limited C
API version 3.13 to get Py_MOD_PER_INTERPRETER_GIL_SUPPORTED. They
now include standard header files explicitly: <errno.h>, <string.h>
and <stdio.h>.
* xxlimited_35: Remove Py_mod_multiple_interpreters slot,
incompatible with limited C API version 3.5.
Here we are doing no more than adding the value for Py_mod_multiple_interpreters and using it for stdlib modules. We will start checking for it in gh-104206 (once PyInterpreterState.ceval.own_gil is added in gh-104204).
xxlimited.c and xxlimited_35.c now define the Py_LIMITED_API macro,
rather than having to do it in the build recipe.
Co-authored-by: Hai Shi <shihai1992@gmail.com>
- Copy existing xxlimited to xxlimited53 (named for the limited API version it uses)
- Build both modules, both in debug and release
- Test both modules