Skip to content

Commit 4f98f46

Browse files
authored
bpo-40268: Remove unused imports in pylifecycle.c (pythonGH-19533)
Remove unused imports in files: * initconfig.c * main.c * preconfig.h * pylifecycle.c * python.c * pythonrun.c
1 parent 361dcdc commit 4f98f46

File tree

6 files changed

+59
-71
lines changed

6 files changed

+59
-71
lines changed

Modules/main.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
/* Python interpreter main program */
22

33
#include "Python.h"
4-
#include "pycore_initconfig.h"
5-
#include "pycore_interp.h" // _PyInterpreterState.sysdict
6-
#include "pycore_pathconfig.h"
7-
#include "pycore_pylifecycle.h"
8-
#include "pycore_pystate.h" // _PyInterpreterState_GET()
4+
#include "pycore_initconfig.h" // _PyArgv
5+
#include "pycore_interp.h" // _PyInterpreterState.sysdict
6+
#include "pycore_pathconfig.h" // _PyPathConfig_ComputeSysPath0()
7+
#include "pycore_pylifecycle.h" // _Py_PreInitializeFromPyArgv()
8+
#include "pycore_pystate.h" // _PyInterpreterState_GET()
99

1010
/* Includes for exit_sigint() */
11-
#include <stdio.h> /* perror() */
11+
#include <stdio.h> // perror()
1212
#ifdef HAVE_SIGNAL_H
13-
# include <signal.h> /* SIGINT */
13+
# include <signal.h> // SIGINT
1414
#endif
1515
#if defined(HAVE_GETPID) && defined(HAVE_UNISTD_H)
16-
# include <unistd.h> /* getpid() */
16+
# include <unistd.h> // getpid()
1717
#endif
1818
#ifdef MS_WINDOWS
19-
# include <windows.h> /* STATUS_CONTROL_C_EXIT */
19+
# include <windows.h> // STATUS_CONTROL_C_EXIT
2020
#endif
2121
/* End of includes for exit_sigint() */
2222

Programs/python.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* Minimal main program -- everything is loaded from the library */
22

33
#include "Python.h"
4-
#include "pycore_pylifecycle.h"
54

65
#ifdef MS_WINDOWS
76
int

Python/initconfig.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#include "Python.h"
2-
#include "osdefs.h" // DELIM
3-
#include "pycore_fileutils.h"
4-
#include "pycore_getopt.h"
5-
#include "pycore_initconfig.h"
2+
#include "pycore_fileutils.h" // _Py_HasFileSystemDefaultEncodeErrors
3+
#include "pycore_getopt.h" // _PyOS_GetOpt()
4+
#include "pycore_initconfig.h" // _PyStatus_OK()
65
#include "pycore_interp.h" // _PyInterpreterState.runtime
7-
#include "pycore_pathconfig.h"
8-
#include "pycore_pyerrors.h"
9-
#include "pycore_pylifecycle.h"
6+
#include "pycore_pathconfig.h" // _Py_path_config
7+
#include "pycore_pyerrors.h" // _PyErr_Fetch()
8+
#include "pycore_pylifecycle.h" // _Py_PreInitializeFromConfig()
109
#include "pycore_pymem.h" // _PyMem_SetDefaultAllocator()
1110
#include "pycore_pystate.h" // _PyThreadState_GET()
11+
12+
#include "osdefs.h" // DELIM
1213
#include <locale.h> // setlocale()
1314
#ifdef HAVE_LANGINFO_H
1415
# include <langinfo.h> // nl_langinfo(CODESET)

Python/preconfig.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "Python.h"
2-
#include "pycore_getopt.h"
3-
#include "pycore_initconfig.h"
2+
#include "pycore_getopt.h" // _PyOS_GetOpt()
3+
#include "pycore_initconfig.h" // _PyArgv
44
#include "pycore_pymem.h" // _PyMem_GetAllocatorName()
55
#include "pycore_runtime.h" // _PyRuntime_Initialize()
66
#include <locale.h> // setlocale()

Python/pylifecycle.c

+22-31
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,41 @@
44

