mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
bpo-36829: sys.excepthook and sys.unraisablehook flush (GH-13620)
sys.excepthook() and sys.unraisablehook() now explicitly flush the file (usually sys.stderr). If file.flush() fails, sys.excepthook() silently ignores the error, whereas sys.unraisablehook() logs the new exception.
This commit is contained in:
@@ -978,6 +978,16 @@ _PyErr_Display(PyObject *file, PyObject *exception, PyObject *value, PyObject *t
|
||||
}
|
||||
print_exception_recursive(file, value, seen);
|
||||
Py_XDECREF(seen);
|
||||
|
||||
/* Call file.flush() */
|
||||
PyObject *res = _PyObject_CallMethodId(file, &PyId_flush, NULL);
|
||||
if (!res) {
|
||||
/* Silently ignore file.flush() error */
|
||||
PyErr_Clear();
|
||||
}
|
||||
else {
|
||||
Py_DECREF(res);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user