https://github.com/python/cpython/commit/2b67fc57f6e97c8389fe970ed232c1ad484113e1
commit: 2b67fc57f6e97c8389fe970ed232c1ad484113e1
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2024-03-11T22:42:18Z
summary:

gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610)

Accept spaces in "#  define Py_LIMITED_API 0x030d0000".

files:
M Modules/_ctypes/_ctypes_test.c
M Modules/_multiprocessing/posixshmem.c
M Modules/_scproxy.c
M Modules/_stat.c
M Modules/_testclinic_limited.c
M Modules/_testimportmultiple.c
M Modules/_uuidmodule.c
M Modules/errnomodule.c
M Modules/resource.c
M Modules/xxlimited.c
M Modules/xxlimited_35.c
M PC/winsound.c
M Tools/clinic/clinic.py

diff --git a/Modules/_ctypes/_ctypes_test.c b/Modules/_ctypes/_ctypes_test.c
index ecc60417790417..1dd3ef19052470 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 4ab15fa6573665..d332a4e9d9ea0b 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 fe82e918677f9a..042738b4ab83a2 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 b43e79453f5b2f..8059ec2f1f066d 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 df08ff9a369b1f..1a73c04aecb8af 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 7e6556ad400cde..a65ca513a12516 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 4b6852c0d0ec73..052cb9fef3b21c 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 1100e9f6094352..97e5f0180d76fb 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 19020b8cc1b6db..8ee07bd0c8054c 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 0bb5e12d7c3dd9..3357b8076b67b1 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 754a368f77e940..52690d9d10a81f 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 7e4ebd90f50c2e..a6b2dac6ac1466 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 8353941f929eb1..893f4cc12ed084 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -66,8 +66,9 @@
 #
 
 
-# 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):

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to