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 commit is contained in:
Hugo Beauzée-Luyssen 2025-03-02 10:56:49 +01:00 committed by GitHub
parent 051f0e5683
commit 214562ed4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 13 additions and 12 deletions

View file

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

View 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"

View 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

View 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

View 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

View 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

View 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