Issue #5319: Print an error if flushing stdout fails at interpreter
shutdown.
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 79a19f8..233fc16 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -320,7 +320,7 @@
     if (fout != NULL && fout != Py_None) {
         tmp = PyObject_CallMethod(fout, "flush", "");
         if (tmp == NULL)
-            PyErr_Clear();
+            PyErr_WriteUnraisable(fout);
         else
             Py_DECREF(tmp);
     }