diff options
author | Victor Stinner <vstinner@python.org> | 2019-11-20 10:17:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-20 10:17:17 (GMT) |
commit | 9da7430675ceaeae5abeb9c9f7cd552b71b3a93a (patch) | |
tree | f78a3703f3d8ca26714e1f20cc08df9102f60eab /Python/pylifecycle.c | |
parent | d51a363a4379385fdfe9c09a56324631465ede29 (diff) | |
download | cpython-9da7430675ceaeae5abeb9c9f7cd552b71b3a93a.zip cpython-9da7430675ceaeae5abeb9c9f7cd552b71b3a93a.tar.gz cpython-9da7430675ceaeae5abeb9c9f7cd552b71b3a93a.tar.bz2 |
bpo-36854: Clear the current thread later (GH-17279)
Clear the current thread later in the Python finalization.
* The PyInterpreterState_Delete() function is now responsible
to call PyThreadState_Swap(NULL).
* The tstate_delete_common() function is now responsible to clear the
"autoTSSKey" thread local storage and it only clears it once the
thread state is fully cleared. It allows to still get the current
thread from TSS in tstate_delete_common().
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 2975b3e..73114df 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -1226,9 +1226,6 @@ finalize_interp_delete(PyThreadState *tstate, int is_main_interp) _PyGILState_Fini(tstate); } - /* Delete current thread. After this, many C API calls become crashy. */ - PyThreadState_Swap(NULL); - PyInterpreterState_Delete(tstate->interp); } @@ -1577,9 +1574,9 @@ handle_error: PyErr_PrintEx(0); PyThreadState_Clear(tstate); - PyThreadState_Swap(save_tstate); PyThreadState_Delete(tstate); PyInterpreterState_Delete(interp); + PyThreadState_Swap(save_tstate); *tstate_p = NULL; return _PyStatus_OK(); |