[Python-checkins] bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)

Victor Stinner webhook-mailer at python.org
Tue Apr 14 11:52:20 EDT 2020


https://github.com/python/cpython/commit/e5014be0497d06d78343623588a80f491a6f7b74
commit: e5014be0497d06d78343623588a80f491a6f7b74
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-04-14T17:52:15+02:00
summary:

bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)

files:
M Modules/_functoolsmodule.c
M Modules/_io/bufferedio.c
M Modules/_io/textio.c
M Modules/_threadmodule.c
M Modules/gcmodule.c
M Modules/getpath.c
M Modules/main.c
M Modules/posixmodule.c
M Modules/signalmodule.c
M Objects/abstract.c
M Objects/call.c
M Objects/cellobject.c
M Objects/classobject.c
M Objects/descrobject.c
M Objects/dictobject.c
M Objects/exceptions.c
M Objects/fileobject.c
M Objects/frameobject.c
M Objects/funcobject.c
M Objects/genobject.c
M Objects/interpreteridobject.c
M Objects/iterobject.c
M Objects/listobject.c
M Objects/memoryobject.c
M Objects/methodobject.c
M Objects/moduleobject.c
M Objects/object.c
M Objects/odictobject.c
M Objects/setobject.c
M Objects/sliceobject.c
M Objects/tupleobject.c
M Objects/typeobject.c
M Objects/unicodeobject.c
M PC/getpathp.c
M Parser/listnode.c
M Parser/myreadline.c
M Programs/_testembed.c
M Python/_warnings.c
M Python/bltinmodule.c
M Python/ceval.c
M Python/codecs.c
M Python/context.c
M Python/errors.c
M Python/frozenmain.c
M Python/hamt.c
M Python/import.c
M Python/initconfig.c
M Python/pathconfig.c
M Python/preconfig.c
M Python/pylifecycle.c
M Python/pystate.c
M Python/pythonrun.c
M Python/symtable.c
M Python/sysmodule.c
M Python/thread.c
M Python/traceback.c

diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index 2f1b47a5b061d..d9536bb4e92d0 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -1,6 +1,6 @@
 #include "Python.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"      // _PyThreadState_GET()
 #include "pycore_tupleobject.h"
 #include "structmember.h"
 
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 6e76db42c3a60..4ec42eb01082c 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -10,7 +10,6 @@
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 #include "pycore_object.h"
-#include "pycore_pystate.h"
 #include "structmember.h"
 #include "pythread.h"
 #include "_iomodule.h"
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 95b023d17908e..9e33c1ed17b0f 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -8,8 +8,9 @@
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
+#include "pycore_interp.h"      // PyInterpreterState.fs_codec
 #include "pycore_object.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"     // _PyInterpreterState_GET()
 #include "structmember.h"
 #include "_iomodule.h"
 
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index 5636140dde4d3..8ff06698a807c 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -5,7 +5,7 @@
 #include "Python.h"
 #include "pycore_pylifecycle.h"
 #include "pycore_interp.h"       // _PyInterpreterState.num_threads
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"      // _PyThreadState_Init()
 #include "pythread.h"
 #include <stddef.h>              // offsetof()
 
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 17541824761a1..281ab33e06523 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -26,13 +26,14 @@
 #include "Python.h"
 #include "pycore_context.h"
 #include "pycore_initconfig.h"
+#include "pycore_interp.h"      // PyInterpreterState.gc
 #include "pycore_object.h"
 #include "pycore_pyerrors.h"
+#include "pycore_pystate.h"     // _PyThreadState_GET()
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
-#include "frameobject.h"        /* for PyFrame_ClearFreeList */
+#include "frameobject.h"        // PyFrame_ClearFreeList
 #include "pydtrace.h"
-#include "pytime.h"             /* for _PyTime_GetMonotonicClock() */
+#include "pytime.h"             // _PyTime_GetMonotonicClock()
 
 typedef struct _gc_runtime_state GCState;
 
