From a2551695bfd760f33423a91dcdc287896ceaa052 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 1 Nov 2023 04:25:43 +0100 Subject: [PATCH 1/2] gh-110968: Py_MOD_PER_INTERPRETER_GIL_SUPPORTED was added to 3.12 Constants like Py_MOD_PER_INTERPRETER_GIL_SUPPORTED were only added to the limited C API version 3.12 and newer. --- Include/moduleobject.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Include/moduleobject.h b/Include/moduleobject.h index b8bdfe29d80406..1717eb352d2a4d 100644 --- a/Include/moduleobject.h +++ b/Include/moduleobject.h @@ -84,13 +84,15 @@ struct PyModuleDef_Slot { #define _Py_mod_LAST_SLOT 3 #endif -/* for Py_mod_multiple_interpreters: */ -#define Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED ((void *)0) -#define Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED ((void *)1) -#define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED ((void *)2) - #endif /* New in 3.5 */ +/* for Py_mod_multiple_interpreters: */ +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000 +# define Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED ((void *)0) +# define Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED ((void *)1) +# define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED ((void *)2) +#endif + struct PyModuleDef { PyModuleDef_Base m_base; const char* m_name; From 5bd61d135e3c8db422d9a5169dc255c4194dcd8e Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 1 Nov 2023 04:28:12 +0100 Subject: [PATCH 2/2] Update xxlimited extensions --- Modules/xxlimited.c | 3 ++- Modules/xxlimited_35.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/xxlimited.c b/Modules/xxlimited.c index 3935c00fc26530..b9646debba9499 100644 --- a/Modules/xxlimited.c +++ b/Modules/xxlimited.c @@ -62,7 +62,8 @@ pass */ -#define Py_LIMITED_API 0x030b0000 +// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED +#define Py_LIMITED_API 0x030c0000 #include "Python.h" #include diff --git a/Modules/xxlimited_35.c b/Modules/xxlimited_35.c index 1ff3ef1cb6f296..361c7e76d77f50 100644 --- a/Modules/xxlimited_35.c +++ b/Modules/xxlimited_35.c @@ -293,7 +293,6 @@ xx_modexec(PyObject *m) static PyModuleDef_Slot xx_slots[] = { {Py_mod_exec, xx_modexec}, - {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED}, {0, NULL} };