summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-03-11 22:42:18 (GMT)
committerGitHub <noreply@github.com>2024-03-11 22:42:18 (GMT)
commit2b67fc57f6e97c8389fe970ed232c1ad484113e1 (patch)
tree913984c1a9d4bedfc34ce8de9f1847873b41a51c
parent06e29a224fac9edeba55422d2e60f2fbb88dddce (diff)
downloadcpython-2b67fc57f6e97c8389fe970ed232c1ad484113e1.zip
cpython-2b67fc57f6e97c8389fe970ed232c1ad484113e1.tar.gz
cpython-2b67fc57f6e97c8389fe970ed232c1ad484113e1.tar.bz2
gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610)
Accept spaces in "# define Py_LIMITED_API 0x030d0000".
-rw-r--r--Modules/_ctypes/_ctypes_test.c5
-rw-r--r--Modules/_multiprocessing/posixshmem.c5
-rw-r--r--Modules/_scproxy.c5
-rw-r--r--Modules/_stat.c5
-rw-r--r--Modules/_testclinic_limited.c5
-rw-r--r--Modules/_testimportmultiple.c3
-rw-r--r--Modules/_uuidmodule.c5
-rw-r--r--Modules/errnomodule.c5
-rw-r--r--Modules/resource.c5
-rw-r--r--Modules/xxlimited.c5
-rw-r--r--Modules/xxlimited_35.c4
-rw-r--r--PC/winsound.c5
-rwxr-xr-xTools/clinic/clinic.py5
13 files changed, 26 insertions, 36 deletions
diff --git a/Modules/_ctypes/_ctypes_test.c b/Modules/_ctypes/_ctypes_test.c
index ecc6041..1dd3ef1 100644
--- a/Modules/_ctypes/_ctypes_test.c
+++ b/Modules/_ctypes/_ctypes_test.c
@@ -1,8 +1,7 @@
+// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
#include "pyconfig.h" // Py_GIL_DISABLED
-
#ifndef Py_GIL_DISABLED
-// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
-#define Py_LIMITED_API 0x030c0000
+# define Py_LIMITED_API 0x030c0000
#endif
// gh-85283: On Windows, Py_LIMITED_API requires Py_BUILD_CORE to not attempt
diff --git a/Modules/_multiprocessing/posixshmem.c b/Modules/_multiprocessing/posixshmem.c
index 4ab15fa..d332a4e 100644
--- a/Modules/_multiprocessing/posixshmem.c
+++ b/Modules/_multiprocessing/posixshmem.c
@@ -2,11 +2,10 @@
posixshmem - A Python extension that provides shm_open() and shm_unlink()
*/
+// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
#include "pyconfig.h" // Py_GIL_DISABLED
-
#ifndef Py_GIL_DISABLED
-// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
-#define Py_LIMITED_API 0x030c0000
+# define Py_LIMITED_API 0x030c0000
#endif
#include <Python.h>
diff --git a/Modules/_scproxy.c b/Modules/_scproxy.c
index fe82e91..042738b 100644
--- a/Modules/_scproxy.c
+++ b/Modules/_scproxy.c
@@ -3,11 +3,10 @@
* using the SystemConfiguration framework.
*/
+// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
#include "pyconfig.h" // Py_GIL_DISABLED
-
#ifndef Py_GIL_DISABLED
-// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
-#define Py_LIMITED_API 0x030c0000
+# define Py_LIMITED_API 0x030c0000
#endif
#include <Python.h>
diff --git a/Modules/_stat.c b/Modules/_stat.c
index b43e794..8059ec2 100644
--- a/Modules/_stat.c
+++ b/Modules/_stat.c
@@ -11,11 +11,10 @@
*
*/
+// Need limited C API version 3.13 for PyModule_Add() on Windows
#include "pyconfig.h" // Py_GIL_DISABLED
-
#ifndef Py_GIL_DISABLED
-// Need limited C API version 3.13 for PyModule_Add() on Windows
-#define Py_LIMITED_API 0x030d0000
+# define Py_LIMITED_API 0x030d0000
#endif
#include "Python.h"
diff --git a/Modules/_testclinic_limited.c b/Modules/_testclinic_limited.c
index df08ff9..1a73c04 100644
--- a/Modules/_testclinic_limited.c
+++ b/Modules/_testclinic_limited.c
@@ -4,11 +4,10 @@
#undef Py_BUILD_CORE_MODULE
#undef Py_BUILD_CORE_BUILTIN
+// For now, AC only supports the limited C API version 3.13
#include "pyconfig.h" // Py_GIL_DISABLED
-
#ifndef Py_GIL_DISABLED
-// For now, only limited C API 3.13 is supported
-#define Py_LIMITED_API 0x030d0000
+# define Py_LIMITED_API 0x030d0000
#endif
/* Always enable assertions */
diff --git a/Modules/_testimportmultiple.c b/Modules/_testimportmultiple.c
index 7e6556a..a65ca51 100644
--- a/Modules/_testimportmultiple.c
+++ b/Modules/_testimportmultiple.c
@@ -5,9 +5,8 @@
*/
#include "pyconfig.h" // Py_GIL_DISABLED
-
#ifndef Py_GIL_DISABLED
-#define Py_LIMITED_API 0x03020000
+# define Py_LIMITED_API 0x03020000
#endif
#include <Python.h>
diff --git a/Modules/_uuidmodule.c b/Modules/_uuidmodule.c
index 4b6852c..052cb9f 100644
--- a/Modules/_uuidmodule.c
+++ b/Modules/_uuidmodule.c
@@ -3,11 +3,10 @@
* DCE compatible Universally Unique Identifier library.
*/
+// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
#include "pyconfig.h" // Py_GIL_DISABLED
-
#ifndef Py_GIL_DISABLED
-// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
-#define Py_LIMITED_API 0x030c0000
+# define Py_LIMITED_API 0x030c0000
#endif
#include "Python.h"
diff --git a/Modules/errnomodule.c b/Modules/errnomodule.c
index 1100e9f..97e5f01 100644
--- a/Modules/errnomodule.c
+++ b/Modules/errnomodule.c
@@ -1,10 +1,9 @@
/* Errno module */
+// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
#include "pyconfig.h" // Py_GIL_DISABLED
-
#ifndef Py_GIL_DISABLED
-// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
-#define Py_LIMITED_API 0x030c0000
+# define Py_LIMITED_API 0x030c0000
#endif
#include "Python.h"
diff --git a/Modules/resource.c b/Modules/resource.c
index 19020b8..8ee07bd 100644
--- a/Modules/resource.c
+++ b/Modules/resource.c
@@ -1,8 +1,7 @@
+// Need limited C API version 3.13 for PySys_Audit()
#include "pyconfig.h" // Py_GIL_DISABLED
-
#ifndef Py_GIL_DISABLED
-// Need limited C API version 3.13 for PySys_Audit()
-#define Py_LIMITED_API 0x030d0000
+# define Py_LIMITED_API 0x030d0000
#endif
#include "Python.h"
diff --git a/Modules/xxlimited.c b/Modules/xxlimited.c
index 0bb5e12..3357b80 100644
--- a/Modules/xxlimited.c
+++ b/Modules/xxlimited.c
@@ -62,11 +62,10 @@
pass
*/
+// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
#include "pyconfig.h" // Py_GIL_DISABLED
-
#ifndef Py_GIL_DISABLED
-// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
-#define Py_LIMITED_API 0x030c0000
+# define Py_LIMITED_API 0x030c0000
#endif
#include "Python.h"
diff --git a/Modules/xxlimited_35.c b/Modules/xxlimited_35.c
index 754a368..52690d9 100644
--- a/Modules/xxlimited_35.c
+++ b/Modules/xxlimited_35.c
@@ -5,10 +5,10 @@
* See the xxlimited module for an extension module template.
*/
+// Test the limited C API version 3.5
#include "pyconfig.h" // Py_GIL_DISABLED
-
#ifndef Py_GIL_DISABLED
-#define Py_LIMITED_API 0x03050000
+# define Py_LIMITED_API 0x03050000
#endif
#include "Python.h"
diff --git a/PC/winsound.c b/PC/winsound.c
index 7e4ebd9..a6b2dac 100644
--- a/PC/winsound.c
+++ b/PC/winsound.c
@@ -35,11 +35,10 @@
winsound.PlaySound(None, 0)
*/
+// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
#include "pyconfig.h" // Py_GIL_DISABLED
-
#ifndef Py_GIL_DISABLED
-// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
-#define Py_LIMITED_API 0x030c0000
+# define Py_LIMITED_API 0x030c0000
#endif
#include <Python.h>
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 8353941..893f4cc 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -66,8 +66,9 @@ from libclinic import ClinicError
#
-# match '#define Py_LIMITED_API'
-LIMITED_CAPI_REGEX = re.compile(r'#define +Py_LIMITED_API')
+# Match '#define Py_LIMITED_API'.
+# Match '# define Py_LIMITED_API 0x030d0000' (without the version).
+LIMITED_CAPI_REGEX = re.compile(r'# *define +Py_LIMITED_API')
class Sentinels(enum.Enum):