Revert "bpo-36818: Add PyInterpreterState.runtime field. (gh-13129)" (GH-13795)
This reverts commit 396e0a8d9dc65453cb9d53500d0a620602656cfe.
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 74e7fc9..94b0809 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -110,9 +110,9 @@
* if the thread holds the last reference to the lock, decref'ing the
* lock will delete the lock, and that may trigger arbitrary Python code
* if there's a weakref, with a callback, to the lock. But by this time
- * _PyRuntimeState.gilstate.tstate_current is already NULL, so only the
- * simplest of C code can be allowed to run (in particular it must not be
- * possible to release the GIL).
+ * _PyRuntime.gilstate.tstate_current is already NULL, so only the simplest
+ * of C code can be allowed to run (in particular it must not be possible to
+ * release the GIL).
* So instead of holding the lock directly, the tstate holds a weakref to
* the lock: that's the value of on_delete_data below. Decref'ing a
* weakref is harmless.
diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h
index 1c5beb0..81548f8 100644
--- a/Include/internal/pycore_object.h
+++ b/Include/internal/pycore_object.h
@@ -19,10 +19,9 @@
* NB: While the object is tracked by the collector, it must be safe to call the
* ob_traverse method.
*
- * Internal note: _PyRuntimeState.gc.generation0->_gc_prev doesn't have
- * any bit flags because it's not object header. So we don't use
- * _PyGCHead_PREV() and _PyGCHead_SET_PREV() for it to avoid unnecessary
- * bitwise operations.
+ * Internal note: _PyRuntime.gc.generation0->_gc_prev doesn't have any bit flags
+ * because it's not object header. So we don't use _PyGCHead_PREV() and
+ * _PyGCHead_SET_PREV() for it to avoid unnecessary bitwise operations.
*
* The PyObject_GC_Track() function is the public version of this macro.
*/
diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h
index e303417..8a692ea 100644
--- a/Include/internal/pycore_pylifecycle.h
+++ b/Include/internal/pycore_pylifecycle.h
@@ -39,10 +39,13 @@
extern int _PyTraceMalloc_Init(int enable);
extern PyObject * _PyBuiltin_Init(void);
extern PyStatus _PySys_Create(
+ _PyRuntimeState *runtime,
PyInterpreterState *interp,
PyObject **sysmod_p);
extern PyStatus _PySys_SetPreliminaryStderr(PyObject *sysdict);
-extern int _PySys_InitMain(PyInterpreterState *interp);
+extern int _PySys_InitMain(
+ _PyRuntimeState *runtime,
+ PyInterpreterState *interp);
extern PyStatus _PyImport_Init(PyInterpreterState *interp);
extern PyStatus _PyExc_Init(void);
extern PyStatus _PyErr_Init(void);
@@ -83,7 +86,10 @@
extern int _PyTraceMalloc_Fini(void);
extern void _PyWarnings_Fini(PyInterpreterState *interp);
-extern void _PyGILState_Init(PyThreadState *tstate);
+extern void _PyGILState_Init(
+ _PyRuntimeState *runtime,
+ PyInterpreterState *interp,
+ PyThreadState *tstate);
extern void _PyGILState_Fini(_PyRuntimeState *runtime);
PyAPI_FUNC(void) _PyGC_DumpShutdownStats(_PyRuntimeState *runtime);
diff --git a/Include/internal/pycore_pystate.h b/Include/internal/pycore_pystate.h
index 520a74b..3ab4009 100644
--- a/Include/internal/pycore_pystate.h
+++ b/Include/internal/pycore_pystate.h
@@ -19,9 +19,6 @@
#include "pycore_pymem.h"
#include "pycore_warnings.h"
-// forward
-struct pyruntimestate;
-
/* ceval state */
@@ -71,7 +68,6 @@
struct _is *next;
struct _ts *tstate_head;
- struct pyruntimestate *runtime;
int64_t id;
int64_t id_refcount;
@@ -300,8 +296,12 @@
/* Other */
-PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *tstate);
-PyAPI_FUNC(void) _PyThreadState_DeleteExcept(PyThreadState *tstate);
+PyAPI_FUNC(void) _PyThreadState_Init(
+ _PyRuntimeState *runtime,
+ PyThreadState *tstate);
+PyAPI_FUNC(void) _PyThreadState_DeleteExcept(
+ _PyRuntimeState *runtime,
+ PyThreadState *tstate);
PyAPI_FUNC(PyThreadState *) _PyThreadState_Swap(
struct _gilstate_runtime_state *gilstate,