55
#include "Python-ast.h"
66
#undef Yield /* undefine macro conflicting with <winbase.h> */
7-
#include "pycore_ceval.h"
8-
#include "pycore_context.h"
7+
8+
#include "pycore_ceval.h" // _PyEval_FiniGIL()
9+
#include "pycore_context.h" // _PyContext_Init()
10+
#include "pycore_fileutils.h" // _Py_ResetForceASCII()
911
#include "pycore_import.h" // _PyImport_Cleanup()
10-
#include "pycore_initconfig.h"
11-
#include "pycore_fileutils.h"
12-
#include "pycore_hamt.h"
13-
#include "pycore_object.h"
14-
#include "pycore_pathconfig.h"
15-
#include "pycore_pyerrors.h"
16-
#include "pycore_pylifecycle.h"
12+
#include "pycore_initconfig.h" // _PyStatus_OK()
13+
#include "pycore_object.h" // _PyDebug_PrintTotalRefs()
14+
#include "pycore_pathconfig.h" // _PyConfig_WritePathConfig()
15+
#include "pycore_pyerrors.h" // _PyErr_Occurred()
16+
#include "pycore_pylifecycle.h" // _PyErr_Print()
1717
#include "pycore_pystate.h" // _PyThreadState_GET()
18-
#include "pycore_sysmodule.h"
19-
#include "pycore_traceback.h"
20-
#include "grammar.h"
21-
#include "node.h"
22-
#include "token.h"
23-
#include "parsetok.h"
24-
#include "errcode.h"
25-
#include "code.h"
26-
#include "symtable.h"
27-
#include "ast.h"
28-
#include "marshal.h"
29-
#include <locale.h>
18+
#include "pycore_sysmodule.h" // _PySys_ClearAuditHooks()
19+
#include "pycore_traceback.h" // _Py_DumpTracebackThreads()
3020

31-
#ifdef HAVE_SIGNAL_H
32-
#include <signal.h>
33-
#endif
21+
#include "grammar.h" // PyGrammar_RemoveAccelerators()
22+
#include <locale.h> // setlocale()
3423

35-
#ifdef MS_WINDOWS
36-
#include "malloc.h" /* for alloca */
24+
#ifdef HAVE_SIGNAL_H
25+
# include <signal.h> // SIG_IGN
3726
#endif
3827

3928
#ifdef HAVE_LANGINFO_H
40-
#include <langinfo.h>
29+
# include <langinfo.h> // nl_langinfo(CODESET)
4130
#endif
4231

4332
#ifdef MS_WINDOWS
44-
#undef BYTE
45-
#include "windows.h"
33+
# undef BYTE
34+
# include "windows.h"
4635

47-
extern PyTypeObject PyWindowsConsoleIO_Type;
48-
#define PyWindowsConsoleIO_Check(op) (PyObject_TypeCheck((op), &PyWindowsConsoleIO_Type))
36+
extern PyTypeObject PyWindowsConsoleIO_Type;
37+
# define PyWindowsConsoleIO_Check(op) \
38+
(PyObject_TypeCheck((op), &PyWindowsConsoleIO_Type))
4939
#endif
5040

41+
5142
_Py_IDENTIFIER(flush);
5243
_Py_IDENTIFIER(name);
5344
_Py_IDENTIFIER(stdin);

Python/pythonrun.c

+18-21
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,33 @@
1212

1313
#include "Python-ast.h"
1414
#undef Yield /* undefine macro conflicting with <winbase.h> */
15+
1516
#include "pycore_interp.h" // PyInterpreterState.importlib
16-
#include "pycore_object.h"
17-
#include "pycore_pyerrors.h"
18-
#include "pycore_pylifecycle.h"
17+
#include "pycore_object.h" // _PyDebug_PrintTotalRefs()
18+
#include "pycore_pyerrors.h" // _PyErr_Fetch
19+
#include "pycore_pylifecycle.h" // _Py_UnhandledKeyboardInterrupt
1920
#include "pycore_pystate.h" // _PyInterpreterState_GET()
20-
#include "pycore_sysmodule.h"
21-
#include "grammar.h"
22-
#include "node.h"
23-
#include "token.h"
24-
#include "parsetok.h"
25-
#include "errcode.h"
26-
#include "code.h"
27-
#include "symtable.h"
28-
#include "ast.h"
29-
#include "marshal.h"
30-
#include <locale.h>
31-
32-
#ifdef HAVE_SIGNAL_H
33-
#include <signal.h>
34-
#endif
21+
#include "pycore_sysmodule.h" // _PySys_Audit()
22+
23+
#include "node.h" // node
24+
#include "token.h" // INDENT
25+
#include "parsetok.h" // perrdetail
26+
#include "errcode.h" // E_EOF
27+
#include "code.h" // PyCodeObject
28+
#include "symtable.h" // PySymtable_BuildObject()
29+
#include "ast.h" // PyAST_FromNodeObject()
30+
#include "marshal.h" // PyMarshal_ReadLongFromFile()
3531

3632
#ifdef MS_WINDOWS
37-
#include "malloc.h" /* for alloca */
33+
# include "malloc.h" // alloca()
3834
#endif
3935

4036
#ifdef MS_WINDOWS
41-
#undef BYTE
42-
#include "windows.h"
37+
# undef BYTE
38+
# include "windows.h"
4339
#endif
4440

41+
4542
_Py_IDENTIFIER(builtins);
4643
_Py_IDENTIFIER(excepthook);
4744
_Py_IDENTIFIER(flush);

0 commit comments

Comments
 (0)