Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-98608: Fix Failure-handling in new_interpreter() (gh-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 gh-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.

(cherry picked from commit d1b883b)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
https: //github.com//issues/98608
  • Loading branch information
ericsnowcurrently authored and miss-islington committed Mar 21, 2023
commit 4a8445dd02f59282ba05adaa71a8316d37538e5e
2 changes: 1 addition & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down