]> granicus.if.org Git - python/commitdiff
Revert my change on initsite(): don't change import site error handler in 3.1,
authorVictor Stinner <victor.stinner@haypocalc.com>
Sun, 21 Mar 2010 21:57:42 +0000 (21:57 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sun, 21 Mar 2010 21:57:42 +0000 (21:57 +0000)
as I did for 2.6. But fix the other bugs :-)

Misc/NEWS
Python/pythonrun.c

index 3e6cf262c0e7a4bddb13873b246f3b51f412fcee..9d42ce69229d27e5337d5214b042a68809ea3cc9 100644 (file)
--- 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
index f4f87662d25ef3bb08b0bc6ddadf120a616e9ac4..55b9d50e50edee9e4859b8ac33d501e2efc77e41 100644 (file)
@@ -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);