summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2022-11-09 21:55:20 (GMT)
committerGitHub <noreply@github.com>2022-11-09 21:55:20 (GMT)
commit283ab0e1c002f2d7459d581df6b4b8599e7d1a4d (patch)
tree15460072aff7041886d8e09b37c09c4051bddf40 /Python/pystate.c
parent58ee5d8677fbd4c6c58b7a78117835bccede6bcd (diff)
downloadcpython-283ab0e1c002f2d7459d581df6b4b8599e7d1a4d.zip
cpython-283ab0e1c002f2d7459d581df6b4b8599e7d1a4d.tar.gz
cpython-283ab0e1c002f2d7459d581df6b4b8599e7d1a4d.tar.bz2
GH-99205: Mark new interpreters and threads as non-static (GH-99268)
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index dd6d6e9..df0f4e2 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -356,6 +356,7 @@ PyInterpreterState_New(void)
interp = &runtime->_main_interpreter;
assert(interp->id == 0);
assert(interp->next == NULL);
+ assert(interp->_static);
interpreters->main = interp;
}
@@ -370,6 +371,9 @@ PyInterpreterState_New(void)
// Set to _PyInterpreterState_INIT.
memcpy(interp, &initial._main_interpreter,
sizeof(*interp));
+ // We need to adjust any fields that are different from the initial
+ // interpreter (as defined in _PyInterpreterState_INIT):
+ interp->_static = false;
if (id < 0) {
/* overflow or Py_Initialize() not called yet! */
@@ -837,6 +841,7 @@ new_threadstate(PyInterpreterState *interp)
assert(id == 1);
used_newtstate = 0;
tstate = &interp->_initial_thread;
+ assert(tstate->_static);
}
else {
// Every valid interpreter must have at least one thread.
@@ -848,6 +853,9 @@ new_threadstate(PyInterpreterState *interp)
memcpy(tstate,
&initial._main_interpreter._initial_thread,
sizeof(*tstate));
+ // We need to adjust any fields that are different from the initial
+ // thread (as defined in _PyThreadState_INIT):
+ tstate->_static = false;
}
interp->threads.head = tstate;