[3.11] gh-113358 Fix rendering tracebacks with exceptions with a broken __getattr__ : Normalize exception (#114379)

This commit is contained in:
Jérome Perrin 2024-01-22 02:25:55 +09:00 committed by GitHub
parent d2cfb5b258
commit 3bd4c3a86c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1206,6 +1206,7 @@ get_exception_notes(struct exception_print_context *ctx, PyObject *value, PyObje
if (_PyObject_LookupAttr(value, &_Py_ID(__notes__), notes) < 0) {
PyObject *type, *errvalue, *tback;
PyErr_Fetch(&type, &errvalue, &tback);
PyErr_NormalizeException(&type, &errvalue, &tback);
note = PyUnicode_FromFormat("Ignored error getting __notes__: %R", errvalue);
Py_XDECREF(type);
Py_XDECREF(errvalue);