diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-06-26 21:32:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-26 21:32:00 (GMT) |
commit | c052b192aaa05eeedb1bd50e0658e2d836ffa581 (patch) | |
tree | e1be65bbf070f16e1299c6542588ff78984fd484 /Python/pystate.c | |
parent | bc515b332bef0eaa3064d3b912ad660932ad8c90 (diff) | |
download | cpython-c052b192aaa05eeedb1bd50e0658e2d836ffa581.zip cpython-c052b192aaa05eeedb1bd50e0658e2d836ffa581.tar.gz cpython-c052b192aaa05eeedb1bd50e0658e2d836ffa581.tar.bz2 |
[3.13] gh-120838: Add _PyThreadState_WHENCE_FINI (gh-121013)
We also add _PyThreadState_NewBound() and drop _PyThreadState_SetWhence().
This change only affects internal API.
(cherry picked from commit a905721b9c5c15279e67c2f7785034b7356b2d46, AKA gh-121010)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Diffstat (limited to 'Python/pystate.c')
-rw-r--r-- | Python/pystate.c | 14 |
1 files changed, 9 insertions, 5 deletions
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 |