gh-127196: Fix crash in _interpreters, when shared had invalid encodings (#127220)

This commit is contained in:
sobolevn 2025-01-09 22:45:35 +03:00 committed by GitHub
parent 8af5781094
commit 087bb48aca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 2 deletions

View file

@ -459,7 +459,12 @@ _run_in_interpreter(PyInterpreterState *interp,
// Prep and switch interpreters.
if (_PyXI_Enter(&session, interp, shareables) < 0) {
assert(!PyErr_Occurred());
if (PyErr_Occurred()) {
// If an error occured at this step, it means that interp
// was not prepared and switched.
return -1;
}
// Now, apply the error from another interpreter:
PyObject *excinfo = _PyXI_ApplyError(session.error);
if (excinfo != NULL) {
*p_excinfo = excinfo;