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

diff --git a/Objects/abstract.c b/Objects/abstract.c
index 7e1e51b..8e22dfe 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 0861414..61426c7 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 e97feef..6efae62 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 999b91c..ce4bf7b 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 5fab222..fe7ba79 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 60660ad..8f9d4e7 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -111,10 +111,11 @@
 #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 dad177a..cb661f8 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 b8ec56e..1c6ecaf 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 340267b..3c140ac 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 3ec949d..af6766f 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 d3455f8..b1a749d 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 84fd858..a250293 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 fe1de7e..51104fb 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 7058fe4..7d2f006 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 da06338..4340f06 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 44ae00f..4b4927d 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 1f419ad..499ce09a 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 ef4ba99..4fa488e 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 220ae92..2fcaa47 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -466,7 +466,6 @@
 
 #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 @@
     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 232ba6d..0b15bed 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 4fd2163..0a5f00d 100644
--- a/Objects/sliceobject.c
+++ b/Objects/sliceobject.c
@@ -17,7 +17,6 @@
 #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 110c092..b65b8ab 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 209c6a5..47766bf 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 28ec8f1..51775df 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -40,14 +40,15 @@
 
 #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"