[Python-checkins] bpo-40268: Include explicitly pycore_interp.h (GH-19505)

Victor Stinner webhook-mailer at python.org
Tue Apr 14 08:26:32 EDT 2020


https://github.com/python/cpython/commit/4a3fe0835310643193ea45529ab0fb45c5f8f2fd
commit: 4a3fe0835310643193ea45529ab0fb45c5f8f2fd
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-04-14T14:26:24+02:00
summary:

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.

files:
M Include/internal/pycore_ceval.h
M Include/internal/pycore_object.h
M Include/internal/pycore_pystate.h
M Modules/_threadmodule.c
M Modules/main.c
M Objects/codeobject.c
M Objects/interpreteridobject.c
M Objects/longobject.c
M Objects/moduleobject.c
M Parser/listnode.c
M Python/_warnings.c
M Python/codecs.c
M Python/dynload_shlib.c
M Python/import.c
M Python/initconfig.c
M Python/preconfig.c
M Python/sysmodule.c
M Python/thread_nt.h
M Python/thread_pthread.h

diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index 811aada3dcb18..298018a872b1a 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 5c3d3cae235f4..7c0f24ac07d7f 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 748aa63a43063..2e783781ada60 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 e2bb14ec728b4..9853699771a75 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 <stddef.h>              // offsetof()
 
 static PyObject *ThreadError;
 static PyObject *str_dict;
diff --git a/Modules/main.c b/Modules/main.c
index 00a0fc3ece401..a9de70b6b09ea 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 1820d8c8a5688..7cb72ceab4480 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 3f316873ed516..84fd85845207a 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 a66e1c49241af..a0bb6bc52be02 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 <float.h>
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 30adc92acf660..acb920a4c0714 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 d431ae537e3b4..f53b265efe6cb 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 e4dfb7391eaf1..d005f12910b48 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 7b35ded2edcd5..66919856ced84 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 <ctype.h>
diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c
index 360387113366f..223e0d03f680e 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 d79fa18e30898..3bf8fe0581ef0 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 e63d6f64f3321..43e0ccb09b7c2 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 89a6227fa6721..db328759c13a1 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 <locale.h>       /* setlocale() */
+#include "pycore_initconfig.h"
+#include "pycore_pymem.h"      // _PyMem_GetAllocatorName()
+#include "pycore_pystate.h"    // _PyRuntime_Initialize()
+#include <locale.h>            // setlocale()
 
 
 #define DECODE_LOCALE_ERR(NAME, LEN) \
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index fd0a9c0bf576c..814e4abad58e2 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 23d585cf9fa6c..e4bd0f70581ee 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 at elsa.preseco.comm.se */
 /* Fast NonRecursiveMutex support by Yakov Markovitch, markovitch at iso.ru */
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index e3497e7d595b1..440d845312a7d 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 */
 



More information about the Python-checkins mailing list