From 83bfd34cf10938ab300a2725be80d556128dc66c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Fri, 28 Feb 2025 10:09:27 +0100 Subject: [PATCH] Postpone inclusion after Python.h (#130641) Remove inclusions prior to Python.h. will cause to be included before Python.h can define some macros to enable some additional features, causing multiple types not to be defined down the line. (cherry picked from commit 830f04b5056db92ba96387db0a778dcd19a39522) --- Objects/codeobject.c | 4 ++-- Python/assemble.c | 3 +-- Python/compile.c | 4 ++-- Python/pythonrun.c | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 6c4eef8e0116a3..5f491fe554273d 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -1,5 +1,3 @@ -#include - #include "Python.h" #include "opcode.h" @@ -16,6 +14,8 @@ #include "pycore_tuple.h" // _PyTuple_ITEMS() #include "clinic/codeobject.c.h" +#include + static const char * code_event_name(PyCodeEvent event) { switch (event) { diff --git a/Python/assemble.c b/Python/assemble.c index 945c8ac39f53ac..671bc7caf17ba3 100644 --- a/Python/assemble.c +++ b/Python/assemble.c @@ -1,5 +1,3 @@ -#include - #include "Python.h" #include "pycore_code.h" // write_location_entry_start() #include "pycore_compile.h" @@ -8,6 +6,7 @@ #include "pycore_opcode_metadata.h" // is_pseudo_target, _PyOpcode_Caches #include "pycore_symtable.h" // _Py_SourceLocation +#include #define DEFAULT_CODE_SIZE 128 #define DEFAULT_LNOTAB_SIZE 16 diff --git a/Python/compile.c b/Python/compile.c index c3cffd3920a028..ba780927eff9d6 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -21,8 +21,6 @@ * objects. */ -#include - #include "Python.h" #include "opcode.h" #include "pycore_ast.h" // _PyAST_GetDocString() @@ -57,6 +55,8 @@ */ #define STACK_USE_GUIDELINE 30 +#include + #undef SUCCESS #undef ERROR #define SUCCESS 0 diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 2092f3adf0c9ec..eea638354fe8f3 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -8,8 +8,6 @@ /* TODO: Cull includes following phase split */ -#include - #include "Python.h" #include "pycore_ast.h" // PyAST_mod2obj() @@ -28,6 +26,8 @@ #include "errcode.h" // E_EOF #include "marshal.h" // PyMarshal_ReadLongFromFile() +#include + #ifdef MS_WINDOWS # include "malloc.h" // alloca() #endif