]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-108765: Cleanup #include in Python/*.c files (#108977)
authorVictor Stinner <vstinner@python.org>
Wed, 6 Sep 2023 13:56:08 +0000 (15:56 +0200)
committerGitHub <noreply@github.com>
Wed, 6 Sep 2023 13:56:08 +0000 (15:56 +0200)
Mention one symbol imported by each #include.

18 files changed:
Include/internal/pycore_uops.h
Python/intrinsics.c
Python/legacy_tracing.c
Python/optimizer.c
Python/pathconfig.c
Python/perf_trampoline.c
Python/pylifecycle.c
Python/pystate.c
Python/pystrtod.c
Python/pythonrun.c
Python/specialize.c
Python/suggestions.c
Python/symtable.c
Python/sysmodule.c
Python/thread.c
Python/thread_pthread_stubs.h
Python/traceback.c
Python/tracemalloc.c

index 254eeca2361bea28e01bec0dba2fa75ec7307fe1..249f5c010e00923c8d3e8692d4c8fe82b59f44fb 100644 (file)
@@ -8,6 +8,8 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
+#include "pycore_frame.h"         // _PyInterpreterFrame
+
 #define _Py_UOP_MAX_TRACE_LENGTH 64
 
 typedef struct {
index 8e59c63aea39ff01ddd28e6c7ec5420dc7c2f505..bbd79ec473f470414cad4f784b3a6c6dbc958089 100644 (file)
@@ -5,11 +5,11 @@
 #include "pycore_frame.h"
 #include "pycore_function.h"
 #include "pycore_global_objects.h"
-#include "pycore_intrinsics.h"
-#include "pycore_pyerrors.h"
-#include "pycore_runtime.h"
+#include "pycore_intrinsics.h"    // INTRINSIC_PRINT
+#include "pycore_pyerrors.h"      // _PyErr_SetString()
+#include "pycore_runtime.h"       // _Py_ID()
 #include "pycore_sysmodule.h"     // _PySys_GetAttr()
-#include "pycore_typevarobject.h"
+#include "pycore_typevarobject.h" // _Py_make_typevar()
 
 
 /******** Unary functions ********/
index 17a13b1361f9925e35d9fa72cad1066e45c3a4cd..9258091afc7c492d8ef3c6c9712bf3d83dd0ca5c 100644 (file)
@@ -2,12 +2,13 @@
  * Provides callables to forward PEP 669 events to legacy events.
  */
 
-#include <stddef.h>
 #include "Python.h"
-#include "opcode.h"
-#include "pycore_ceval.h"
+#include "pycore_ceval.h"         // export _PyEval_SetProfile()
 #include "pycore_object.h"
-#include "pycore_sysmodule.h"
+#include "pycore_sysmodule.h"     // _PySys_Audit()
+
+#include "opcode.h"
+#include <stddef.h>
 
 typedef struct _PyLegacyEventHandler {
     PyObject_HEAD
index 7472f52c50b7668df6fabd7e98e74d7babc7871e..8aaf9f9fd7cb1454216daf64b428af4f6c3767ef 100644 (file)
@@ -1,9 +1,9 @@
 #include "Python.h"
 #include "opcode.h"
 #include "pycore_interp.h"
-#include "pycore_opcode_metadata.h"
-#include "pycore_opcode_utils.h"
-#include "pycore_optimizer.h"
+#include "pycore_opcode_metadata.h" // _PyOpcode_OpName()
+#include "pycore_opcode_utils.h"  // MAX_REAL_OPCODE
+#include "pycore_optimizer.h"     // _Py_uop_analyze_and_optimize()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
 #include "pycore_uops.h"
 #include "cpython/optimizer.h"
index afffa134e893bae44d55dfefbd6359ac7627aa83..0ac64ec811025938ecf7ee3efb995c6e6c87aebc 100644 (file)
@@ -1,13 +1,15 @@
 /* Path configuration like module_search_path (sys.path) */
 
 #include "Python.h"
-#include "marshal.h"              // PyMarshal_ReadObjectFromString
-#include "osdefs.h"               // DELIM
-#include "pycore_initconfig.h"
-#include "pycore_fileutils.h"
+#include "pycore_initconfig.h"    // _PyStatus_OK()
+#include "pycore_fileutils.h"     // _Py_wgetcwd()
 #include "pycore_pathconfig.h"
 #include "pycore_pymem.h"         // _PyMem_SetDefaultAllocator()
 #include <wchar.h>
+
+#include "marshal.h"              // PyMarshal_ReadObjectFromString
+#include "osdefs.h"               // DELIM
+
 #ifdef MS_WINDOWS
 #  include <windows.h>            // GetFullPathNameW(), MAX_PATH
 #  include <pathcch.h>
index 0f1af30226d9fb50e0cc10ab223948c488a20525..209a23b6c1cbc7b1ec0b3efeeefd05623f2c3b54 100644 (file)
@@ -130,7 +130,7 @@ any DWARF information available for them).
 */
 
 #include "Python.h"
-#include "pycore_ceval.h"
+#include "pycore_ceval.h"         // _PyPerf_Callbacks
 #include "pycore_frame.h"
 #include "pycore_interp.h"
 #include "pycore_pyerrors.h"      // _PyErr_WriteUnraisableMsg()
index 64c74f433f222c8743cc0000f19dc7fc998e5b01..92eef6d50712bbd314c214a4dba496b1975b9e79 100644 (file)
@@ -17,7 +17,7 @@
 #include "pycore_list.h"          // _PyList_Fini()
 #include "pycore_long.h"          // _PyLong_InitTypes()
 #include "pycore_object.h"        // _PyDebug_PrintTotalRefs()
-#include "pycore_pathconfig.h"    // _PyConfig_WritePathConfig()
+#include "pycore_pathconfig.h"    // _PyPathConfig_UpdateGlobal()
 #include "pycore_pyerrors.h"      // _PyErr_Occurred()
 #include "pycore_pylifecycle.h"   // _PyErr_Print()
 #include "pycore_pymem.h"         // _PyObject_DebugMallocStats()
 #include "pycore_typevarobject.h" // _Py_clear_generic_types()
 #include "pycore_unicodeobject.h" // _PyUnicode_InitTypes()
 #include "pycore_weakref.h"       // _PyWeakref_GET_REF()
+
 #include "opcode.h"
 
 #include <locale.h>               // setlocale()
 #include <stdlib.h>               // getenv()
 
 #if defined(__APPLE__)
-#include <mach-o/loader.h>
+#  include <mach-o/loader.h>
 #endif
 
 #ifdef HAVE_SIGNAL_H
index 46ea2c4f678db8a354ebd55ad156e2296fd600a4..b2b9b9f8776c331ccbc8b23ce6124bd8bb95494c 100644 (file)
@@ -6,10 +6,10 @@
 #include "pycore_code.h"          // stats
 #include "pycore_dtoa.h"          // _dtoa_state_INIT()
 #include "pycore_frame.h"
-#include "pycore_initconfig.h"
+#include "pycore_initconfig.h"    // _PyStatus_OK()
 #include "pycore_object.h"        // _PyType_InitCache()
-#include "pycore_pyerrors.h"
-#include "pycore_pylifecycle.h"
+#include "pycore_pyerrors.h"      // _PyErr_Clear()
+#include "pycore_pylifecycle.h"   // _PyAST_Fini()
 #include "pycore_pymem.h"         // _PyMem_SetDefaultAllocator()
 #include "pycore_pystate.h"
 #include "pycore_runtime_init.h"  // _PyRuntimeState_INIT
index 9bb060e3d11979cdb59aba2e29963e69cb0b4505..16bf06f0e6cca2fb4ea5bcbbcdd8fbb05969b0a0 100644 (file)
@@ -3,7 +3,8 @@
 #include <Python.h>
 #include "pycore_dtoa.h"          // _Py_dg_strtod()
 #include "pycore_pymath.h"        // _PY_SHORT_FLOAT_REPR
-#include <locale.h>
+
+#include <locale.h>               // localeconv()
 
 /* Case-insensitive string match used for nan and inf detection; t should be
    lower-case.  Returns 1 for a successful match, 0 otherwise. */
index 231ac78146a0e6ecb12a5a3bf8e9125befa7d369..ddd8951cedb1f15dca8749b906f099c3dc8383e3 100644 (file)
 
 #include "Python.h"
 
-#include "pycore_ast.h"           // PyAST_mod2obj
-#include "pycore_ceval.h"         // _Py_EnterRecursiveCall
+#include "pycore_ast.h"           // PyAST_mod2obj()
+#include "pycore_ceval.h"         // _Py_EnterRecursiveCall()
 #include "pycore_compile.h"       // _PyAST_Compile()
 #include "pycore_interp.h"        // PyInterpreterState.importlib
 #include "pycore_object.h"        // _PyDebug_PrintTotalRefs()
 #include "pycore_parser.h"        // _PyParser_ASTFromString()
-#include "pycore_pyerrors.h"      // _PyErr_GetRaisedException, _Py_Offer_Suggestions
-#include "pycore_pylifecycle.h"   // _Py_UnhandledKeyboardInterrupt
+#include "pycore_pyerrors.h"      // _PyErr_GetRaisedException()
+#include "pycore_pylifecycle.h"   // _Py_FdIsInteractive()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
-#include "pycore_pythonrun.h"     // define _PyRun_InteractiveLoopObject()
+#include "pycore_pythonrun.h"     // export _PyRun_InteractiveLoopObject()
 #include "pycore_sysmodule.h"     // _PySys_Audit()
 #include "pycore_traceback.h"     // _PyTraceBack_Print_Indented()
 
index a794f146c188ecdba1da5c81ab8fcc1e2e34fabd..aa40b3343f3adde7e020e03d7bba7d05cf1fdbb7 100644 (file)
@@ -4,14 +4,14 @@
 
 #include "pycore_code.h"
 #include "pycore_descrobject.h"   // _PyMethodWrapper_Type
-#include "pycore_dict.h"
+#include "pycore_dict.h"          // DICT_KEYS_UNICODE
 #include "pycore_function.h"      // _PyFunction_GetVersionForCurrentState()
-#include "pycore_global_strings.h"  // _Py_ID()
-#include "pycore_long.h"
+#include "pycore_long.h"          // _PyLong_IsNonNegativeCompact()
 #include "pycore_moduleobject.h"
 #include "pycore_object.h"
 #include "pycore_opcode_metadata.h" // _PyOpcode_Caches
 #include "pycore_pylifecycle.h"   // _PyOS_URandomNonblock()
+#include "pycore_runtime.h"       // _Py_ID()
 
 
 #include <stdlib.h> // rand()
index 12097f793e3575863e59d80f2a666ca17bed93d8..9247da4c7037a28e9a801c1c0f24fbd2329e7cb4 100644 (file)
@@ -1,10 +1,9 @@
 #include "Python.h"
+#include "pycore_code.h"          // _PyCode_GetVarnames()
 #include "pycore_frame.h"
-#include "pycore_runtime.h"         // _PyRuntime
-#include "pycore_global_objects.h"  // _Py_ID()
+#include "pycore_pyerrors.h"      // export _Py_UTF8_Edit_Cost()
+#include "pycore_runtime.h"       // _Py_ID()
 
-#include "pycore_pyerrors.h"
-#include "pycore_code.h"        // _PyCode_GetVarnames()
 #include "stdlib_module_names.h"  // _Py_stdlib_module_names
 
 #define MAX_CANDIDATE_ITEMS 750
index e9adbd5d29b1f91d40560d02128470ee7c1311e4..f157d4c170314a2bff147ad8e09675efe4e00b97 100644 (file)
@@ -1,5 +1,5 @@
 #include "Python.h"
-#include "pycore_ast.h"           // identifier, stmt_ty
+#include "pycore_ast.h"           // stmt_ty
 #include "pycore_parser.h"        // _PyParser_ASTFromString()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_symtable.h"      // PySTEntryObject
index 0ec763c7aa7cf853d7eca8f996e07d5fb561dd6c..3835f760072ef98db18f4c766f6553f291334066 100644 (file)
@@ -23,7 +23,7 @@ Data members:
 #include "pycore_long.h"          // _PY_LONG_MAX_STR_DIGITS_THRESHOLD
 #include "pycore_modsupport.h"    // _PyModule_CreateInitialized()
 #include "pycore_namespace.h"     // _PyNamespace_New()
-#include "pycore_object.h"        // _PyObject_IS_GC(), _PyObject_DebugTypeStats()
+#include "pycore_object.h"        // _PyObject_DebugTypeStats()
 #include "pycore_pathconfig.h"    // _PyPathConfig_ComputeSysPath0()
 #include "pycore_pyerrors.h"      // _PyErr_GetRaisedException()
 #include "pycore_pylifecycle.h"   // _PyErr_WriteUnraisableDefaultHook()
@@ -31,18 +31,19 @@ Data members:
 #include "pycore_pymem.h"         // _PyMem_SetDefaultAllocator()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_structseq.h"     // _PyStructSequence_InitBuiltinWithFlags()
-#include "pycore_sysmodule.h"     // Define _PySys_GetSizeOf()
+#include "pycore_sysmodule.h"     // export _PySys_GetSizeOf()
 #include "pycore_tuple.h"         // _PyTuple_FromArray()
 
 #include "frameobject.h"          // PyFrame_FastToLocalsWithError()
-#include "pydtrace.h"
+#include "pydtrace.h"             // PyDTrace_AUDIT()
 #include "osdefs.h"               // DELIM
 #include "stdlib_module_names.h"  // _Py_stdlib_module_names
+
 #include <locale.h>
 
 #ifdef MS_WINDOWS
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#  define WIN32_LEAN_AND_MEAN
+#  include <windows.h>
 #endif /* MS_WINDOWS */
 
 #ifdef MS_COREDLL
@@ -52,11 +53,11 @@ extern const char *PyWin_DLLVersionString;
 #endif
 
 #ifdef __EMSCRIPTEN__
-#include <emscripten.h>
+#  include <emscripten.h>
 #endif
 
 #ifdef HAVE_FCNTL_H
-#include <fcntl.h>
+#  include <fcntl.h>
 #endif
 
 /*[clinic input]
@@ -66,6 +67,7 @@ module sys
 
 #include "clinic/sysmodule.c.h"
 
+
 PyObject *
 _PySys_GetAttr(PyThreadState *tstate, PyObject *name)
 {
index 7fc53f9b61360bf4f5ab322f88963985129e3dc7..1ac2db2937e373892e325f5ea226b04c23f83fdf 100644 (file)
@@ -11,7 +11,7 @@
 #include "pycore_pythread.h"
 
 #ifndef DONT_HAVE_STDIO_H
-#include <stdio.h>
+#  include <stdio.h>
 #endif
 
 #include <stdlib.h>
index 56e5b6141924b4005021807f92d6df7a4b5ac48d..48bad36ec449ab4cafa58a7ed4f05a48a590dac9 100644 (file)
@@ -40,7 +40,7 @@ pthread_cond_init(pthread_cond_t *restrict cond,
     return 0;
 }
 
-PyAPI_FUNC(int)pthread_cond_destroy(pthread_cond_t *cond)
+PyAPI_FUNC(int) pthread_cond_destroy(pthread_cond_t *cond)
 {
     return 0;
 }
index 657ddab1cbf615528f44b80e4e81731c3861a3eb..2fcfa7ca56c14078bfe929af45ecd028a0d61cd4 100644 (file)
@@ -3,9 +3,9 @@
 
 #include "Python.h"
 
-#include "pycore_ast.h"           // asdl_seq_*
+#include "pycore_ast.h"           // asdl_seq_GET()
 #include "pycore_call.h"          // _PyObject_CallMethodFormat()
-#include "pycore_compile.h"       // _PyAST_Optimize
+#include "pycore_compile.h"       // _PyAST_Optimize()
 #include "pycore_fileutils.h"     // _Py_BEGIN_SUPPRESS_IPH
 #include "pycore_frame.h"         // _PyFrame_GetCode()
 #include "pycore_interp.h"        // PyInterpreterState.gc
index 7d294ea5fe744c9b9bf42ba534117926201933bc..19b64c619feb6aabe867baab3d4aa32c5d0b0119 100644 (file)
@@ -2,11 +2,12 @@
 #include "pycore_fileutils.h"     // _Py_write_noraise()
 #include "pycore_gc.h"            // PyGC_Head
 #include "pycore_hashtable.h"     // _Py_hashtable_t
-#include "pycore_object.h"        // _PyType_PreHeaderSize
+#include "pycore_object.h"        // _PyType_PreHeaderSize()
 #include "pycore_pymem.h"         // _Py_tracemalloc_config
 #include "pycore_runtime.h"       // _Py_ID()
-#include "pycore_traceback.h"
+#include "pycore_traceback.h"     // _Py_DumpASCII()
 #include <pycore_frame.h>
+
 #include "frameobject.h"          // _PyInterpreterFrame_GetLine
 
 #include <stdlib.h>               // malloc()