Issue #10077: Fix logging of site module errors at startup.
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index d08d0ed..98cad37 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -721,14 +721,17 @@
         if (f == NULL || f == Py_None)
             return;
         if (Py_VerboseFlag) {
+            PyObject *type, *value, *traceback;
+            PyErr_Fetch(&type, &value, &traceback);
             PyFile_WriteString(
                 "'import site' failed; traceback:\n", f);
+            PyErr_Restore(type, value, traceback);
             PyErr_Print();
         }
         else {
+            PyErr_Clear();
             PyFile_WriteString(
               "'import site' failed; use -v for traceback\n", f);
-            PyErr_Clear();
         }
     }
     else {