]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610)
authorVictor Stinner <vstinner@python.org>
Mon, 11 Mar 2024 22:42:18 +0000 (23:42 +0100)
committerGitHub <noreply@github.com>
Mon, 11 Mar 2024 22:42:18 +0000 (22:42 +0000)
Accept spaces in "#  define Py_LIMITED_API 0x030d0000".

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

index ecc60417790417ced0db8275b5aeff1f51f8596b..1dd3ef1905247010b5f7540b2fd7775eebbd5e74 100644 (file)
@@ -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
index 4ab15fa65736652b51e311a972923d2280420a40..d332a4e9d9ea0b8ff0b143e4fe2b9a69bd72989f 100644 (file)
@@ -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>
index fe82e918677f9a386ee1bdc127a63ff63bc7ba92..042738b4ab83a2eca15f58ea39394cb132aad871 100644 (file)
@@ -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>
index b43e79453f5b2fd6d144ed3caf648ce52cd914c4..8059ec2f1f066db21185119452f5e2b16640d273 100644 (file)
  *
  */
 
+// 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"
index df08ff9a369b1f94e93b6db85e4e0d68754de869..1a73c04aecb8aff5c72a5e020753e04e09fe6008 100644 (file)
@@ -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 */
index 7e6556ad400cdeccd249b560e740710bfb3154e3..a65ca513a12516cb9113c2fd4a5b55b957c26cde 100644 (file)
@@ -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>
index 4b6852c0d0ec73d432f843d796b754b92c4d3e48..052cb9fef3b21c07daf26d7d75d5b42021a8f08a 100644 (file)
@@ -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"
index 1100e9f6094352bee6434afdaac023224099b92d..97e5f0180d76fb1eb2d9adb7fe80b72ec299ca93 100644 (file)
@@ -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"
index 19020b8cc1b6db2fba1960a7fd763bfac1ac5c71..8ee07bd0c8054c1f05bfc1a46ab14cc829641498 100644 (file)
@@ -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"
index 0bb5e12d7c3dd985c5c85719c34316f0f664d144..3357b8076b67b11666b376719d9beed6bfbcab36 100644 (file)
           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"
index 754a368f77e940132f87f0ba1c64c1f1d4eadbeb..52690d9d10a81f800708956450ce36df7132c005 100644 (file)
@@ -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"
index 7e4ebd90f50c2e404f3e8d6d1fe6697a52fa0658..a6b2dac6ac1466989b36224688d729b93f9b0be1 100644 (file)
    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>
index 8353941f929eb1b3c63d56512e05b35ae7045d73..893f4cc12ed084edd4ddf6ee17a677c056ac0972 100755 (executable)
@@ -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):