]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738) (#130756)
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>
Mon, 3 Mar 2025 12:09:59 +0000 (13:09 +0100)
committerGitHub <noreply@github.com>
Mon, 3 Mar 2025 12:09:59 +0000 (13:09 +0100)
gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738)

Move some `#include <stdbool.h>` 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` (this caused some
build failures when compiling CPython with `zig cc`).

(cherry-picked from commit 214562ed4ddc248b007f718ed92ebcc0c3669611)

---------

Co-authored-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
Misc/NEWS.d/next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst [new file with mode: 0644]
Modules/_blake2/blake2b_impl.c
Modules/_blake2/blake2s_impl.c
Modules/_hashopenssl.c
Parser/string_parser.c
Python/flowgraph.c
Python/instruction_sequence.c

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 (file)
index 0000000..61d416c
--- /dev/null
@@ -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.
index 0c3ae5a2fac2751af822ad60ff03fb30d9da1944..370d01d55790b5053fc94c8dc5a25a89fe37bfe4 100644 (file)
 #  define Py_BUILD_CORE_MODULE 1
 #endif
 
-#include <stdbool.h>
 #include "Python.h"
 #include "pycore_strhex.h"       // _Py_strhex()
 
+#include <stdbool.h>
+
 #include "../hashlib.h"
 #include "blake2module.h"
 
index 3014773ab5233156c10dd66b8f0738181b38bf66..0935866092c882e22428a88d7f054d9ad39c84f1 100644 (file)
 #  define Py_BUILD_CORE_MODULE 1
 #endif
 
-#include <stdbool.h>
 #include "Python.h"
 #include "pycore_strhex.h"       // _Py_strhex()
 
+#include <stdbool.h>
+
 #include "../hashlib.h"
 #include "blake2module.h"
 
index fef0ed4a0b884427cda95ad5498065dbdda09e48..7e54e6f4d0290c117e6641de0f689a15ee6fb445 100644 (file)
@@ -22,7 +22,6 @@
 #  define Py_BUILD_CORE_MODULE 1
 #endif
 
-#include <stdbool.h>
 #include "Python.h"
 #include "pycore_hashtable.h"
 #include "pycore_pyhash.h"               // _Py_HashBytes()
@@ -38,6 +37,7 @@
 #include <openssl/objects.h>
 #include <openssl/err.h>
 
+#include <stdbool.h>
 
 #ifndef OPENSSL_THREADS
 #  error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL"
index e92984935430ce8b5cd22a5aa7d2bc022fb6af1c..ce96b6e7b44f50408bc79ae2a3e4d989d8d1b990 100644 (file)
@@ -1,5 +1,3 @@
-#include <stdbool.h>
-
 #include <Python.h>
 #include "pycore_bytesobject.h"   // _PyBytes_DecodeEscape()
 #include "pycore_unicodeobject.h" // _PyUnicode_DecodeUnicodeEscapeInternal()
@@ -8,6 +6,8 @@
 #include "pegen.h"
 #include "string_parser.h"
 
+#include <stdbool.h>
+
 //// STRING HANDLING FUNCTIONS ////
 
 static int
index ff70e47370241a0ad8bac1c3ded07325d4ba6a61..ecf510842ea7483d1779be377e784fcde8932b9a 100644 (file)
@@ -1,6 +1,3 @@
-
-#include <stdbool.h>
-
 #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 <stdbool.h>
+
 
 #undef SUCCESS
 #undef ERROR
index a3f85f754d71bb5b6962e6eadbf8bbb44c11aee6..e713ebb9b8734e34d8f69c91c86528e6fa8e4c91 100644 (file)
@@ -5,8 +5,6 @@
  */
 
 
-#include <stdbool.h>
-
 #include "Python.h"
 
 #include "pycore_compile.h" // _PyCompile_EnsureArrayLargeEnough
@@ -22,6 +20,8 @@ typedef _Py_SourceLocation location;
 
 #include "clinic/instruction_sequence.c.h"
 
+#include <stdbool.h>
+
 #undef SUCCESS
 #undef ERROR
 #define SUCCESS 0