Skip to content

Commit 6c40c35

Browse files
vstinneraisk
authored andcommitted
pythongh-110968: Py_MOD_PER_INTERPRETER_GIL_SUPPORTED new in 3.13. (python#110969)
* 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.
1 parent c548279 commit 6c40c35

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

Include/moduleobject.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@ struct PyModuleDef_Slot {
7979
#define _Py_mod_LAST_SLOT 3
8080
#endif
8181

82+
#endif /* New in 3.5 */
83+
8284
/* for Py_mod_multiple_interpreters: */
85+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
8386
#define Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED ((void *)0)
8487
#define Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED ((void *)1)
8588
#define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED ((void *)2)
86-
87-
#endif /* New in 3.5 */
89+
#endif
8890

8991
struct PyModuleDef {
9092
PyModuleDef_Base m_base;

Modules/_ctypes/_ctypes_test.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
#define Py_LIMITED_API 0x03060000
1+
// Need limited C API version 3.13 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
2+
#define Py_LIMITED_API 0x030d0000
23

34
#include <Python.h>
45

6+
#include <stdio.h> // printf()
57
#include <stdlib.h> // qsort()
8+
#include <string.h> // memset()
69
#ifdef MS_WIN32
710
# include <windows.h>
811
#endif

Modules/errnomodule.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/* Errno module */
22

3-
// Need PyModuleDef_Slot added to limited C API version 3.5
4-
#define Py_LIMITED_API 0x03050000
3+
// Need limited C API version 3.13 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
4+
#define Py_LIMITED_API 0x030d0000
55

66
#include "Python.h"
7+
#include <errno.h> // EPIPE
78

89
/* Windows socket errors (WSA*) */
910
#ifdef MS_WINDOWS

Modules/xxlimited.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
pass
6363
*/
6464

65-
#define Py_LIMITED_API 0x030b0000
65+
// Need limited C API version 3.13 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
66+
#define Py_LIMITED_API 0x030d0000
6667

6768
#include "Python.h"
6869
#include <string.h>

Modules/xxlimited_35.c

-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ xx_modexec(PyObject *m)
293293

294294
static PyModuleDef_Slot xx_slots[] = {
295295
{Py_mod_exec, xx_modexec},
296-
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
297296
{0, NULL}
298297
};
299298

0 commit comments

Comments
 (0)