]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-131238: Add explicit includes to pycore headers (#131257)
authorVictor Stinner <vstinner@python.org>
Mon, 17 Mar 2025 11:32:43 +0000 (12:32 +0100)
committerGitHub <noreply@github.com>
Mon, 17 Mar 2025 11:32:43 +0000 (12:32 +0100)
23 files changed:
Modules/_io/_iomodule.c
Modules/_operator.c
Modules/_posixsubprocess.c
Modules/_zoneinfo.c
Modules/faulthandler.c
Objects/fileobject.c
Parser/action_helpers.c
Parser/asdl_c.py
Parser/tokenizer/file_tokenizer.c
Python/Python-ast.c
Python/ast.c
Python/ast_opt.c
Python/codecs.c
Python/compile.c
Python/dtoa.c
Python/errors.c
Python/importdl.c
Python/marshal.c
Python/perf_jit_trampoline.c
Python/perf_trampoline.c
Python/qsbr.c
Python/symtable.c
Python/thread.c

index 015e9e36cada4369b439553c66eedc11856806f1..bd4d994454dfcd00f697262ab4f81682c19f5cd9 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "Python.h"
 #include "pycore_abstract.h"      // _PyNumber_Index()
-#include "pycore_initconfig.h"    // _PyStatus_OK()
+#include "pycore_interp.h"        // _PyInterpreterState_GetConfig()
 #include "pycore_long.h"          // _PyLong_IsNegative()
 #include "pycore_pyerrors.h"      // _PyErr_ChainExceptions1()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
index c287ea2780c528f74195c97e80f8f4e79eca7299..1cc05c39f5dbad13280014a070445884d27e4781 100644 (file)
@@ -1,8 +1,10 @@
 #include "Python.h"
 #include "pycore_modsupport.h"    // _PyArg_NoKwnames()
 #include "pycore_moduleobject.h"  // _PyModule_GetState()
-#include "pycore_runtime.h"       // _Py_ID()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
+#include "pycore_tuple.h"         // _PyTuple_ITEMS()
+#include "pycore_typeobject.h"    // _PyType_GetModuleState()
+#include "pycore_unicodeobject.h" // _PyUnicode_InternMortal()
 
 
 #include "clinic/_operator.c.h"
index ad6d7ceda84e37733be95a938460eeca0251b7cf..8f4b57017635f8f5cceca4292529e36a3cda3483 100644 (file)
@@ -4,9 +4,10 @@
 #endif
 
 #include "Python.h"
-#include "pycore_fileutils.h"
-#include "pycore_pystate.h"
+#include "pycore_interp.h"        // _PyInterpreterState_GetFinalizing()
+#include "pycore_pystate.h"       // _PyInterpreterState_GET()
 #include "pycore_signal.h"        // _Py_RestoreSignals()
+
 #if defined(HAVE_PIPE2) && !defined(_GNU_SOURCE)
 #  define _GNU_SOURCE
 #endif
index 8c882bef24867ecd75ef5b7d63376676766d92d3..7e761b287792e159b72685b51cadfffa79fd31a8 100644 (file)
@@ -6,11 +6,13 @@
 #include "pycore_critical_section.h"  // _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED()
 #include "pycore_long.h"          // _PyLong_GetOne()
 #include "pycore_pyerrors.h"      // _PyErr_ChainExceptions1()
+#include "pycore_typeobject.h"    // _PyType_GetModuleState()
 
 #include "datetime.h"             // PyDateTime_TZInfo
 
 #include <stddef.h>               // offsetof()
-#include <stdint.h>
+#include <stdint.h>               // int64_t
+
 
 #include "clinic/_zoneinfo.c.h"
 /*[clinic input]
index fac10190d314daffc9ad5723451a02d02684cf84..910de4d34454f8aca2d10fbaf25b938ff48e8d60 100644 (file)
@@ -1,8 +1,9 @@
 #include "Python.h"
-#include "pycore_ceval.h"         // _PyEval_IsGILEnabled
-#include "pycore_initconfig.h"    // _PyStatus_ERR
-#include "pycore_pyerrors.h"      // _Py_DumpExtensionModules
+#include "pycore_ceval.h"         // _PyEval_IsGILEnabled()
+#include "pycore_initconfig.h"    // _PyStatus_ERR()
+#include "pycore_pyerrors.h"      // _Py_DumpExtensionModules()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
+#include "pycore_runtime.h"       // _Py_ID()
 #include "pycore_signal.h"        // Py_NSIG
 #include "pycore_sysmodule.h"     // _PySys_GetRequiredAttr()
 #include "pycore_time.h"          // _PyTime_FromSecondsObject()
@@ -28,6 +29,7 @@
 #  include <sys/auxv.h>           // getauxval()
 #endif
 
+
 /* Sentinel to ignore all_threads on free-threading */
 #define FT_IGNORE_ALL_THREADS 2
 
index c9a20ccd75324aa6549829140c25e6e8f8349d72..4898e046ff79a6874eff35cf8df70442852959ac 100644 (file)
@@ -3,11 +3,13 @@
 #include "Python.h"
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
 #include "pycore_runtime.h"       // _PyRuntime
+#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8String()
 
 #ifdef HAVE_UNISTD_H
 #  include <unistd.h>             // isatty()
 #endif
 
+
 #if defined(HAVE_GETC_UNLOCKED) && !defined(_Py_MEMORY_SANITIZER)
    /* clang MemorySanitizer doesn't yet understand getc_unlocked. */
 #  define GETC(f) getc_unlocked(f)
index 52d63401a6e6b591cd55475e641ccddf8d32838f..88f478af8b2d2d9beff929c3526d56fff3e77af4 100644 (file)
@@ -1,9 +1,12 @@
 #include <Python.h>
 
 #include "pegen.h"
-#include "string_parser.h"
-#include "pycore_runtime.h"         // _PyRuntime
+#include "string_parser.h"          // _PyPegen_decode_string()
+
 #include "pycore_pystate.h"         // _PyInterpreterState_GET()
+#include "pycore_runtime.h"         // _PyRuntime
+#include "pycore_unicodeobject.h"   // _PyUnicode_InternImmortal()
+
 
 void *
 _PyPegen_dummy_name(Parser *p, ...)
index 5c8014a47d5177e181f5d1fdfb4aaa76251f325c..82d84ac5bde381ec210f2606ad8cbb58f121ad6a 100755 (executable)
@@ -2273,15 +2273,16 @@ def generate_module_def(mod, metadata, f, internal_h):
         #include "Python.h"
         #include "pycore_ast.h"
         #include "pycore_ast_state.h"     // struct ast_state
-        #include "pycore_ceval.h"         // _Py_EnterRecursiveCall
+        #include "pycore_ceval.h"         // _Py_EnterRecursiveCall()
         #include "pycore_lock.h"          // _PyOnceFlag
-        #include "pycore_interp.h"        // _PyInterpreterState.ast
         #include "pycore_modsupport.h"    // _PyArg_NoPositional()
         #include "pycore_pystate.h"       // _PyInterpreterState_GET()
-        #include "pycore_setobject.h"     // _PySet_NextEntry(), _PySet_Update()
+        #include "pycore_runtime.h"       // _Py_ID()
+        #include "pycore_setobject.h"     // _PySet_NextEntry()
         #include "pycore_unionobject.h"   // _Py_union_type_or
-        #include "structmember.h"
-        #include <stddef.h>
+
+        #include <stddef.h>               // offsetof()
+
 
         // Forward declaration
         static int init_types(void *arg);
index efe9fb9b56abaf48c1329967ac9c623cecd47507..15fc9348f8ae562bd33b95b8a9f8495feddf4708 100644 (file)
@@ -1,8 +1,9 @@
 #include "Python.h"
-#include "pycore_call.h"
-#include "pycore_import.h"
-#include "pycore_fileutils.h"
-#include "errcode.h"
+#include "pycore_call.h"          // _PyObject_CallNoArgs()
+#include "pycore_fileutils.h"     // _Py_UniversalNewlineFgetsWithSize()
+#include "pycore_runtime.h"       // _Py_ID()
+
+#include "errcode.h"              // E_NOMEM
 
 #ifdef HAVE_UNISTD_H
 #  include <unistd.h>             // lseek(), read()
@@ -13,6 +14,7 @@
 #include "../lexer/lexer.h"
 #include "../lexer/buffer.h"
 
+
 static int
 tok_concatenate_interactive_new_line(struct tok_state *tok, const char *line) {
     assert(tok->fp_interactive);
index 638e3f67e1cfdda4f64dfa85b7a5135dd981ce30..98dcdc4ed0be7062b79e6207094d5ad34b5869ad 100644 (file)
@@ -3,15 +3,16 @@
 #include "Python.h"
 #include "pycore_ast.h"
 #include "pycore_ast_state.h"     // struct ast_state
-#include "pycore_ceval.h"         // _Py_EnterRecursiveCall
+#include "pycore_ceval.h"         // _Py_EnterRecursiveCall()
 #include "pycore_lock.h"          // _PyOnceFlag
-#include "pycore_interp.h"        // _PyInterpreterState.ast
 #include "pycore_modsupport.h"    // _PyArg_NoPositional()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
-#include "pycore_setobject.h"     // _PySet_NextEntry(), _PySet_Update()
+#include "pycore_runtime.h"       // _Py_ID()
+#include "pycore_setobject.h"     // _PySet_NextEntry()
 #include "pycore_unionobject.h"   // _Py_union_type_or
-#include "structmember.h"
-#include <stddef.h>
+
+#include <stddef.h>               // offsetof()
+
 
 // Forward declaration
 static int init_types(void *arg);
index 597df5b63b5f394abff9aa75049a4754eb592748..7ee884357b41e84a56f60f8adeeb39dcd07119cd 100644 (file)
@@ -5,9 +5,10 @@
 #include "Python.h"
 #include "pycore_ast.h"           // asdl_stmt_seq
 #include "pycore_pystate.h"       // _PyThreadState_GET()
+#include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString()
+
+#include <stdbool.h>              // bool
 
-#include <assert.h>
-#include <stdbool.h>
 
 #define ENTER_RECURSIVE() \
 if (Py_EnterRecursiveCall(" during compilation")) { \
index 2c6e16817f2aad317d9734be5302746b9bdaf337..12414453c481d7b5d19446f0d5d8c39c1b4816c4 100644 (file)
@@ -2,9 +2,8 @@
 #include "Python.h"
 #include "pycore_ast.h"           // _PyAST_GetDocString()
 #include "pycore_format.h"        // F_LJUST
-#include "pycore_long.h"          // _PyLong
-#include "pycore_pystate.h"       // _PyThreadState_GET()
-#include "pycore_setobject.h"     // _PySet_NextEntry()
+#include "pycore_runtime.h"       // _Py_STR()
+#include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString()
 
 
 typedef struct {
index 2453929c8c789ac78d2c806bffd03aa46543a708..51f4beb84669c8143efd16a9ebc94c8a7d4804a9 100644 (file)
@@ -11,11 +11,12 @@ Copyright (c) Corporation for National Research Initiatives.
 #include "Python.h"
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
 #include "pycore_interp.h"        // PyInterpreterState.codec_search_path
-#include "pycore_lock.h"          // PyMutex
 #include "pycore_pyerrors.h"      // _PyErr_FormatNote()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
+#include "pycore_runtime.h"       // _Py_ID()
 #include "pycore_ucnhash.h"       // _PyUnicode_Name_CAPI
 
+
 static const char *codecs_builtin_error_handlers[] = {
     "strict", "ignore", "replace",
     "xmlcharrefreplace", "backslashreplace", "namereplace",
index cd68b897cf6188a420ee817b07f0f2939fd50a69..a52183ef5156e484906728d12090f8366790e9d7 100644 (file)
  */
 
 #include "Python.h"
-#include "pycore_ast.h"           // PyAST_Check, _PyAST_GetDocString()
+#include "pycore_ast.h"           // PyAST_Check()
+#include "pycore_code.h"          // _PyCode_GetFreevars()
 #include "pycore_compile.h"
-#include "pycore_flowgraph.h"
+#include "pycore_flowgraph.h"     // _PyCfg_FromInstructionSequence()
 #include "pycore_pystate.h"       // _Py_GetConfig()
+#include "pycore_runtime.h"       // _Py_ID()
 #include "pycore_setobject.h"     // _PySet_NextEntry()
+#include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString()
 
 #include "cpython/code.h"
 
 #include <stdbool.h>
 
+
 #undef SUCCESS
 #undef ERROR
 #define SUCCESS 0
index 61d776d9a20687f9d6a0c0d6fe8dd4e64ce7b7e8..3de150351a4ef8677f28282ad4e1d99330e5f505 100644 (file)
 
 #include "Python.h"
 #include "pycore_dtoa.h"          // _PY_SHORT_FLOAT_REPR
+#include "pycore_interp_structs.h"// struct Bigint
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
 #include <stdlib.h>               // exit()
 
index bf48c107e253a36597d828fada5b7a577ba61891..d2f331269ed0bc9cd679ba7ed4ae472fb945c372 100644 (file)
@@ -7,9 +7,11 @@
 #include "pycore_initconfig.h"    // _PyStatus_ERR()
 #include "pycore_pyerrors.h"      // _PyErr_Format()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
+#include "pycore_runtime.h"       // _Py_ID()
 #include "pycore_structseq.h"     // _PyStructSequence_FiniBuiltin()
 #include "pycore_sysmodule.h"     // _PySys_GetOptionalAttr()
 #include "pycore_traceback.h"     // _PyTraceBack_FromFrame()
+#include "pycore_unicodeobject.h" // _PyUnicode_Equal()
 
 #ifdef MS_WINDOWS
 #  include <windows.h>
@@ -17,6 +19,7 @@
 #  include <stdlib.h>             // _sys_nerr
 #endif
 
+
 /* Forward declarations */
 static PyObject *
 _PyErr_FormatV(PyThreadState *tstate, PyObject *exception,
index 996ca7ed2a3108c3fd42d898e15aba5c16de47e7..87c44891407db5ac79b9519626972c5d12542e86 100644 (file)
@@ -2,13 +2,13 @@
 /* Support for dynamic loading of extension modules */
 
 #include "Python.h"
-#include "pycore_call.h"
-#include "pycore_import.h"
+#include "pycore_call.h"          // _PyObject_CallMethod()
+#include "pycore_import.h"        // _PyImport_SwapPackageContext()
+#include "pycore_importdl.h"      // struct _Py_ext_module_loader_info
+#include "pycore_moduleobject.h"  // _PyModule_GetDef()
 #include "pycore_pyerrors.h"      // _PyErr_FormatFromCause()
-#include "pycore_pystate.h"
-#include "pycore_runtime.h"
+#include "pycore_runtime.h"       // _Py_ID()
 
-#include "pycore_importdl.h"
 
 /* ./configure sets HAVE_DYNAMIC_LOADING if dynamic loading of modules is
    supported on this platform. configure will then compile and link in one
index cf7011652513ae89835986a5d3b6632b8fcfbf4f..b39c1a5b1ade50e33673eaac0a7f5801fb880b33 100644 (file)
@@ -9,17 +9,19 @@
 #include "Python.h"
 #include "pycore_call.h"             // _PyObject_CallNoArgs()
 #include "pycore_code.h"             // _PyCode_New()
-#include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION()
 #include "pycore_hashtable.h"        // _Py_hashtable_t
-#include "pycore_long.h"             // _PyLong_DigitCount
-#include "pycore_setobject.h"        // _PySet_NextEntry()
-#include "marshal.h"                 // Py_MARSHAL_VERSION
+#include "pycore_long.h"             // _PyLong_IsZero()
 #include "pycore_pystate.h"          // _PyInterpreterState_GET()
+#include "pycore_setobject.h"        // _PySet_NextEntryRef()
+#include "pycore_unicodeobject.h"    // _PyUnicode_InternImmortal()
+
+#include "marshal.h"                 // Py_MARSHAL_VERSION
 
 #ifdef __APPLE__
 #  include "TargetConditionals.h"
 #endif /* __APPLE__ */
 
+
 /*[clinic input]
 module marshal
 [clinic start generated code]*/
index 0a8945958b4b3cbcdfd048e12d76f9c1e71a4172..1211e0e9f112b764cb0b9d56814bc22549ce9662 100644 (file)
@@ -2,6 +2,7 @@
 #include "pycore_ceval.h"         // _PyPerf_Callbacks
 #include "pycore_frame.h"
 #include "pycore_interp.h"
+#include "pycore_runtime.h"       // _PyRuntime
 
 
 #ifdef PY_HAVE_PERF_TRAMPOLINE
index ad077dc861b0a76fc6bed4adb79fff44473dc22c..a6a32b98fa9ef55b227968b827799563d732db0c 100644 (file)
@@ -133,6 +133,7 @@ any DWARF information available for them).
 #include "pycore_ceval.h"         // _PyPerf_Callbacks
 #include "pycore_frame.h"
 #include "pycore_interp.h"
+#include "pycore_runtime.h"       // _PyRuntime
 
 
 #ifdef PY_HAVE_PERF_TRAMPOLINE
index 862b2e59eb77d5411b62b8145aa201e56b6d74e9..bf34fb2523dfc8db4e5c1932e0a412384a3931d6 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "Python.h"
-#include "pycore_initconfig.h"      // _PyStatus_NO_MEMORY()
-#include "pycore_lock.h"            // PyMutex_Lock()
-#include "pycore_qsbr.h"
+#include "pycore_interp.h"          // PyInterpreterState
 #include "pycore_pystate.h"         // _PyThreadState_GET()
+#include "pycore_qsbr.h"
+#include "pycore_tstate.h"          // _PyThreadStateImpl
 
 
 // Starting size of the array of qsbr thread states
index 4d6384f597f1f03ff72068f0bb801d62ea52c8fa..9e2c0fb72942264479c410eeb7b0ce0b5c7c769d 100644 (file)
@@ -2,7 +2,12 @@
 #include "pycore_ast.h"           // stmt_ty
 #include "pycore_parser.h"        // _PyParser_ASTFromString()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
+#include "pycore_runtime.h"       // _Py_ID()
 #include "pycore_symtable.h"      // PySTEntryObject
+#include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString()
+
+#include <stddef.h>               // offsetof()
+
 
 // Set this to 1 to dump all symtables to stdout for debugging
 #define _PY_DUMP_SYMTABLE 0
index b31d1dc5e770eff06c88e4ce287e8d158cc38f80..4ff5f11a34852b2cffa48e2d667bcbcf25c1ff3d 100644 (file)
@@ -8,8 +8,9 @@
 #include "Python.h"
 #include "pycore_ceval.h"         // _PyEval_MakePendingCalls()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
-#include "pycore_structseq.h"     // _PyStructSequence_FiniBuiltin()
 #include "pycore_pythread.h"      // _POSIX_THREADS
+#include "pycore_runtime.h"       // _PyRuntime
+#include "pycore_structseq.h"     // _PyStructSequence_FiniBuiltin()
 
 #ifndef DONT_HAVE_STDIO_H
 #  include <stdio.h>