[Python-checkins] r79249 - in python/branches/release31-maint: Misc/NEWS Python/pythonrun.c

victor.stinner python-checkins at python.org
Sun Mar 21 22:57:42 CET 2010


Author: victor.stinner
Date: Sun Mar 21 22:57:42 2010
New Revision: 79249

Log:
Revert my change on initsite(): don't change import site error handler in 3.1,
as I did for 2.6. But fix the other bugs :-)


Modified:
   python/branches/release31-maint/Misc/NEWS
   python/branches/release31-maint/Python/pythonrun.c

Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS	(original)
+++ python/branches/release31-maint/Misc/NEWS	Sun Mar 21 22:57:42 2010
@@ -25,11 +25,6 @@
 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

Modified: python/branches/release31-maint/Python/pythonrun.c
==============================================================================
--- python/branches/release31-maint/Python/pythonrun.c	(original)
+++ python/branches/release31-maint/Python/pythonrun.c	Sun Mar 21 22:57:42 2010
@@ -712,12 +712,22 @@
 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);


More information about the Python-checkins mailing list