diff --git a/Modules/getpath.c b/Modules/getpath.c
index e97ea8b30799d..1dd8dd0134e7c 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -1,11 +1,10 @@
 /* Return the initial module search path. */
 
 #include "Python.h"
-#include "pycore_initconfig.h"
-#include "osdefs.h"
 #include "pycore_fileutils.h"
+#include "pycore_initconfig.h"
 #include "pycore_pathconfig.h"
-#include "pycore_pystate.h"
+#include "osdefs.h"
 
 #include <sys/types.h>
 #include <string.h>
diff --git a/Modules/main.c b/Modules/main.c
index fb24c6c6c2892..fa9c6b4eb9418 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -6,7 +6,7 @@
 #include "pycore_pathconfig.h"
 #include "pycore_pylifecycle.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"      // _PyInterpreterState_GET()
 
 /* Includes for exit_sigint() */
 #include <stdio.h>      /* perror() */
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 2d603d14e8df5..692dda314b304 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -37,7 +37,7 @@
 
 #include "pycore_ceval.h"     /* _PyEval_ReInitThreads() */
 #include "pycore_import.h"    /* _PyImport_ReInitLock() */
-#include "pycore_pystate.h"   /* _PyRuntime */
+#include "pycore_pystate.h"   /* _PyInterpreterState_GET() */
 #include "pythread.h"
 #include "structmember.h"
 #ifndef MS_WINDOWS
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index ceb986bddcbd3..69d69ace28ebb 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -8,7 +8,7 @@
 #include "pycore_call.h"
 #include "pycore_ceval.h"
 #include "pycore_pyerrors.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"    // _PyThreadState_GET()
 
 #ifndef MS_WINDOWS
 #include "posixmodule.h"
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 7e1e51b4c87c2..8e22dfeca99b4 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -4,7 +4,7 @@
 #include "pycore_abstract.h"   // _PyIndex_Check()
 #include "pycore_ceval.h"      // _Py_EnterRecursiveCall()
 #include "pycore_pyerrors.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"    // _PyThreadState_GET()
 #include <ctype.h>
 #include "structmember.h" /* we need the offsetof() macro from there */
 #include "longintrepr.h"
diff --git a/Objects/call.c b/Objects/call.c
index 0861414324609..61426c7e09e4e 100644
--- a/Objects/call.c
+++ b/Objects/call.c
@@ -1,9 +1,9 @@
 #include "Python.h"
 #include "pycore_call.h"
-#include "pycore_ceval.h"   /* _PyEval_EvalFrame() */
+#include "pycore_ceval.h"        // _PyEval_EvalFrame()
 #include "pycore_object.h"
 #include "pycore_pyerrors.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"      // _PyThreadState_GET()
 #include "pycore_tupleobject.h"
 #include "frameobject.h"
 
diff --git a/Objects/cellobject.c b/Objects/cellobject.c
index e97feefbf6d04..6efae626bf5b7 100644
--- a/Objects/cellobject.c
+++ b/Objects/cellobject.c
@@ -3,7 +3,6 @@
 #include "Python.h"
 #include "pycore_object.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
 
 PyObject *
 PyCell_New(PyObject *obj)
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 999b91c0a2dc8..ce4bf7b5ff97c 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -4,7 +4,7 @@
 #include "pycore_object.h"
 #include "pycore_pyerrors.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"   // _PyThreadState_GET()
 #include "structmember.h"
 
 #define TP_DESCR_GET(t) ((t)->tp_descr_get)
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 5fab222b82cae..fe7ba79770a6a 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1,9 +1,9 @@
 /* Descriptors -- a new, flexible way to describe attributes */
 
 #include "Python.h"
-#include "pycore_ceval.h"   // _Py_EnterRecursiveCall()
+#include "pycore_ceval.h"        // _Py_EnterRecursiveCall()
 #include "pycore_object.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"      // _PyThreadState_GET()
 #include "pycore_tupleobject.h"
 #include "structmember.h" /* Why is this not included in Python.h? */
 
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 60660adf897c3..8f9d4e7b73140 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -111,10 +111,11 @@ converting the dict to the combined table.
 #define PyDict_MINSIZE 8
 
 #include "Python.h"
