]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-110968: Py_MOD_PER_INTERPRETER_GIL_SUPPORTED was added to 3.12 (#111588)
authorVictor Stinner <vstinner@python.org>
Wed, 1 Nov 2023 17:13:31 +0000 (18:13 +0100)
committerGitHub <noreply@github.com>
Wed, 1 Nov 2023 17:13:31 +0000 (18:13 +0100)
Constants like Py_MOD_PER_INTERPRETER_GIL_SUPPORTED were only added
to the limited C API version 3.12 and newer.

Include/moduleobject.h
Modules/xxlimited.c
Modules/xxlimited_35.c

index b8bdfe29d80406b08a55e6a9c643ebf6acae7c2f..1717eb352d2a4dc4a1bcc19969bdd8e9efc1ed2a 100644 (file)
@@ -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;
index 3935c00fc26530a41671836b6905aa57f2d57bf6..b9646debba949998a7a9c43f7e4896e47aa6568c 100644 (file)
@@ -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 <string.h>
index 1ff3ef1cb6f296e35981997e9d9d9870d460d7f2..361c7e76d77f5082e7f0209c09b3a14cb38fa1a3 100644 (file)
@@ -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}
 };