8000 gh-109700: fix interp finalization while handling memory error by kumaraditya303 · Pull Request #136342 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-109700: fix interp finalization while handling memory error #136342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2025
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
14 changes: 7 additions & 7 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1702,8 +1702,10 @@ finalize_modules(PyThreadState *tstate)
#endif

// Stop watching __builtin__ modifications
PyDict_Unwatch(0, interp->builtins);

if (PyDict_Unwatch(0, interp->builtins) < 0) {
// might happen if interp is cleared before watching the __builtin__
PyErr_Clear();
}
PyObject *modules = _PyImport_GetModules(interp);
if (modules == NULL) {
// Already done
Expand Down Expand Up @@ -2377,15 +2379,13 @@ new_interpreter(PyThreadState **tstate_p,
error:
*tstate_p = NULL;
if (tstate != NULL) {
PyThreadState_Clear(tstate);
_PyThreadState_Detach(tstate);
PyThreadState_Delete(tstate);
Py_EndInterpreter(tstate);
} else {
PyInterpreterState_Delete(interp);
}
if (save_tstate != NULL) {
_PyThreadState_Attach(save_tstate);
}
PyInterpreterState_Delete(interp);

return status;
}

Expand Down
Loading
0