+#include "pycore_gc.h"       // _PyObject_GC_IS_TRACKED()
 #include "pycore_object.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"  // _PyThreadState_GET()
 #include "dict-common.h"
-#include "stringlib/eq.h"    /* to get unicode_eq() */
+#include "stringlib/eq.h"    // unicode_eq()
 
 /*[clinic input]
 class dict "PyDictObject *" "&PyDict_Type"
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index dad177a1ab606..cb661f84ff2de 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -9,7 +9,6 @@
 #include "pycore_initconfig.h"
 #include "pycore_object.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
 #include "structmember.h"
 #include "osdefs.h"
 
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index b8ec56e994ca6..1c6ecaf82c24e 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -2,7 +2,7 @@
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
-#include "pycore_pystate.h"
+#include "pycore_runtime.h"  // _PyRuntime
 
 #if defined(HAVE_GETC_UNLOCKED) && !defined(_Py_MEMORY_SANITIZER)
 /* clang MemorySanitizer doesn't yet understand getc_unlocked. */
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 340267bd47907..3c140acad7ea6 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -2,7 +2,7 @@
 
 #include "Python.h"
 #include "pycore_object.h"
-#include "pycore_pystate.h"
+#include "pycore_gc.h"       // _PyObject_GC_IS_TRACKED()
 
 #include "code.h"
 #include "frameobject.h"
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 3ec949d573bf5..af6766fbd7a9f 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -4,7 +4,6 @@
 #include "Python.h"
 #include "pycore_object.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
 #include "pycore_tupleobject.h"
 #include "code.h"
 #include "structmember.h"
diff --git a/Objects/genobject.c b/Objects/genobject.c
index d3455f8dcd792..b1a749d140e82 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -1,9 +1,9 @@
 /* Generator object implementation */
 
 #include "Python.h"
-#include "pycore_ceval.h"   /* _PyEval_EvalFrame() */
+#include "pycore_ceval.h"     // _PyEval_EvalFrame()
 #include "pycore_object.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"   // _PyThreadState_GET()
 #include "frameobject.h"
 #include "structmember.h"
 #include "opcode.h"
diff --git a/Objects/interpreteridobject.c b/Objects/interpreteridobject.c
index 84fd85845207a..a250293a47277 100644
--- a/Objects/interpreteridobject.c
+++ b/Objects/interpreteridobject.c
@@ -3,7 +3,6 @@
 #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/iterobject.c b/Objects/iterobject.c
index fe1de7e211c5d..51104fbe9695f 100644
--- a/Objects/iterobject.c
+++ b/Objects/iterobject.c
@@ -3,7 +3,6 @@
 #include "Python.h"
 #include "pycore_object.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
 
 typedef struct {
     PyObject_HEAD
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 7058fe4396eec..7d2f006617ba5 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -3,7 +3,6 @@
 #include "Python.h"
 #include "pycore_abstract.h"   // _PyIndex_Check()
 #include "pycore_object.h"
-#include "pycore_pystate.h"
 #include "pycore_tupleobject.h"
 #include "pycore_accu.h"
 
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
index da06338017cae..4340f0675f163 100644
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -14,7 +14,6 @@
 #include "pycore_abstract.h"   // _PyIndex_Check()
 #include "pycore_object.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
 #include "pystrhex.h"
 #include <stddef.h>
 
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 44ae00f7e0023..4b4927db82094 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -2,11 +2,11 @@
 /* Method object implementation */
 
 #include "Python.h"
-#include "pycore_ceval.h"   // _Py_EnterRecursiveCall()
+#include "pycore_ceval.h"     // _Py_EnterRecursiveCall()
 #include "pycore_object.h"
 #include "pycore_pyerrors.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"   // _PyThreadState_GET()
 #include "structmember.h"
 
 /* undefine macro trampoline to PyCFunction_NewEx */
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 1f419ad08317e..499ce09ae6b5b 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -3,7 +3,7 @@
 
 #include "Python.h"
 #include "pycore_interp.h"    // PyInterpreterState.importlib
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"   // _PyInterpreterState_GET()
 #include "structmember.h"
 
 static Py_ssize_t max_module_number;
diff --git a/Objects/object.c b/Objects/object.c
index ef4ba997de427..4fa488e8d08b6 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -2,13 +2,13 @@
 /* Generic object operations; and implementation of None */
 
 #include "Python.h"
-#include "pycore_ceval.h"   // _Py_EnterRecursiveCall()
+#include "pycore_ceval.h"         // _Py_EnterRecursiveCall()
 #include "pycore_context.h"
 #include "pycore_initconfig.h"
 #include "pycore_object.h"
 #include "pycore_pyerrors.h"
 #include "pycore_pylifecycle.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "frameobject.h"
 #include "interpreteridobject.h"
 
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
index 220ae92ec9296..2fcaa47876513 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -466,7 +466,6 @@ Potential Optimizations
 
 #include "Python.h"
 #include "pycore_object.h"
-#include "pycore_pystate.h"
 #include "structmember.h"
 #include "dict-common.h"
 #include <stddef.h>
@@ -890,7 +889,7 @@ odict_inplace_or(PyObject *self, PyObject *other)
     if (mutablemapping_update_arg(self, other) < 0) {
         return NULL;
     }
-    Py_INCREF(self); 
+    Py_INCREF(self);
     return self;
 }
 
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 232ba6d97a070..0b15bedeb4ff3 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -32,8 +32,7 @@
 */
 
 #include "Python.h"
