diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index eeaf20b4617a20..b0c5da56c4fff9 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -1962,10 +1962,10 @@ new_interpreter(PyThreadState **tstate_p, int isolated_subinterpreter) /* Oops, it didn't work. Undo it all. */ PyErr_PrintEx(0); + PyThreadState_Swap(save_tstate); PyThreadState_Clear(tstate); PyThreadState_Delete(tstate); PyInterpreterState_Delete(interp); - PyThreadState_Swap(save_tstate); return status; }