gh-103176: sys._current_exceptions() returns mapping to exception instances instead of exc_info tuples (#103177)

This commit is contained in:
Irit Katriel 2023-04-11 09:38:37 +01:00 committed by GitHub
parent 8026cda10c
commit 78b763f630
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 10 deletions

View file

@ -1986,14 +1986,13 @@ _PyThread_CurrentExceptions(void)
if (id == NULL) {
goto fail;
}
PyObject *exc_info = _PyErr_StackItemToExcInfoTuple(err_info);
if (exc_info == NULL) {
Py_DECREF(id);
goto fail;
}
int stat = PyDict_SetItem(result, id, exc_info);
PyObject *exc = err_info->exc_value;
assert(exc == NULL ||
exc == Py_None ||
PyExceptionInstance_Check(exc));
int stat = PyDict_SetItem(result, id, exc == NULL ? Py_None : exc);
Py_DECREF(id);
Py_DECREF(exc_info);
if (stat < 0) {
goto fail;
}