-#include "pycore_object.h"
-#include "pycore_pystate.h"
+#include "pycore_object.h"   // _PyObject_GC_UNTRACK()
 #include "structmember.h"
 
 /* Object used as dummy key to fill deleted entries */
diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c
index 4fd216388fdfd..0a5f00dbe0a39 100644
--- a/Objects/sliceobject.c
+++ b/Objects/sliceobject.c
@@ -17,7 +17,6 @@ this type and there is exactly one in existence.
 #include "pycore_abstract.h"   // _PyIndex_Check()
 #include "pycore_object.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
 #include "structmember.h"
 
 static PyObject *
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 110c0925ccd94..b65b8abc2806d 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -3,9 +3,9 @@
 
 #include "Python.h"
 #include "pycore_abstract.h"   // _PyIndex_Check()
-#include "pycore_object.h"
-#include "pycore_pystate.h"
 #include "pycore_accu.h"
+#include "pycore_gc.h"         // _PyObject_GC_IS_TRACKED()
+#include "pycore_object.h"
 
 /*[clinic input]
 class tuple "PyTupleObject *" "&PyTuple_Type"
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 209c6a554eedd..47766bf6fbbbf 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -5,7 +5,7 @@
 #include "pycore_initconfig.h"
 #include "pycore_object.h"
 #include "pycore_pyerrors.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"     // _PyThreadState_GET()
 #include "frameobject.h"
 #include "structmember.h"
 
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 28ec8f10dcb3d..51775df199d1e 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -40,14 +40,15 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
-#include "pycore_abstract.h"   // _PyIndex_Check()
+#include "pycore_abstract.h"       // _PyIndex_Check()
 #include "pycore_bytes_methods.h"
 #include "pycore_fileutils.h"
 #include "pycore_initconfig.h"
+#include "pycore_interp.h"         // PyInterpreterState.fs_codec
 #include "pycore_object.h"
 #include "pycore_pathconfig.h"
 #include "pycore_pylifecycle.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"        // _PyInterpreterState_GET()
 #include "ucnhash.h"
 #include "stringlib/eq.h"
 
diff --git a/PC/getpathp.c b/PC/getpathp.c
index aa820e57a9cb2..24a9323e6e67e 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -82,7 +82,6 @@
 #include "Python.h"
 #include "pycore_initconfig.h"   /* PyStatus */
 #include "pycore_pathconfig.h"   /* _PyPathConfig */
-#include "pycore_pystate.h"
 #include "osdefs.h"
 #include <wchar.h>
 
