Skip to content

Commit 4b446e7

Browse files
committed
Close owned guards before deleting them, not after.
Claude pointed this out as an issue. I think it makes some sense.
1 parent 5f1d2e0 commit 4b446e7

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Python/pystate.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3570,15 +3570,15 @@ PyThreadState_Release(PyThreadStateToken *token)
35703570
PyThreadState_Clear(tstate);
35713571
}
35723572

3573+
if (owned_guard != NULL) {
3574+
PyInterpreterGuard_Close(owned_guard);
3575+
}
3576+
35733577
PyThreadState *check_tstate = PyThreadState_Swap(to_restore);
35743578
(void)check_tstate;
35753579
assert(check_tstate == tstate);
35763580

35773581
if (tstate->ensure.delete_on_release) {
35783582
PyThreadState_Delete(tstate);
35793583
}
3580-
3581-
if (owned_guard != NULL) {
3582-
PyInterpreterGuard_Close(owned_guard);
3583-
}
35843584
}

0 commit comments

Comments
 (0)