From 3c89fc3c81cf3a054161b3e746ed7f371e745d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Sat, 1 Mar 2025 18:31:27 +0100 Subject: [PATCH 1/7] ensure Python.h is included first in most circumstances Except when "pyconfig.h" is included first, and for platform specific code such as android/emscripten --- Modules/_hashopenssl.c | 2 +- Parser/string_parser.c | 4 ++-- Python/codegen.c | 4 ++-- Python/flowgraph.c | 5 ++--- Python/index_pool.c | 4 ++-- Python/instruction_sequence.c | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) 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 #include "Python.h" #include "pycore_hashtable.h" #include "pycore_strhex.h" // _Py_strhex() @@ -37,6 +36,7 @@ #include #include +#include #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 - #include #include "pycore_bytesobject.h" // _PyBytes_DecodeEscape() #include "pycore_unicodeobject.h" // _PyUnicode_DecodeUnicodeEscapeInternal() @@ -8,6 +6,8 @@ #include "pegen.h" #include "string_parser.h" +#include + //// 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 - #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 + #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 - #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 + #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 - #include "Python.h" #include "pycore_index_pool.h" #include "pycore_lock.h" +#include + #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 - #include "Python.h" #include "pycore_compile.h" // _PyCompile_EnsureArrayLargeEnough @@ -22,6 +20,8 @@ typedef _Py_SourceLocation location; #include "clinic/instruction_sequence.c.h" +#include + #undef SUCCESS #undef ERROR #define SUCCESS 0 From 6cda19de45484cd469b9ea08594aafda8d276c56 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 1 Mar 2025 18:20:07 +0000 Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst diff --git a/Misc/NEWS.d/next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst b/Misc/NEWS.d/next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst new file mode 100644 index 00000000000000..6f12e9f1650da1 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst @@ -0,0 +1 @@ +Ensure Python.h is included in most places, except when "pyconfig.h" is included before, or in platform specific contexts From eb2f0dacadf0b2a9a98741273c05c912b6e2b2a5 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 1 Mar 2025 18:27:43 +0000 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst 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..6f12e9f1650da1 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst @@ -0,0 +1 @@ +Ensure Python.h is included in most places, except when "pyconfig.h" is included before, or in platform specific contexts From a3a7ea37c3f238a9848df9dc71ca5a09a39b8ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Sat, 1 Mar 2025 19:28:17 +0100 Subject: [PATCH 4/7] Update Misc/NEWS.d/next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- .../next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst b/Misc/NEWS.d/next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst index 6f12e9f1650da1..6a84cf62a6d55d 100644 --- a/Misc/NEWS.d/next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst +++ b/Misc/NEWS.d/next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst @@ -1 +1,2 @@ -Ensure Python.h is included in most places, except when "pyconfig.h" is included before, or in platform specific contexts +Ensure that `Python.h` is included before `stdbool.h` unless `pyconfig.h` is included +or in some platform-specific contexts. From ac46e98a0e4eece8da0840ea1dd57ce563656c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Sat, 1 Mar 2025 19:31:48 +0100 Subject: [PATCH 5/7] update changelog --- .../next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst | 2 -- .../next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 Misc/NEWS.d/next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst diff --git a/Misc/NEWS.d/next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst b/Misc/NEWS.d/next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst deleted file mode 100644 index 6a84cf62a6d55d..00000000000000 --- a/Misc/NEWS.d/next/Build/2025-03-01-18-20-07.gh-issue-130738.nDFSHR.rst +++ /dev/null @@ -1,2 +0,0 @@ -Ensure that `Python.h` is included before `stdbool.h` unless `pyconfig.h` is included -or in some platform-specific contexts. 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 index 6f12e9f1650da1..6a84cf62a6d55d 100644 --- 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 @@ -1 +1,2 @@ -Ensure Python.h is included in most places, except when "pyconfig.h" is included before, or in platform specific contexts +Ensure that `Python.h` is included before `stdbool.h` unless `pyconfig.h` is included +or in some platform-specific contexts. From 6a6e5b1613ce858e37af55bfd92a642db95efdfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Sat, 1 Mar 2025 19:35:47 +0100 Subject: [PATCH 6/7] fix backticks --- .../next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 6a84cf62a6d55d..7c90286a19d0f9 100644 --- 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 @@ -1,2 +1,2 @@ -Ensure that `Python.h` is included before `stdbool.h` unless `pyconfig.h` is included +Ensure that ``Python.h`` is included before ``stdbool.h`` unless ``pyconfig.h`` is included or in some platform-specific contexts. From 88bd3cc48ed0dc563574dbd8dbdbf4742c887e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 2 Mar 2025 10:33:39 +0100 Subject: [PATCH 7/7] Update Misc/NEWS.d/next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst --- .../next/Build/2025-03-01-18-27-42.gh-issue-130740.nDFSHR.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index 7c90286a19d0f9..61d416c69f0c30 100644 --- 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 @@ -1,2 +1,2 @@ -Ensure that ``Python.h`` is included before ``stdbool.h`` unless ``pyconfig.h`` is included -or in some platform-specific contexts. +Ensure that ``Python.h`` is included before ``stdbool.h`` unless ``pyconfig.h`` +is included before or in some platform-specific contexts.