diff --git a/Parser/listnode.c b/Parser/listnode.c
index 3bcc03e93526a..c806b98e48c35 100644
--- a/Parser/listnode.c
+++ b/Parser/listnode.c
@@ -2,8 +2,8 @@
 /* List a node on a file */
 
 #include "Python.h"
-#include "pycore_interp.h"   // PyInterpreterState.parser
-#include "pycore_pystate.h"  // _PyInterpreterState_GET
+#include "pycore_interp.h"        // PyInterpreterState.parser
+#include "pycore_pystate.h"       // _PyInterpreterState_GET()
 #include "token.h"
 #include "node.h"
 
diff --git a/Parser/myreadline.c b/Parser/myreadline.c
index 43e5583b8bcc4..7da8ea8378065 100644
--- a/Parser/myreadline.c
+++ b/Parser/myreadline.c
@@ -10,10 +10,10 @@
 */
 
 #include "Python.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"   // _PyThreadState_GET()
 #ifdef MS_WINDOWS
-#define WIN32_LEAN_AND_MEAN
-#include "windows.h"
+#  define WIN32_LEAN_AND_MEAN
+#  include "windows.h"
 #endif /* MS_WINDOWS */
 
 
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index 900a4b1d427a6..da3e7861d1e80 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -6,8 +6,8 @@
 #undef NDEBUG
 
 #include <Python.h>
-#include "pycore_initconfig.h"   /* _PyConfig_InitCompatConfig() */
-#include "pycore_pystate.h"      /* _PyRuntime */
+#include "pycore_initconfig.h"    // _PyConfig_InitCompatConfig()
+#include "pycore_runtime.h"       // _PyRuntime
 #include <Python.h>
 #include "pythread.h"
 #include <inttypes.h>
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 0236cabdf11c2..f4ef0bb4b1214 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -2,7 +2,7 @@
 #include "pycore_initconfig.h"
 #include "pycore_interp.h"        // PyInterpreterState.warnings
 #include "pycore_pyerrors.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "frameobject.h"
 #include "clinic/_warnings.c.h"
 
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 8063c2186d3e6..a9fc21f108774 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -6,7 +6,7 @@
 #undef Yield   /* undefine macro conflicting with <winbase.h> */
 #include "pycore_object.h"
 #include "pycore_pyerrors.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"      // _PyThreadState_GET()
 #include "pycore_tupleobject.h"
 
 _Py_IDENTIFIER(__builtins__);
diff --git a/Python/ceval.c b/Python/ceval.c
index fc720b4ba403a..16e2d0b1fbea9 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -10,7 +10,7 @@
 #define PY_LOCAL_AGGRESSIVE
 
 #include "Python.h"
-#include "pycore_abstract.h"   // _PyIndex_Check()
+#include "pycore_abstract.h"     // _PyIndex_Check()
 #include "pycore_call.h"
 #include "pycore_ceval.h"
 #include "pycore_code.h"
@@ -18,7 +18,7 @@
 #include "pycore_object.h"
 #include "pycore_pyerrors.h"
 #include "pycore_pylifecycle.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"      // _PyInterpreterState_GET()
 #include "pycore_sysmodule.h"
 #include "pycore_tupleobject.h"
 
diff --git a/Python/codecs.c b/Python/codecs.c
index 32cc110d8ec13..0f18c27e5fe46 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -9,8 +9,8 @@ Copyright (c) Corporation for National Research Initiatives.
    ------------------------------------------------------------------------ */
 
 #include "Python.h"
-#include "pycore_interp.h"     // PyInterpreterState.codec_search_path
-#include "pycore_pystate.h"
+#include "pycore_interp.h"        // PyInterpreterState.codec_search_path
+#include "pycore_pystate.h"       // _PyInterpreterState_GET()
 #include "ucnhash.h"
 #include <ctype.h>
 
diff --git a/Python/context.c b/Python/context.c
index e0338c97e1873..00f25ddab41d1 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -1,10 +1,11 @@
 #include "Python.h"
 
 #include "pycore_context.h"
