Skip to content

Commit ac24ffa

Browse files
ericsnowcurrentlyFidget-Spinner
authored andcommitted
pythongh-98608: Fix Failure-handling in new_interpreter() (pythongh-102658)
The error-handling code in new_interpreter() has been broken for a while. We hadn't noticed because those code mostly doesn't fail. (I noticed while working on pythongh-101660.) The problem is that we try to clear/delete the newly-created thread/interpreter using itself, which just failed. The solution is to switch back to the calling thread state first. python#98608
1 parent 711256c commit ac24ffa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Python/pylifecycle.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2062,10 +2062,10 @@ new_interpreter(PyThreadState **tstate_p, const _PyInterpreterConfig *config)
20622062

20632063
/* Oops, it didn't work. Undo it all. */
20642064
PyErr_PrintEx(0);
2065+
PyThreadState_Swap(save_tstate);
20652066
PyThreadState_Clear(tstate);
20662067
PyThreadState_Delete(tstate);
20672068
PyInterpreterState_Delete(interp);
2068-
PyThreadState_Swap(save_tstate);
20692069

20702070
return status;
20712071
}

0 commit comments

Comments
 (0)