Skip to content

Commit

Permalink
pythongh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX
Browse files Browse the repository at this point in the history
Accept spaces in "#  define Py_LIMITED_API 0x030d0000".
  • Loading branch information
vstinner committed Mar 11, 2024
1 parent 3c0dcef commit 384b344
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 36 deletions.
5 changes: 2 additions & 3 deletions Modules/_ctypes/_ctypes_test.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 2 additions & 3 deletions Modules/_multiprocessing/posixshmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 2 additions & 3 deletions Modules/_scproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 2 additions & 3 deletions Modules/_stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions Modules/_testclinic_limited.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 1 addition & 2 deletions Modules/_testimportmultiple.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 2 additions & 3 deletions Modules/_uuidmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions Modules/errnomodule.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 2 additions & 3 deletions Modules/resource.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 2 additions & 3 deletions Modules/xxlimited.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions Modules/xxlimited_35.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions PC/winsound.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 3 additions & 2 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 384b344

Please sign in to comment.