+#include "pycore_gc.h"            // _PyObject_GC_MAY_BE_TRACKED()
 #include "pycore_hamt.h"
 #include "pycore_object.h"
 #include "pycore_pyerrors.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "structmember.h"
 
 
diff --git a/Python/errors.c b/Python/errors.c
index a2fe52b812006..db007709d263e 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -4,7 +4,7 @@
 #include "Python.h"
 #include "pycore_initconfig.h"
 #include "pycore_pyerrors.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"    // _PyThreadState_GET()
 #include "pycore_sysmodule.h"
 #include "pycore_traceback.h"
 
diff --git a/Python/frozenmain.c b/Python/frozenmain.c
index 508721b855902..dd04d609d24f9 100644
--- a/Python/frozenmain.c
+++ b/Python/frozenmain.c
@@ -2,7 +2,7 @@
 /* Python interpreter main program for frozen scripts */
 
 #include "Python.h"
-#include "pycore_pystate.h"
+#include "pycore_runtime.h"  // _PyRuntime_Initialize()
 #include <locale.h>
 
 #ifdef MS_WINDOWS
diff --git a/Python/hamt.c b/Python/hamt.c
index 729981033f4a7..9924e3351243e 100644
--- a/Python/hamt.c
+++ b/Python/hamt.c
@@ -1,8 +1,7 @@
 #include "Python.h"
 
 #include "pycore_hamt.h"
-#include "pycore_object.h"
-#include "pycore_pystate.h"
+#include "pycore_object.h"   // _PyObject_GC_TRACK()
 #include "structmember.h"
 
 /*
diff --git a/Python/import.c b/Python/import.c
index 042691d30b0de..8a2f9de066a68 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -9,8 +9,8 @@
 #include "pycore_pyhash.h"
 #include "pycore_pylifecycle.h"
 #include "pycore_pymem.h"
-#include "pycore_interp.h"       // _PyInterpreterState_ClearModules()
-#include "pycore_pystate.h"
+#include "pycore_interp.h"        // _PyInterpreterState_ClearModules()
+#include "pycore_pystate.h"       // _PyInterpreterState_GET()
 #include "pycore_sysmodule.h"
 #include "errcode.h"
 #include "marshal.h"
diff --git a/Python/initconfig.c b/Python/initconfig.c
index 43e0ccb09b7c2..201d930f7d8d2 100644
--- a/Python/initconfig.c
+++ b/Python/initconfig.c
@@ -1,25 +1,25 @@
 #include "Python.h"
-#include "osdefs.h"       /* DELIM */
+#include "osdefs.h"               // DELIM
 #include "pycore_fileutils.h"
 #include "pycore_getopt.h"
 #include "pycore_initconfig.h"
-#include "pycore_interp.h"    // _PyInterpreterState.runtime
+#include "pycore_interp.h"        // _PyInterpreterState.runtime
 #include "pycore_pathconfig.h"
 #include "pycore_pyerrors.h"
 #include "pycore_pylifecycle.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"   /* _PyRuntime */
-#include <locale.h>       /* setlocale() */
+#include "pycore_pystate.h"       // _PyThreadState_GET()
+#include <locale.h>               // setlocale()
 #ifdef HAVE_LANGINFO_H
-#  include <langinfo.h>   /* nl_langinfo(CODESET) */
+#  include <langinfo.h>           // nl_langinfo(CODESET)
 #endif
 #if defined(MS_WINDOWS) || defined(__CYGWIN__)
-#  include <windows.h>    /* GetACP() */
+#  include <windows.h>            // GetACP()
 #  ifdef HAVE_IO_H
 #    include <io.h>
 #  endif
 #  ifdef HAVE_FCNTL_H
-#    include <fcntl.h>    /* O_BINARY */
+#    include <fcntl.h>            // O_BINARY
 #  endif
 #endif
 
diff --git a/Python/pathconfig.c b/Python/pathconfig.c
index aa1d6f8139bcc..1515926531a1c 100644
--- a/Python/pathconfig.c
+++ b/Python/pathconfig.c
@@ -6,8 +6,10 @@
 #include "pycore_fileutils.h"
 #include "pycore_pathconfig.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
 #include <wchar.h>
