Skip to content

Commit 3aa6cea

Browse files
author
Victor Stinner
committed
Issue python#10077: Fix logging of site module errors at startup.
1 parent ecdd084 commit 3aa6cea

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎Misc/NEWS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ What's New in Python 3.1.3?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #10077: Fix logging of site module errors at startup.
14+
1315
- Issue #9713, #10114: Parser functions (eg. PyParser_ASTFromFile) expects
1416
filenames encoded to the filesystem encoding with surrogateescape error
1517
handler (to support undecodable bytes), instead of UTF-8 in strict mode.

‎Python/pythonrun.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,14 +721,17 @@ initsite(void)
721721
if (f == NULL || f == Py_None)
722722
return;
723723
if (Py_VerboseFlag) {
724+
PyObject *type, *value, *traceback;
725+
PyErr_Fetch(&type, &value, &traceback);
724726
PyFile_WriteString(
725727
"'import site' failed; traceback:\n", f);
728+
PyErr_Restore(type, value, traceback);
726729
PyErr_Print();
727730
}
728731
else {
732+
PyErr_Clear();
729733
PyFile_WriteString(
730734
"'import site' failed; use -v for traceback\n", f);
731-
PyErr_Clear();
732735
}
733736
}
734737
else {

0 commit comments

Comments
 (0)