gh-110912: Correctly display tracebacks for MemoryError exceptions using the traceback module (#110921)

This commit is contained in:
Pablo Galindo Salgado 2023-10-16 15:39:23 +01:00 committed by GitHub
parent bad7a35055
commit b3c9faf056
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View file

@ -1031,6 +1031,7 @@ error:
void
_PyErr_Display(PyObject *file, PyObject *unused, PyObject *value, PyObject *tb)
{
assert(value != NULL);
assert(file != NULL && file != Py_None);
if (PyExceptionInstance_Check(value)
&& tb != NULL && PyTraceBack_Check(tb)) {
@ -1047,10 +1048,6 @@ _PyErr_Display(PyObject *file, PyObject *unused, PyObject *value, PyObject *tb)
int unhandled_keyboard_interrupt = _PyRuntime.signals.unhandled_keyboard_interrupt;
if (!value || PyErr_GivenExceptionMatches(value, PyExc_MemoryError)) {
goto fallback;
}
// Try first with the stdlib traceback module
PyObject *traceback_module = PyImport_ImportModule("traceback");