https://github.com/python/cpython/commit/214562ed4ddc248b007f718ed92ebcc0c3669611
commit: 214562ed4ddc248b007f718ed92ebcc0c3669611
branch: main
author: Hugo Beauzée-Luyssen <h...@beauzee.fr>
committer: picnixz <10796600+picn...@users.noreply.github.com>
date: 2025-03-02T09:56:49Z
summary:

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`.

files:
A Misc/NEWS.d/next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst
M Modules/_hashopenssl.c
M Parser/string_parser.c
M Python/codegen.c
M Python/flowgraph.c
M Python/index_pool.c
M 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
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 3f1deb81c6375f..f66b182b1deb6a 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -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"
diff --git a/Parser/string_parser.c b/Parser/string_parser.c
index b93300b00a8545..9b557e94d00431 100644
--- a/Parser/string_parser.c
+++ b/Parser/string_parser.c
@@ -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
diff --git a/Python/codegen.c b/Python/codegen.c
index ecad8c22bdf51e..8f1a2983007ce4 100644
--- a/Python/codegen.c
+++ b/Python/codegen.c
@@ -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
diff --git a/Python/flowgraph.c b/Python/flowgraph.c
index c5bdf105545459..fb3c73a059a589 100644
--- a/Python/flowgraph.c
+++ b/Python/flowgraph.c
@@ -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
diff --git a/Python/index_pool.c b/Python/index_pool.c
index 526eccff74af00..007c81a0fc16ec 100644
--- a/Python/index_pool.c
+++ b/Python/index_pool.c
@@ -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
diff --git a/Python/instruction_sequence.c b/Python/instruction_sequence.c
index e2607e98095ed2..ed40c06715f1f3 100644
--- a/Python/instruction_sequence.c
+++ b/Python/instruction_sequence.c
@@ -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

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to