Skip to content

Commit 7a8d6ab

Browse files
committed
Fix pegen build and suppress MSVC warning in our headers
1 parent 142b60a commit 7a8d6ab

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Include/Python.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@
5959
# include <intrin.h> // __readgsqword()
6060
#endif
6161

62+
// Suppress known warnings in Python header files.
63+
#if defined(_MSC_VER)
64+
// Warning that alignas behaviour has changed. Doesn't affect us, because we
65+
// never relied on the old behaviour.
66+
#pragma warning(push)
67+
#pragma warning(disable: 5274)
68+
#endif
69+
6270
// Include Python header files
6371
#include "pyport.h"
6472
#include "pymacro.h"
@@ -138,4 +146,9 @@
138146
#include "cpython/pyfpe.h"
139147
#include "cpython/tracemalloc.h"
140148

149+
// Restore warning filter
150+
#ifdef _MSC_VER
151+
#pragma warning(pop)
152+
#endif
153+
141154
#endif /* !Py_PYTHON_H */

Tools/peg_generator/pegen/build.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ def compile_c_extension(
108108
extra_compile_args.append("-DPy_BUILD_CORE_MODULE")
109109
# Define _Py_TEST_PEGEN to not call PyAST_Validate() in Parser/pegen.c
110110
extra_compile_args.append("-D_Py_TEST_PEGEN")
111+
if sys.platform == "win32" and sysconfig.get_config_var("Py_GIL_DISABLED"):
112+
extra_compile_args.append("-DPy_GIL_DISABLED")
111113
extra_link_args = get_extra_flags("LDFLAGS", "PY_LDFLAGS_NODIST")
112114
if keep_asserts:
113115
extra_compile_args.append("-UNDEBUG")

0 commit comments

Comments
 (0)