summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/crossinterp.c6
-rw-r--r--Python/import.c4
-rw-r--r--Python/pylifecycle.c4
-rw-r--r--Python/pystate.c14
4 files changed, 15 insertions, 13 deletions
diff --git a/Python/crossinterp.c b/Python/crossinterp.c
index 367e29d..a03456a 100644
--- a/Python/crossinterp.c
+++ b/Python/crossinterp.c
@@ -1544,8 +1544,7 @@ _enter_session(_PyXI_session *session, PyInterpreterState *interp)
PyThreadState *tstate = PyThreadState_Get();
PyThreadState *prev = tstate;
if (interp != tstate->interp) {
- tstate = PyThreadState_New(interp);
- _PyThreadState_SetWhence(tstate, _PyThreadState_WHENCE_EXEC);
+ tstate = _PyThreadState_NewBound(interp, _PyThreadState_WHENCE_EXEC);
// XXX Possible GILState issues?
session->prev_tstate = PyThreadState_Swap(tstate);
assert(session->prev_tstate == prev);
@@ -1895,8 +1894,7 @@ _PyXI_EndInterpreter(PyInterpreterState *interp,
tstate = cur_tstate;
}
else {
- tstate = PyThreadState_New(interp);
- _PyThreadState_SetWhence(tstate, _PyThreadState_WHENCE_INTERP);
+ tstate = _PyThreadState_NewBound(interp, _PyThreadState_WHENCE_FINI);
assert(tstate != NULL);
save_tstate = PyThreadState_Swap(tstate);
}
diff --git a/Python/import.c b/Python/import.c
index 366c016..20ad100 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1518,11 +1518,11 @@ switch_to_main_interpreter(PyThreadState *tstate)
if (_Py_IsMainInterpreter(tstate->interp)) {
return tstate;
}
- PyThreadState *main_tstate = PyThreadState_New(_PyInterpreterState_Main());
+ PyThreadState *main_tstate = _PyThreadState_NewBound(
+ _PyInterpreterState_Main(), _PyThreadState_WHENCE_EXEC);
if (main_tstate == NULL) {
return NULL;
}
- main_tstate->_whence = _PyThreadState_WHENCE_EXEC;
#ifndef NDEBUG
PyThreadState *old_tstate = PyThreadState_Swap(main_tstate);
assert(old_tstate == tstate);
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index a7b4d7e..9b599cb 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -677,7 +677,7 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
}
PyThreadState *tstate = _PyThreadState_New(interp,
- _PyThreadState_WHENCE_INTERP);
+ _PyThreadState_WHENCE_INIT);
if (tstate == NULL) {
return _PyStatus_ERR("can't make first thread");
}
@@ -2233,7 +2233,7 @@ new_interpreter(PyThreadState **tstate_p,
goto error;
}
- tstate = _PyThreadState_New(interp, _PyThreadState_WHENCE_INTERP);
+ tstate = _PyThreadState_New(interp, _PyThreadState_WHENCE_INIT);
if (tstate == NULL) {
status = _PyStatus_NO_MEMORY();
goto error;
diff --git a/Python/pystate.c b/Python/pystate.c
index 8d31a4d..602b13e 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -1293,9 +1293,8 @@ _PyInterpreterState_IDDecref(PyInterpreterState *interp)
PyThread_release_lock(interp->id_mutex);
if (refcount == 0 && interp->requires_idref) {
- PyThreadState *tstate = _PyThreadState_New(interp,
- _PyThreadState_WHENCE_INTERP);
- _PyThreadState_Bind(tstate);
+ PyThreadState *tstate =
+ _PyThreadState_NewBound(interp, _PyThreadState_WHENCE_FINI);
// XXX Possible GILState issues?
PyThreadState *save_tstate = _PyThreadState_Swap(runtime, tstate);
@@ -1603,8 +1602,13 @@ new_threadstate(PyInterpreterState *interp, int whence)
PyThreadState *
PyThreadState_New(PyInterpreterState *interp)
{
- PyThreadState *tstate = new_threadstate(interp,
- _PyThreadState_WHENCE_UNKNOWN);
+ return _PyThreadState_NewBound(interp, _PyThreadState_WHENCE_UNKNOWN);
+}
+
+PyThreadState *
+_PyThreadState_NewBound(PyInterpreterState *interp, int whence)
+{
+ PyThreadState *tstate = new_threadstate(interp, whence);
if (tstate) {
bind_tstate(tstate);
// This makes sure there's a gilstate tstate bound