Skip to content

Commit 2b67fc5

Browse files
authored
gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610)
Accept spaces in "# define Py_LIMITED_API 0x030d0000".
1 parent 06e29a2 commit 2b67fc5

13 files changed

+26
-36
lines changed

Modules/_ctypes/_ctypes_test.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
12
#include "pyconfig.h" // Py_GIL_DISABLED
2-
33
#ifndef Py_GIL_DISABLED
4-
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
5-
#define Py_LIMITED_API 0x030c0000
4+
# define Py_LIMITED_API 0x030c0000
65
#endif
76

87
// gh-85283: On Windows, Py_LIMITED_API requires Py_BUILD_CORE to not attempt

Modules/_multiprocessing/posixshmem.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
posixshmem - A Python extension that provides shm_open() and shm_unlink()
33
*/
44

5+
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
56
#include "pyconfig.h" // Py_GIL_DISABLED
6-
77
#ifndef Py_GIL_DISABLED
8-
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
9-
#define Py_LIMITED_API 0x030c0000
8+
# define Py_LIMITED_API 0x030c0000
109
#endif
1110

1211
#include <Python.h>

Modules/_scproxy.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
* using the SystemConfiguration framework.
44
*/
55

6+
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
67
#include "pyconfig.h" // Py_GIL_DISABLED
7-
88
#ifndef Py_GIL_DISABLED
9-
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
10-
#define Py_LIMITED_API 0x030c0000
9+
# define Py_LIMITED_API 0x030c0000
1110
#endif
1211

1312
#include <Python.h>

Modules/_stat.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
*
1212
*/
1313

14+
// Need limited C API version 3.13 for PyModule_Add() on Windows
1415
#include "pyconfig.h" // Py_GIL_DISABLED
15-
1616
#ifndef Py_GIL_DISABLED
17-
// Need limited C API version 3.13 for PyModule_Add() on Windows
18-
#define Py_LIMITED_API 0x030d0000
17+
# define Py_LIMITED_API 0x030d0000
1918
#endif
2019

2120
#include "Python.h"

Modules/_testclinic_limited.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
#undef Py_BUILD_CORE_MODULE
55
#undef Py_BUILD_CORE_BUILTIN
66

7+
// For now, AC only supports the limited C API version 3.13
78
#include "pyconfig.h" // Py_GIL_DISABLED
8-
99
#ifndef Py_GIL_DISABLED
10-
// For now, only limited C API 3.13 is supported
11-
#define Py_LIMITED_API 0x030d0000
10+
# define Py_LIMITED_API 0x030d0000
1211
#endif
1312

1413
/* Always enable assertions */

Modules/_testimportmultiple.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
*/
66

77
#include "pyconfig.h" // Py_GIL_DISABLED
8-
98
#ifndef Py_GIL_DISABLED
10-
#define Py_LIMITED_API 0x03020000
9+
# define Py_LIMITED_API 0x03020000
1110
#endif
1211

1312
#include <Python.h>

Modules/_uuidmodule.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
* DCE compatible Universally Unique Identifier library.
44
*/
55

6+
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
67
#include "pyconfig.h" // Py_GIL_DISABLED
7-
88
#ifndef Py_GIL_DISABLED
9-
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
10-
#define Py_LIMITED_API 0x030c0000
9+
# define Py_LIMITED_API 0x030c0000
1110
#endif
1211

1312
#include "Python.h"

Modules/errnomodule.c

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

3+
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
34
#include "pyconfig.h" // Py_GIL_DISABLED
4-
55
#ifndef Py_GIL_DISABLED
6-
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
7-
#define Py_LIMITED_API 0x030c0000
6+
# define Py_LIMITED_API 0x030c0000
87
#endif
98

109
#include "Python.h"

Modules/resource.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
// Need limited C API version 3.13 for PySys_Audit()
12
#include "pyconfig.h" // Py_GIL_DISABLED
2-
33
#ifndef Py_GIL_DISABLED
4-
// Need limited C API version 3.13 for PySys_Audit()
5-
#define Py_LIMITED_API 0x030d0000
4+
# define Py_LIMITED_API 0x030d0000
65
#endif
76

87
#include "Python.h"

Modules/xxlimited.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@
6262
pass
6363
*/
6464

65+
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
6566
#include "pyconfig.h" // Py_GIL_DISABLED
66-
6767
#ifndef Py_GIL_DISABLED
68-
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
69-
#define Py_LIMITED_API 0x030c0000
68+
# define Py_LIMITED_API 0x030c0000
7069
#endif
7170

7271
#include "Python.h"

Modules/xxlimited_35.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* See the xxlimited module for an extension module template.
66
*/
77

8+
// Test the limited C API version 3.5
89
#include "pyconfig.h" // Py_GIL_DISABLED
9-
1010
#ifndef Py_GIL_DISABLED
11-
#define Py_LIMITED_API 0x03050000
11+
# define Py_LIMITED_API 0x03050000
1212
#endif
1313

1414
#include "Python.h"

PC/winsound.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@
3535
winsound.PlaySound(None, 0)
3636
*/
3737

38+
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
3839
#include "pyconfig.h" // Py_GIL_DISABLED
39-
4040
#ifndef Py_GIL_DISABLED
41-
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
42-
#define Py_LIMITED_API 0x030c0000
41+
# define Py_LIMITED_API 0x030c0000
4342
#endif
4443

4544
#include <Python.h>

Tools/clinic/clinic.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@
6666
#
6767

6868

69-
# match '#define Py_LIMITED_API'
70-
LIMITED_CAPI_REGEX = re.compile(r'#define +Py_LIMITED_API')
69+
# Match '#define Py_LIMITED_API'.
70+
# Match '# define Py_LIMITED_API 0x030d0000' (without the version).
71+
LIMITED_CAPI_REGEX = re.compile(r'# *define +Py_LIMITED_API')
7172

7273

7374
class Sentinels(enum.Enum):

0 commit comments

Comments
 (0)