From 4a3fe0835310643193ea45529ab0fb45c5f8f2fd Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 14 Apr 2020 14:26:24 +0200 Subject: [PATCH] bpo-40268: Include explicitly pycore_interp.h (GH-19505) pycore_pystate.h no longer includes pycore_interp.h: it's now included explicitly in files accessing PyInterpreterState. --- Include/internal/pycore_ceval.h | 4 ++-- Include/internal/pycore_object.h | 4 +++- Include/internal/pycore_pystate.h | 3 +-- Modules/_threadmodule.c | 3 ++- Modules/main.c | 1 + Objects/codeobject.c | 3 ++- Objects/interpreteridobject.c | 1 + Objects/longobject.c | 3 ++- Objects/moduleobject.c | 1 + Parser/listnode.c | 3 ++- Python/_warnings.c | 1 + Python/codecs.c | 1 + Python/dynload_shlib.c | 1 + Python/import.c | 1 + Python/initconfig.c | 1 + Python/preconfig.c | 7 ++++--- Python/sysmodule.c | 4 +++- Python/thread_nt.h | 1 + Python/thread_pthread.h | 1 + 19 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h index 811aada3dcb..298018a872b 100644 --- a/Include/internal/pycore_ceval.h +++ b/Include/internal/pycore_ceval.h @@ -13,7 +13,7 @@ struct pyruntimestate; struct _ceval_runtime_state; struct _frame; -#include "pycore_pystate.h" /* PyInterpreterState.eval_frame */ +#include "pycore_interp.h" /* PyInterpreterState.eval_frame */ extern void _Py_FinishPendingCalls(PyThreadState *tstate); extern void _PyEval_InitRuntimeState(struct _ceval_runtime_state *); @@ -50,7 +50,7 @@ extern PyObject *_PyEval_EvalCode( PyObject *kwdefs, PyObject *closure, PyObject *name, PyObject *qualname); -extern int _PyEval_ThreadsInitialized(_PyRuntimeState *runtime); +extern int _PyEval_ThreadsInitialized(struct pyruntimestate *runtime); extern PyStatus _PyEval_InitGIL(PyThreadState *tstate); extern void _PyEval_FiniGIL(PyThreadState *tstate); diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h index 5c3d3cae235..7c0f24ac07d 100644 --- a/Include/internal/pycore_object.h +++ b/Include/internal/pycore_object.h @@ -8,7 +8,9 @@ extern "C" { # error "this header requires Py_BUILD_CORE define" #endif -#include "pycore_pystate.h" /* PyInterpreterState.gc */ +#include "pycore_gc.h" // _PyObject_GC_IS_TRACKED() +#include "pycore_interp.h" // PyInterpreterState.gc +#include "pycore_pystate.h" // _PyThreadState_GET() PyAPI_FUNC(int) _PyType_CheckConsistency(PyTypeObject *type); PyAPI_FUNC(int) _PyDict_CheckConsistency(PyObject *mp, int check_content); diff --git a/Include/internal/pycore_pystate.h b/Include/internal/pycore_pystate.h index 748aa63a430..2e783781ada 100644 --- a/Include/internal/pycore_pystate.h +++ b/Include/internal/pycore_pystate.h @@ -8,8 +8,7 @@ extern "C" { # error "this header requires Py_BUILD_CORE define" #endif -#include "pycore_interp.h" /* PyInterpreterState */ -#include "pycore_runtime.h" /* PyRuntimestate */ +#include "pycore_runtime.h" /* PyRuntimeState */ /* Check if the current thread is the main thread. diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index e2bb14ec728..9853699771a 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -4,9 +4,10 @@ #include "Python.h" #include "pycore_pylifecycle.h" +#include "pycore_interp.h" // _PyInterpreterState.num_threads #include "pycore_pystate.h" -#include "structmember.h" /* offsetof */ #include "pythread.h" +#include // offsetof() static PyObject *ThreadError; static PyObject *str_dict; diff --git a/Modules/main.c b/Modules/main.c index 00a0fc3ece4..a9de70b6b09 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -2,6 +2,7 @@ #include "Python.h" #include "pycore_initconfig.h" +#include "pycore_interp.h" // _PyInterpreterState.sysdict #include "pycore_pathconfig.h" #include "pycore_pylifecycle.h" #include "pycore_pymem.h" diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 1820d8c8a56..7cb72ceab44 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -5,7 +5,8 @@ #include "opcode.h" #include "structmember.h" #include "pycore_code.h" -#include "pycore_pystate.h" +#include "pycore_interp.h" // PyInterpreterState.co_extra_freefuncs +#include "pycore_pystate.h" // _PyInterpreterState_GET_UNSAFE() #include "pycore_tupleobject.h" #include "clinic/codeobject.c.h" diff --git a/Objects/interpreteridobject.c b/Objects/interpreteridobject.c index 3f316873ed5..84fd8584520 100644 --- a/Objects/interpreteridobject.c +++ b/Objects/interpreteridobject.c @@ -2,6 +2,7 @@ #include "Python.h" #include "pycore_abstract.h" // _PyIndex_Check() +#include "pycore_interp.h" // _PyInterpreterState_LookUpID() #include "pycore_pystate.h" #include "interpreteridobject.h" diff --git a/Objects/longobject.c b/Objects/longobject.c index a66e1c49241..a0bb6bc52be 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -3,7 +3,8 @@ /* XXX The functional organization of this file is terrible */ #include "Python.h" -#include "pycore_pystate.h" /* _Py_IsMainInterpreter() */ +#include "pycore_interp.h" // _PY_NSMALLPOSINTS +#include "pycore_pystate.h" // _Py_IsMainInterpreter() #include "longintrepr.h" #include diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 30adc92acf6..acb920a4c07 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -2,6 +2,7 @@ /* Module object implementation */ #include "Python.h" +#include "pycore_interp.h" // PyInterpreterState.importlib #include "pycore_pystate.h" #include "structmember.h" diff --git a/Parser/listnode.c b/Parser/listnode.c index d431ae537e3..f53b265efe6 100644 --- a/Parser/listnode.c +++ b/Parser/listnode.c @@ -2,7 +2,8 @@ /* List a node on a file */ #include "Python.h" -#include "pycore_pystate.h" +#include "pycore_interp.h" // PyInterpreterState.parser +#include "pycore_pystate.h" // _PyInterpreterState_GET_UNSAFE #include "token.h" #include "node.h" diff --git a/Python/_warnings.c b/Python/_warnings.c index e4dfb7391ea..d005f12910b 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -1,5 +1,6 @@ #include "Python.h" #include "pycore_initconfig.h" +#include "pycore_interp.h" // PyInterpreterState.warnings #include "pycore_pyerrors.h" #include "pycore_pystate.h" #include "frameobject.h" diff --git a/Python/codecs.c b/Python/codecs.c index 7b35ded2edc..66919856ced 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -9,6 +9,7 @@ Copyright (c) Corporation for National Research Initiatives. ------------------------------------------------------------------------ */ #include "Python.h" +#include "pycore_interp.h" // PyInterpreterState.codec_search_path #include "pycore_pystate.h" #include "ucnhash.h" #include diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c index 36038711336..223e0d03f68 100644 --- a/Python/dynload_shlib.c +++ b/Python/dynload_shlib.c @@ -2,6 +2,7 @@ /* Support for dynamic loading of extension modules */ #include "Python.h" +#include "pycore_interp.h" // _PyInterpreterState.dlopenflags #include "pycore_pystate.h" // _PyInterpreterState_GET_UNSAFE() #include "importdl.h" diff --git a/Python/import.c b/Python/import.c index d79fa18e308..3bf8fe0581e 100644 --- a/Python/import.c +++ b/Python/import.c @@ -9,6 +9,7 @@ #include "pycore_pyhash.h" #include "pycore_pylifecycle.h" #include "pycore_pymem.h" +#include "pycore_interp.h" // _PyInterpreterState_ClearModules() #include "pycore_pystate.h" #include "pycore_sysmodule.h" #include "errcode.h" diff --git a/Python/initconfig.c b/Python/initconfig.c index e63d6f64f33..43e0ccb09b7 100644 --- a/Python/initconfig.c +++ b/Python/initconfig.c @@ -3,6 +3,7 @@ #include "pycore_fileutils.h" #include "pycore_getopt.h" #include "pycore_initconfig.h" +#include "pycore_interp.h" // _PyInterpreterState.runtime #include "pycore_pathconfig.h" #include "pycore_pyerrors.h" #include "pycore_pylifecycle.h" diff --git a/Python/preconfig.c b/Python/preconfig.c index 89a6227fa67..db328759c13 100644 --- a/Python/preconfig.c +++ b/Python/preconfig.c @@ -1,8 +1,9 @@ #include "Python.h" -#include "pycore_initconfig.h" #include "pycore_getopt.h" -#include "pycore_pystate.h" /* _PyRuntime_Initialize() */ -#include /* setlocale() */ +#include "pycore_initconfig.h" +#include "pycore_pymem.h" // _PyMem_GetAllocatorName() +#include "pycore_pystate.h" // _PyRuntime_Initialize() +#include // setlocale() #define DECODE_LOCALE_ERR(NAME, LEN) \ diff --git a/Python/sysmodule.c b/Python/sysmodule.c index fd0a9c0bf57..814e4abad58 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -17,7 +17,9 @@ Data members: #include "Python.h" #include "code.h" #include "frameobject.h" -#include "pycore_ceval.h" +#include "pycore_ceval.h" // _Py_RecursionLimitLowerWaterMark() +#include "pycore_pystate.h" // _PyThreadState_GET() +#include "pycore_tupleobject.h" #include "pycore_initconfig.h" #include "pycore_pathconfig.h" #include "pycore_pyerrors.h" diff --git a/Python/thread_nt.h b/Python/thread_nt.h index 23d585cf9fa..e4bd0f70581 100644 --- a/Python/thread_nt.h +++ b/Python/thread_nt.h @@ -1,3 +1,4 @@ +#include "pycore_interp.h" // _PyInterpreterState.pythread_stacksize /* This code implemented by Dag.Gruneau@elsa.preseco.comm.se */ /* Fast NonRecursiveMutex support by Yakov Markovitch, markovitch@iso.ru */ diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h index e3497e7d595..440d845312a 100644 --- a/Python/thread_pthread.h +++ b/Python/thread_pthread.h @@ -1,3 +1,4 @@ +#include "pycore_interp.h" // _PyInterpreterState.pythread_stacksize /* Posix threads interface */