diff options
author | Victor Stinner <vstinner@python.org> | 2023-09-06 13:56:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-06 13:56:08 (GMT) |
commit | b298b395e8ab1725c4f0dd736155b8c818664d42 (patch) | |
tree | 7946296ed34254283f71a70004b06fe7a7d2c30d /Python | |
parent | 14d6e197cc56e5256d501839a4e66e3864ab15f0 (diff) | |
download | cpython-b298b395e8ab1725c4f0dd736155b8c818664d42.zip cpython-b298b395e8ab1725c4f0dd736155b8c818664d42.tar.gz cpython-b298b395e8ab1725c4f0dd736155b8c818664d42.tar.bz2 |
gh-108765: Cleanup #include in Python/*.c files (#108977)
Mention one symbol imported by each #include.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/intrinsics.c | 8 | ||||
-rw-r--r-- | Python/legacy_tracing.c | 9 | ||||
-rw-r--r-- | Python/optimizer.c | 6 | ||||
-rw-r--r-- | Python/pathconfig.c | 10 | ||||
-rw-r--r-- | Python/perf_trampoline.c | 2 | ||||
-rw-r--r-- | Python/pylifecycle.c | 5 | ||||
-rw-r--r-- | Python/pystate.c | 6 | ||||
-rw-r--r-- | Python/pystrtod.c | 3 | ||||
-rw-r--r-- | Python/pythonrun.c | 10 | ||||
-rw-r--r-- | Python/specialize.c | 6 | ||||
-rw-r--r-- | Python/suggestions.c | 7 | ||||
-rw-r--r-- | Python/symtable.c | 2 | ||||
-rw-r--r-- | Python/sysmodule.c | 16 | ||||
-rw-r--r-- | Python/thread.c | 2 | ||||
-rw-r--r-- | Python/thread_pthread_stubs.h | 2 | ||||
-rw-r--r-- | Python/traceback.c | 4 | ||||
-rw-r--r-- | Python/tracemalloc.c | 5 |
17 files changed, 55 insertions, 48 deletions
diff --git a/Python/intrinsics.c b/Python/intrinsics.c index 8e59c63..bbd79ec 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -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 ********/ diff --git a/Python/legacy_tracing.c b/Python/legacy_tracing.c index 17a13b1..9258091 100644 --- a/Python/legacy_tracing.c +++ b/Python/legacy_tracing.c @@ -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 diff --git a/Python/optimizer.c b/Python/optimizer.c index 7472f52..8aaf9f9 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -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" diff --git a/Python/pathconfig.c b/Python/pathconfig.c index afffa13..0ac64ec 100644 --- a/Python/pathconfig.c +++ b/Python/pathconfig.c @@ -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> diff --git a/Python/perf_trampoline.c b/Python/perf_trampoline.c index 0f1af30..209a23b 100644 --- a/Python/perf_trampoline.c +++ b/Python/perf_trampoline.c @@ -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() diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 64c74f4..92eef6d 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -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() @@ -32,13 +32,14 @@ #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 diff --git a/Python/pystate.c b/Python/pystate.c index 46ea2c4..b2b9b9f 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -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 diff --git a/Python/pystrtod.c b/Python/pystrtod.c index 9bb060e..16bf06f 100644 --- a/Python/pystrtod.c +++ b/Python/pystrtod.c @@ -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. */ diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 231ac78..ddd8951 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -12,16 +12,16 @@ #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() diff --git a/Python/specialize.c b/Python/specialize.c index a794f14..aa40b33 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -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() diff --git a/Python/suggestions.c b/Python/suggestions.c index 12097f7..9247da4 100644 --- a/Python/suggestions.c +++ b/Python/suggestions.c @@ -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 diff --git a/Python/symtable.c b/Python/symtable.c index e9adbd5..f157d4c 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -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 diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 0ec763c..3835f76 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -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) { diff --git a/Python/thread.c b/Python/thread.c index 7fc53f9..1ac2db2 100644 --- a/Python/thread.c +++ b/Python/thread.c @@ -11,7 +11,7 @@ #include "pycore_pythread.h" #ifndef DONT_HAVE_STDIO_H -#include <stdio.h> +# include <stdio.h> #endif #include <stdlib.h> diff --git a/Python/thread_pthread_stubs.h b/Python/thread_pthread_stubs.h index 56e5b61..48bad36 100644 --- a/Python/thread_pthread_stubs.h +++ b/Python/thread_pthread_stubs.h @@ -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; } diff --git a/Python/traceback.c b/Python/traceback.c index 657ddab..2fcfa7c 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -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 diff --git a/Python/tracemalloc.c b/Python/tracemalloc.c index 7d294ea..19b64c6 100644 --- a/Python/tracemalloc.c +++ b/Python/tracemalloc.c @@ -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() |