From 4f98f465f14e7258c5b18a62c5aa114dbe1174d8 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 15 Apr 2020 04:01:58 +0200 Subject: [PATCH] bpo-40268: Remove unused imports in pylifecycle.c (GH-19533) Remove unused imports in files: * initconfig.c * main.c * preconfig.h * pylifecycle.c * python.c * pythonrun.c --- Modules/main.c | 18 +++++++-------- Programs/python.c | 1 - Python/initconfig.c | 15 +++++++------ Python/preconfig.c | 4 ++-- Python/pylifecycle.c | 53 ++++++++++++++++++-------------------------- Python/pythonrun.c | 39 +++++++++++++++----------------- 6 files changed, 59 insertions(+), 71 deletions(-) diff --git a/Modules/main.c b/Modules/main.c index 4d696a35901..bc3a2ed8ed8 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -1,22 +1,22 @@ /* Python interpreter main program */ #include "Python.h" -#include "pycore_initconfig.h" -#include "pycore_interp.h" // _PyInterpreterState.sysdict -#include "pycore_pathconfig.h" -#include "pycore_pylifecycle.h" -#include "pycore_pystate.h" // _PyInterpreterState_GET() +#include "pycore_initconfig.h" // _PyArgv +#include "pycore_interp.h" // _PyInterpreterState.sysdict +#include "pycore_pathconfig.h" // _PyPathConfig_ComputeSysPath0() +#include "pycore_pylifecycle.h" // _Py_PreInitializeFromPyArgv() +#include "pycore_pystate.h" // _PyInterpreterState_GET() /* Includes for exit_sigint() */ -#include /* perror() */ +#include // perror() #ifdef HAVE_SIGNAL_H -# include /* SIGINT */ +# include // SIGINT #endif #if defined(HAVE_GETPID) && defined(HAVE_UNISTD_H) -# include /* getpid() */ +# include // getpid() #endif #ifdef MS_WINDOWS -# include /* STATUS_CONTROL_C_EXIT */ +# include // STATUS_CONTROL_C_EXIT #endif /* End of includes for exit_sigint() */ diff --git a/Programs/python.c b/Programs/python.c index 1cc3c42cfcb..84148f7767a 100644 --- a/Programs/python.c +++ b/Programs/python.c @@ -1,7 +1,6 @@ /* Minimal main program -- everything is loaded from the library */ #include "Python.h" -#include "pycore_pylifecycle.h" #ifdef MS_WINDOWS int diff --git a/Python/initconfig.c b/Python/initconfig.c index 32aafdb57ad..c313d91ac73 100644 --- a/Python/initconfig.c +++ b/Python/initconfig.c @@ -1,14 +1,15 @@ #include "Python.h" -#include "osdefs.h" // DELIM -#include "pycore_fileutils.h" -#include "pycore_getopt.h" -#include "pycore_initconfig.h" +#include "pycore_fileutils.h" // _Py_HasFileSystemDefaultEncodeErrors +#include "pycore_getopt.h" // _PyOS_GetOpt() +#include "pycore_initconfig.h" // _PyStatus_OK() #include "pycore_interp.h" // _PyInterpreterState.runtime -#include "pycore_pathconfig.h" -#include "pycore_pyerrors.h" -#include "pycore_pylifecycle.h" +#include "pycore_pathconfig.h" // _Py_path_config +#include "pycore_pyerrors.h" // _PyErr_Fetch() +#include "pycore_pylifecycle.h" // _Py_PreInitializeFromConfig() #include "pycore_pymem.h" // _PyMem_SetDefaultAllocator() #include "pycore_pystate.h" // _PyThreadState_GET() + +#include "osdefs.h" // DELIM #include // setlocale() #ifdef HAVE_LANGINFO_H # include // nl_langinfo(CODESET) diff --git a/Python/preconfig.c b/Python/preconfig.c index 1cbfccfe69c..262738fa57d 100644 --- a/Python/preconfig.c +++ b/Python/preconfig.c @@ -1,6 +1,6 @@ #include "Python.h" -#include "pycore_getopt.h" -#include "pycore_initconfig.h" +#include "pycore_getopt.h" // _PyOS_GetOpt() +#include "pycore_initconfig.h" // _PyArgv #include "pycore_pymem.h" // _PyMem_GetAllocatorName() #include "pycore_runtime.h" // _PyRuntime_Initialize() #include // setlocale() diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 688ee0c133b..7909cdbf5b7 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -4,50 +4,41 @@ #include "Python-ast.h" #undef Yield /* undefine macro conflicting with */ -#include "pycore_ceval.h" -#include "pycore_context.h" + +#include "pycore_ceval.h" // _PyEval_FiniGIL() +#include "pycore_context.h" // _PyContext_Init() +#include "pycore_fileutils.h" // _Py_ResetForceASCII() #include "pycore_import.h" // _PyImport_Cleanup() -#include "pycore_initconfig.h" -#include "pycore_fileutils.h" -#include "pycore_hamt.h" -#include "pycore_object.h" -#include "pycore_pathconfig.h" -#include "pycore_pyerrors.h" -#include "pycore_pylifecycle.h" +#include "pycore_initconfig.h" // _PyStatus_OK() +#include "pycore_object.h" // _PyDebug_PrintTotalRefs() +#include "pycore_pathconfig.h" // _PyConfig_WritePathConfig() +#include "pycore_pyerrors.h" // _PyErr_Occurred() +#include "pycore_pylifecycle.h" // _PyErr_Print() #include "pycore_pystate.h" // _PyThreadState_GET() -#include "pycore_sysmodule.h" -#include "pycore_traceback.h" -#include "grammar.h" -#include "node.h" -#include "token.h" -#include "parsetok.h" -#include "errcode.h" -#include "code.h" -#include "symtable.h" -#include "ast.h" -#include "marshal.h" -#include +#include "pycore_sysmodule.h" // _PySys_ClearAuditHooks() +#include "pycore_traceback.h" // _Py_DumpTracebackThreads() + +#include "grammar.h" // PyGrammar_RemoveAccelerators() +#include // setlocale() #ifdef HAVE_SIGNAL_H -#include -#endif - -#ifdef MS_WINDOWS -#include "malloc.h" /* for alloca */ +# include // SIG_IGN #endif #ifdef HAVE_LANGINFO_H -#include +# include // nl_langinfo(CODESET) #endif #ifdef MS_WINDOWS -#undef BYTE -#include "windows.h" +# undef BYTE +# include "windows.h" -extern PyTypeObject PyWindowsConsoleIO_Type; -#define PyWindowsConsoleIO_Check(op) (PyObject_TypeCheck((op), &PyWindowsConsoleIO_Type)) + extern PyTypeObject PyWindowsConsoleIO_Type; +# define PyWindowsConsoleIO_Check(op) \ + (PyObject_TypeCheck((op), &PyWindowsConsoleIO_Type)) #endif + _Py_IDENTIFIER(flush); _Py_IDENTIFIER(name); _Py_IDENTIFIER(stdin); diff --git a/Python/pythonrun.c b/Python/pythonrun.c index d6bc8832035..0a25ebc854f 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -12,35 +12,32 @@ #include "Python-ast.h" #undef Yield /* undefine macro conflicting with */ + #include "pycore_interp.h" // PyInterpreterState.importlib -#include "pycore_object.h" -#include "pycore_pyerrors.h" -#include "pycore_pylifecycle.h" +#include "pycore_object.h" // _PyDebug_PrintTotalRefs() +#include "pycore_pyerrors.h" // _PyErr_Fetch +#include "pycore_pylifecycle.h" // _Py_UnhandledKeyboardInterrupt #include "pycore_pystate.h" // _PyInterpreterState_GET() -#include "pycore_sysmodule.h" -#include "grammar.h" -#include "node.h" -#include "token.h" -#include "parsetok.h" -#include "errcode.h" -#include "code.h" -#include "symtable.h" -#include "ast.h" -#include "marshal.h" -#include +#include "pycore_sysmodule.h" // _PySys_Audit() -#ifdef HAVE_SIGNAL_H -#include +#include "node.h" // node +#include "token.h" // INDENT +#include "parsetok.h" // perrdetail +#include "errcode.h" // E_EOF +#include "code.h" // PyCodeObject +#include "symtable.h" // PySymtable_BuildObject() +#include "ast.h" // PyAST_FromNodeObject() +#include "marshal.h" // PyMarshal_ReadLongFromFile() + +#ifdef MS_WINDOWS +# include "malloc.h" // alloca() #endif #ifdef MS_WINDOWS -#include "malloc.h" /* for alloca */ +# undef BYTE +# include "windows.h" #endif -#ifdef MS_WINDOWS -#undef BYTE -#include "windows.h" -#endif _Py_IDENTIFIER(builtins); _Py_IDENTIFIER(excepthook);