summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS5
-rw-r--r--Python/pythonrun.c18
2 files changed, 14 insertions, 9 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 3e6cf26..9d42ce6 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -25,11 +25,6 @@ What's New in Python 3.1.2?
Core and Builtins
-----------------
-- Issue #3137: Don't ignore errors at startup, especially a keyboard interrupt
- (SIGINT). If an error occurs while importing the site module, the error is
- printed and Python exits. Initialize the GIL before importing the site
- module.
-
- Issue #7173: Generator finalization could invalidate sys.exc_info().
Library
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index f4f8766..55b9d50 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -712,12 +712,22 @@ initmain(void)
static void
initsite(void)
{
- PyObject *m;
+ PyObject *m, *f;
m = PyImport_ImportModule("site");
if (m == NULL) {
- PyErr_Print();
- Py_Finalize();
- exit(1);
+ f = PySys_GetObject("stderr");
+ if (f == NULL || f == Py_None)
+ return;
+ if (Py_VerboseFlag) {
+ PyFile_WriteString(
+ "'import site' failed; traceback:\n", f);
+ PyErr_Print();
+ }
+ else {
+ PyFile_WriteString(
+ "'import site' failed; use -v for traceback\n", f);
+ PyErr_Clear();
+ }
}
else {
Py_DECREF(m);