diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index e80dd30c89dfd0..9145f0bfc4d7d7 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -2056,10 +2056,10 @@ new_interpreter(PyThreadState **tstate_p, const _PyInterpreterConfig *config) /* 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; }