Closed
Description
Feature or enhancement
In general, when _PyThreadState_GET()
is non-NULL then the current thread is "attached", but there is a small window during PyThreadState_DeleteCurrent()
where that's not true: tstate_delete_common() is called when the thread is detached, but before current_fast_clear():
Lines 1689 to 1691 in 601f3a7
I think it's worth swapping the order of the calls so that we call current_fast_clear
before tstate_delete_common
. This would also make the order of operations in PyThreadState_DeleteCurrent()
more similar to the order used when calling PyThreadState_Delete()
.
See also: #116483