Skip to content

Commit

Permalink
pythongh-98608: Fix Failure-handling in new_interpreter() (pythongh-1…
Browse files Browse the repository at this point in the history
…02658)

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
  • Loading branch information
ericsnowcurrently authored and warsaw committed Apr 11, 2023
1 parent 830792c commit 45f7d84
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -2062,10 +2062,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;
}
Expand Down

0 comments on commit 45f7d84

Please sign in to comment.