diff options
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index ba1d1cf02f..ace9f2f987 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -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 |