From d3d2cfead71e3a64704d8e578f22bba18b8e0284 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 1 Nov 2023 18:13:31 +0100 Subject: [3.12] gh-110968: Py_MOD_PER_INTERPRETER_GIL_SUPPORTED was added to 3.12 (#111588) 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 +++++++----- Modules/xxlimited.c | 3 ++- Modules/xxlimited_35.c | 1 - 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Include/moduleobject.h b/Include/moduleobject.h index b8bdfe2..1717eb3 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; diff --git a/Modules/xxlimited.c b/Modules/xxlimited.c index 3935c00..b9646de 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 1ff3ef1..361c7e7 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} }; -- cgit v0.12