Skip to content

Commit b298b39

Browse files
authored
gh-108765: Cleanup #include in Python/*.c files (#108977)
Mention one symbol imported by each #include.
1 parent 14d6e19 commit b298b39

18 files changed

+57
-48
lines changed

Include/internal/pycore_uops.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11+
#include "pycore_frame.h" // _PyInterpreterFrame
12+
1113
#define _Py_UOP_MAX_TRACE_LENGTH 64
1214

1315
typedef struct {

Python/intrinsics.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
#include "pycore_frame.h"
66
#include "pycore_function.h"
77
#include "pycore_global_objects.h"
8-
#include "pycore_intrinsics.h"
9-
#include "pycore_pyerrors.h"
10-
#include "pycore_runtime.h"
8+
#include "pycore_intrinsics.h" // INTRINSIC_PRINT
9+
#include "pycore_pyerrors.h" // _PyErr_SetString()
10+
#include "pycore_runtime.h" // _Py_ID()
1111
#include "pycore_sysmodule.h" // _PySys_GetAttr()
12-
#include "pycore_typevarobject.h"
12+
#include "pycore_typevarobject.h" // _Py_make_typevar()
1313

1414

1515
/******** Unary functions ********/

Python/legacy_tracing.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
* Provides callables to forward PEP 669 events to legacy events.
33
*/
44

5-
#include <stddef.h>
65
#include "Python.h"
7-
#include "opcode.h"
8-
#include "pycore_ceval.h"
6+
#include "pycore_ceval.h" // export _PyEval_SetProfile()
97
#include "pycore_object.h"
10-
#include "pycore_sysmodule.h"
8+
#include "pycore_sysmodule.h" // _PySys_Audit()
9+
10+
#include "opcode.h"
11+
#include <stddef.h>
1112

1213
typedef struct _PyLegacyEventHandler {
1314
PyObject_HEAD

Python/optimizer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "Python.h"
22
#include "opcode.h"
33
#include "pycore_interp.h"
4-
#include "pycore_opcode_metadata.h"
5-
#include "pycore_opcode_utils.h"
6-
#include "pycore_optimizer.h"
4+
#include "pycore_opcode_metadata.h" // _PyOpcode_OpName()
5+
#include "pycore_opcode_utils.h" // MAX_REAL_OPCODE
6+
#include "pycore_optimizer.h" // _Py_uop_analyze_and_optimize()
77
#include "pycore_pystate.h" // _PyInterpreterState_GET()
88
#include "pycore_uops.h"
99
#include "cpython/optimizer.h"

Python/pathconfig.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/* Path configuration like module_search_path (sys.path) */
22

33
#include "Python.h"
4-
#include "marshal.h" // PyMarshal_ReadObjectFromString
5-
#include "osdefs.h" // DELIM
6-
#include "pycore_initconfig.h"
7-
#include "pycore_fileutils.h"
4+
#include "pycore_initconfig.h" // _PyStatus_OK()
5+
#include "pycore_fileutils.h" // _Py_wgetcwd()
86
#include "pycore_pathconfig.h"
97
#include "pycore_pymem.h" // _PyMem_SetDefaultAllocator()
108
#include <wchar.h>
9+
10+
#include "marshal.h" // PyMarshal_ReadObjectFromString
11+
#include "osdefs.h" // DELIM
12+
1113
#ifdef MS_WINDOWS
1214
# include <windows.h> // GetFullPathNameW(), MAX_PATH
1315
# include <pathcch.h>

Python/perf_trampoline.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ any DWARF information available for them).
130130
*/
131131

132132
#include "Python.h"
133-
#include "pycore_ceval.h"
133+
#include "pycore_ceval.h" // _PyPerf_Callbacks
134134
#include "pycore_frame.h"
135135
#include "pycore_interp.h"
136136
#include "pycore_pyerrors.h" // _PyErr_WriteUnraisableMsg()

Python/pylifecycle.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "pycore_list.h" // _PyList_Fini()
1818
#include "pycore_long.h" // _PyLong_InitTypes()
1919
#include "pycore_object.h" // _PyDebug_PrintTotalRefs()
20-
#include "pycore_pathconfig.h" // _PyConfig_WritePathConfig()
20+
#include "pycore_pathconfig.h" // _PyPathConfig_UpdateGlobal()
2121
#include "pycore_pyerrors.h" // _PyErr_Occurred()
2222
#include "pycore_pylifecycle.h" // _PyErr_Print()
2323
#include "pycore_pymem.h" // _PyObject_DebugMallocStats()
@@ -32,13 +32,14 @@
3232
#include "pycore_typevarobject.h" // _Py_clear_generic_types()
3333
#include "pycore_unicodeobject.h" // _PyUnicode_InitTypes()
3434
#include "pycore_weakref.h" // _PyWeakref_GET_REF()
35+
3536
#include "opcode.h"
3637

3738
#include <locale.h> // setlocale()
3839
#include <stdlib.h> // getenv()
3940

4041
#if defined(__APPLE__)
41-
#include <mach-o/loader.h>
42+
# include <mach-o/loader.h>
4243
#endif
4344

4445
#ifdef HAVE_SIGNAL_H

Python/pystate.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
#include "pycore_code.h" // stats
77
#include "pycore_dtoa.h" // _dtoa_state_INIT()
88
#include "pycore_frame.h"
9-
#include "pycore_initconfig.h"
9+
#include "pycore_initconfig.h" // _PyStatus_OK()
1010
#include "pycore_object.h" // _PyType_InitCache()
11-
#include "pycore_pyerrors.h"
12-
#include "pycore_pylifecycle.h"
11+
#include "pycore_pyerrors.h" // _PyErr_Clear()
12+
#include "pycore_pylifecycle.h" // _PyAST_Fini()
1313
#include "pycore_pymem.h" // _PyMem_SetDefaultAllocator()
1414
#include "pycore_pystate.h"
1515
#include "pycore_runtime_init.h" // _PyRuntimeState_INIT

Python/pystrtod.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#include <Python.h>
44
#include "pycore_dtoa.h" // _Py_dg_strtod()
55
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
6-
#include <locale.h>
6+
7+
#include <locale.h> // localeconv()
78

89
/* Case-insensitive string match used for nan and inf detection; t should be
910
lower-case. Returns 1 for a successful match, 0 otherwise. */

Python/pythonrun.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212

1313
#include "Python.h"
1414

15-
#include "pycore_ast.h" // PyAST_mod2obj
16-
#include "pycore_ceval.h" // _Py_EnterRecursiveCall
15+
#include "pycore_ast.h" // PyAST_mod2obj()
16+
#include "pycore_ceval.h" // _Py_EnterRecursiveCall()
1717
#include "pycore_compile.h" // _PyAST_Compile()
1818
#include "pycore_interp.h" // PyInterpreterState.importlib
1919
#include "pycore_object.h" // _PyDebug_PrintTotalRefs()
2020
#include "pycore_parser.h" // _PyParser_ASTFromString()
21-
#include "pycore_pyerrors.h" // _PyErr_GetRaisedException, _Py_Offer_Suggestions
22-
#include "pycore_pylifecycle.h" // _Py_UnhandledKeyboardInterrupt
21+
#include "pycore_pyerrors.h" // _PyErr_GetRaisedException()
22+
#include "pycore_pylifecycle.h" // _Py_FdIsInteractive()
2323
#include "pycore_pystate.h" // _PyInterpreterState_GET()
24-
#include "pycore_pythonrun.h" // define _PyRun_InteractiveLoopObject()
24+
#include "pycore_pythonrun.h" // export _PyRun_InteractiveLoopObject()
2525
#include "pycore_sysmodule.h" // _PySys_Audit()
2626
#include "pycore_traceback.h" // _PyTraceBack_Print_Indented()
2727

0 commit comments

Comments
 (0)