[Python-checkins] r62030 - in python/trunk: Misc/NEWS Modules/main.c

georg.brandl python-checkins at python.org
Sat Mar 29 02:50:06 CET 2008


Author: georg.brandl
Date: Sat Mar 29 02:50:06 2008
New Revision: 62030

Modified:
   python/trunk/Misc/NEWS
   python/trunk/Modules/main.c
Log:
Backport #1442: report exception when startup file cannot be run.


Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Sat Mar 29 02:50:06 2008
@@ -12,6 +12,9 @@
 Core and builtins
 -----------------
 
+- Patch #1442: properly report exceptions when the PYTHONSTARTUP file
+  cannot be executed.
+
 - The compilation of a class nested in another class used to leak one
   reference on the outer class name.
 

Modified: python/trunk/Modules/main.c
==============================================================================
--- python/trunk/Modules/main.c	(original)
+++ python/trunk/Modules/main.c	Sat Mar 29 02:50:06 2008
@@ -140,6 +140,15 @@
 			(void) PyRun_SimpleFileExFlags(fp, startup, 0, cf);
 			PyErr_Clear();
 			fclose(fp);
+               } else {
+			int save_errno;
+			save_errno = errno;
+			PySys_WriteStderr("Could not open PYTHONSTARTUP\n");
+			errno = save_errno;
+			PyErr_SetFromErrnoWithFilename(PyExc_IOError,
+						       startup);
+			PyErr_Print();
+			PyErr_Clear();
 		}
 	}
 }


More information about the Python-checkins mailing list