Skip to content

Commit 214562e

Browse files
authored
pythongh-130740: Move some stdbool.h includes after Python.h (python#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`.
1 parent 051f0e5 commit 214562e

7 files changed

+13
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Ensure that ``Python.h`` is included before ``stdbool.h`` unless ``pyconfig.h``
2+
is included before or in some platform-specific contexts.

Modules/_hashopenssl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
# define Py_BUILD_CORE_MODULE 1
2323
#endif
2424

25-
#include <stdbool.h>
2625
#include "Python.h"
2726
#include "pycore_hashtable.h"
2827
#include "pycore_strhex.h" // _Py_strhex()
@@ -37,6 +36,7 @@
3736
#include <openssl/objects.h>
3837
#include <openssl/err.h>
3938

39+
#include <stdbool.h>
4040

4141
#ifndef OPENSSL_THREADS
4242
# error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL"

Parser/string_parser.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include <stdbool.h>
2-
31
#include <Python.h>
42
#include "pycore_bytesobject.h" // _PyBytes_DecodeEscape()
53
#include "pycore_unicodeobject.h" // _PyUnicode_DecodeUnicodeEscapeInternal()
@@ -8,6 +6,8 @@
86
#include "pegen.h"
97
#include "string_parser.h"
108

9+
#include <stdbool.h>
10+
1111
//// STRING HANDLING FUNCTIONS ////
1212

1313
static int

Python/codegen.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
* objects.
1313
*/
1414

15-
#include <stdbool.h>
16-
1715
#include "Python.h"
1816
#include "opcode.h"
1917
#include "pycore_ast.h" // _PyAST_GetDocString()
@@ -32,6 +30,8 @@
3230
#include "pycore_opcode_metadata.h" // _PyOpcode_opcode_metadata, _PyOpcode_num_popped/pushed
3331
#undef NEED_OPCODE_METADATA
3432

33+
#include <stdbool.h>
34+
3535
#define COMP_GENEXP 0
3636
#define COMP_LISTCOMP 1
3737
#define COMP_SETCOMP 2

Python/flowgraph.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
#include <stdbool.h>
3-
41
#include "Python.h"
52
#include "opcode.h"
63
#include "pycore_flowgraph.h"
@@ -12,6 +9,8 @@
129
#include "pycore_opcode_utils.h"
1310
#include "pycore_opcode_metadata.h" // OPCODE_HAS_ARG, etc
1411

12+
#include <stdbool.h>
13+
1514

1615
#undef SUCCESS
1716
#undef ERROR

Python/index_pool.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#include <stdbool.h>
2-
31
#include "Python.h"
42

53
#include "pycore_index_pool.h"
64
#include "pycore_lock.h"
75

6+
#include <stdbool.h>
7+
88
#ifdef Py_GIL_DISABLED
99

1010
static inline void

Python/instruction_sequence.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66

77

8-
#include <stdbool.h>
9-
108
#include "Python.h"
119

1210
#include "pycore_compile.h" // _PyCompile_EnsureArrayLargeEnough
@@ -22,6 +20,8 @@ typedef _Py_SourceLocation location;
2220

2321
#include "clinic/instruction_sequence.c.h"
2422

23+
#include <stdbool.h>
24+
2525
#undef SUCCESS
2626
#undef ERROR
2727
#define SUCCESS 0

0 commit comments

Comments
 (0)