]> granicus.if.org Git - python/commitdiff
Issue #10077: Fix logging of site module errors at startup.
authorVictor Stinner <victor.stinner@haypocalc.com>
Sat, 23 Oct 2010 08:50:36 +0000 (08:50 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sat, 23 Oct 2010 08:50:36 +0000 (08:50 +0000)
Misc/NEWS
Python/pythonrun.c

index 9797b91e8beaa187e87730a989b92ea425ad7167..e2c424c25dedaf07fd1475a329415a17cc046437 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ What's New in Python 3.1.3?
 Core and Builtins
 -----------------
 
+- Issue #10077: Fix logging of site module errors at startup.
+
 - Issue #9713, #10114: Parser functions (eg. PyParser_ASTFromFile) expects
   filenames encoded to the filesystem encoding with surrogateescape error
   handler (to support undecodable bytes), instead of UTF-8 in strict mode.
index d08d0edd138d0066fd04dad22624a4a85b5c70e3..98cad37799f95bde5a5a2cd030320b0fdcedf7ae 100644 (file)
@@ -721,14 +721,17 @@ initsite(void)
         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 {