gh-108765: Cleanup #include in Python/*.c files (#108977)

Mention one symbol imported by each #include.
This commit is contained in:
Victor Stinner 2023-09-06 15:56:08 +02:00 committed by GitHub
parent 14d6e197cc
commit b298b395e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 57 additions and 48 deletions

View 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 {

View 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 ********/

View 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

View 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"

View 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>

View 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()

View 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()
@ -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

View 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

View 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. */

View File

@ -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()

View 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()

View 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

View 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

View 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)
{

View File

@ -11,7 +11,7 @@
#include "pycore_pythread.h"
#ifndef DONT_HAVE_STDIO_H
#include <stdio.h>
# include <stdio.h>
#endif
#include <stdlib.h>

View 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;
}

View 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

View 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()