]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738)
authorHugo Beauzée-Luyssen <hugo@beauzee.fr>
Sun, 2 Mar 2025 09:56:49 +0000 (10:56 +0100)
committerGitHub <noreply@github.com>
Sun, 2 Mar 2025 09:56:49 +0000 (09:56 +0000)
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`.

Misc/NEWS.d/next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst [new file with mode: 0644]
Modules/_hashopenssl.c
Parser/string_parser.c
Python/codegen.c
Python/flowgraph.c
Python/index_pool.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 3f1deb81c6375f69877d3eeaad097c8299a25a02..f66b182b1deb6aa334a4ea6ba16bf711d930f8ba 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_strhex.h"               // _Py_strhex()
@@ -37,6 +36,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 b93300b00a8545bbb785bd2a7393e887db57a73e..9b557e94d004312169aca81e4ad59ec888e535e7 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 ecad8c22bdf51e3023a56f10e7bc80477d10901d..8f1a2983007ce490f94232155565b79929deb3c6 100644 (file)
@@ -12,8 +12,6 @@
  * objects.
  */
 
-#include <stdbool.h>
-
 #include "Python.h"
 #include "opcode.h"
 #include "pycore_ast.h"           // _PyAST_GetDocString()
@@ -32,6 +30,8 @@
 #include "pycore_opcode_metadata.h" // _PyOpcode_opcode_metadata, _PyOpcode_num_popped/pushed
 #undef NEED_OPCODE_METADATA
 
+#include <stdbool.h>
+
 #define COMP_GENEXP   0
 #define COMP_LISTCOMP 1
 #define COMP_SETCOMP  2
index c5bdf105545459c360aede938b489cbf664f972c..fb3c73a059a5890815447a4a44d2a38fc6743f8f 100644 (file)
@@ -1,6 +1,3 @@
-
-#include <stdbool.h>
-
 #include "Python.h"
 #include "opcode.h"
 #include "pycore_flowgraph.h"
@@ -12,6 +9,8 @@
 #include "pycore_opcode_utils.h"
 #include "pycore_opcode_metadata.h" // OPCODE_HAS_ARG, etc
 
+#include <stdbool.h>
+
 
 #undef SUCCESS
 #undef ERROR
index 526eccff74af00e56a213cdc83ae244764815efc..007c81a0fc16ec30d32bc94e2ff5ff3b7fd77a08 100644 (file)
@@ -1,10 +1,10 @@
-#include <stdbool.h>
-
 #include "Python.h"
 
 #include "pycore_index_pool.h"
 #include "pycore_lock.h"
 
+#include <stdbool.h>
+
 #ifdef Py_GIL_DISABLED
 
 static inline void
index e2607e98095ed25a1fe4aece10eb207fe06b1309..ed40c06715f1f325121b3f0a14f9365bb5c7bd76 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