+#ifdef MS_WINDOWS
+#  include <windows.h>            // GetFullPathNameW(), MAX_PATH
+#endif
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/Python/preconfig.c b/Python/preconfig.c
index db328759c13a1..531d8d0df3504 100644
--- a/Python/preconfig.c
+++ b/Python/preconfig.c
@@ -2,7 +2,7 @@
 #include "pycore_getopt.h"
 #include "pycore_initconfig.h"
 #include "pycore_pymem.h"      // _PyMem_GetAllocatorName()
-#include "pycore_pystate.h"    // _PyRuntime_Initialize()
+#include "pycore_runtime.h"    // _PyRuntime_Initialize()
 #include <locale.h>            // setlocale()
 
 
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index ac0ea107bcf90..754e7620a0cc0 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -6,7 +6,7 @@
 #undef Yield   /* undefine macro conflicting with <winbase.h> */
 #include "pycore_ceval.h"
 #include "pycore_context.h"
-#include "pycore_import.h"   /* _PyImport_FindBuiltin */
+#include "pycore_import.h"        // _PyImport_Cleanup()
 #include "pycore_initconfig.h"
 #include "pycore_fileutils.h"
 #include "pycore_hamt.h"
@@ -15,7 +15,7 @@
 #include "pycore_pyerrors.h"
 #include "pycore_pylifecycle.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_sysmodule.h"
 #include "pycore_traceback.h"
 #include "grammar.h"
diff --git a/Python/pystate.c b/Python/pystate.c
index 65d46a2bb4248..3c427c1210714 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -7,7 +7,7 @@
 #include "pycore_pyerrors.h"
 #include "pycore_pylifecycle.h"
 #include "pycore_pymem.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_sysmodule.h"
 
 /* --------------------------------------------------------------------------
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index d1165e2b4d2f3..246669994c4dd 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -12,10 +12,11 @@
 
 #include "Python-ast.h"
 #undef Yield   /* undefine macro conflicting with <winbase.h> */
+#include "pycore_interp.h"        // PyInterpreterState.importlib
 #include "pycore_object.h"
 #include "pycore_pyerrors.h"
 #include "pycore_pylifecycle.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"       // _PyInterpreterState_GET()
 #include "pycore_sysmodule.h"
 #include "grammar.h"
 #include "node.h"
diff --git a/Python/symtable.c b/Python/symtable.c
index 014570e6ef78f..a3c5d650d1edc 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -1,5 +1,5 @@
 #include "Python.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"   // _PyThreadState_GET()
 #include "symtable.h"
 #undef Yield   /* undefine macro conflicting with <winbase.h> */
 #include "structmember.h"
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 6b3a1c38b9d9b..79e5df06d3037 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -18,13 +18,12 @@ Data members:
 #include "code.h"
 #include "frameobject.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"
 #include "pycore_pylifecycle.h"
 #include "pycore_pymem.h"
+#include "pycore_pystate.h"      // _PyThreadState_GET()
 #include "pycore_tupleobject.h"
 #include "pythread.h"
 #include "pydtrace.h"
diff --git a/Python/thread.c b/Python/thread.c
index bac0e6992ae02..127610318663d 100644
--- a/Python/thread.c
+++ b/Python/thread.c
@@ -6,7 +6,7 @@
    Stuff shared by all thread_*.h files is collected here. */
 
 #include "Python.h"
-#include "pycore_pystate.h"
+#include "pycore_pystate.h"   // _PyInterpreterState_GET()
 
 #ifndef _POSIX_THREADS
 /* This means pthreads are not implemented in libc headers, hence the macro
diff --git a/Python/traceback.c b/Python/traceback.c
index 2167e07a9b85d..610c2172ef833 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -2,7 +2,6 @@
 /* Traceback implementation */
 
 #include "Python.h"
-#include "pycore_pystate.h"
 
 #include "code.h"
 #include "frameobject.h"



More information about the Python-checkins mailing list