From 49276f286e6444b0e3c16f34e9ca90dada436948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Sun, 2 Mar 2025 10:56:49 +0100 Subject: [PATCH 1/2] gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738) Move some `#include ` after `#include "Python.h"` when `pyconfig.h` is not included first and when we are in a platform-agnostic context. This is to avoid having features defined by `stdbool.h` before those decided by `Python.h`. --- .../Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst | 2 ++ Modules/_hashopenssl.c | 2 +- Parser/string_parser.c | 4 ++-- Python/flowgraph.c | 5 ++--- Python/instruction_sequence.c | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst diff --git a/Misc/NEWS.d/next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst b/Misc/NEWS.d/next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst new file mode 100644 index 00000000000000..61d416c69f0c30 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst @@ -0,0 +1,2 @@ +Ensure that ``Python.h`` is included before ``stdbool.h`` unless ``pyconfig.h`` +is included before or in some platform-specific contexts. diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index 2f7d277e07bac0..71a7eabe1b0d52 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -22,7 +22,6 @@ # define Py_BUILD_CORE_MODULE 1 #endif -#include #include "Python.h" #include "pycore_hashtable.h" #include "pycore_pyhash.h" // _Py_HashBytes() @@ -38,6 +37,7 @@ #include #include +#include #ifndef OPENSSL_THREADS # error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL" diff --git a/Parser/string_parser.c b/Parser/string_parser.c index e92984935430ce..ce96b6e7b44f50 100644 --- a/Parser/string_parser.c +++ b/Parser/string_parser.c @@ -1,5 +1,3 @@ -#include - #include #include "pycore_bytesobject.h" // _PyBytes_DecodeEscape() #include "pycore_unicodeobject.h" // _PyUnicode_DecodeUnicodeEscapeInternal() @@ -8,6 +6,8 @@ #include "pegen.h" #include "string_parser.h" +#include + //// STRING HANDLING FUNCTIONS //// static int diff --git a/Python/flowgraph.c b/Python/flowgraph.c index ff70e47370241a..ecf510842ea748 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -1,6 +1,3 @@ - -#include - #include "Python.h" #include "pycore_flowgraph.h" #include "pycore_compile.h" @@ -9,6 +6,8 @@ #include "pycore_opcode_utils.h" #include "pycore_opcode_metadata.h" // OPCODE_HAS_ARG, etc +#include + #undef SUCCESS #undef ERROR diff --git a/Python/instruction_sequence.c b/Python/instruction_sequence.c index a3f85f754d71bb..e713ebb9b8734e 100644 --- a/Python/instruction_sequence.c +++ b/Python/instruction_sequence.c @@ -5,8 +5,6 @@ */ -#include - #include "Python.h" #include "pycore_compile.h" // _PyCompile_EnsureArrayLargeEnough @@ -22,6 +20,8 @@ typedef _Py_SourceLocation location; #include "clinic/instruction_sequence.c.h" +#include + #undef SUCCESS #undef ERROR #define SUCCESS 0 From 4f58ff676350b953162c199742b42744d72aa2a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 2 Mar 2025 11:10:16 +0100 Subject: [PATCH 2/2] backport --- Modules/_blake2/blake2b_impl.c | 3 ++- Modules/_blake2/blake2s_impl.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Modules/_blake2/blake2b_impl.c b/Modules/_blake2/blake2b_impl.c index 0c3ae5a2fac275..370d01d55790b5 100644 --- a/Modules/_blake2/blake2b_impl.c +++ b/Modules/_blake2/blake2b_impl.c @@ -17,10 +17,11 @@ # define Py_BUILD_CORE_MODULE 1 #endif -#include #include "Python.h" #include "pycore_strhex.h" // _Py_strhex() +#include + #include "../hashlib.h" #include "blake2module.h" diff --git a/Modules/_blake2/blake2s_impl.c b/Modules/_blake2/blake2s_impl.c index 3014773ab52331..0935866092c882 100644 --- a/Modules/_blake2/blake2s_impl.c +++ b/Modules/_blake2/blake2s_impl.c @@ -17,10 +17,11 @@ # define Py_BUILD_CORE_MODULE 1 #endif -#include #include "Python.h" #include "pycore_strhex.h" // _Py_strhex() +#include + #include "../hashlib.h" #include "blake2module.h"