]> granicus.if.org Git - python/commitdiff
Backport #1442: report exception when startup file cannot be run.
authorGeorg Brandl <georg@python.org>
Sat, 29 Mar 2008 01:50:06 +0000 (01:50 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 29 Mar 2008 01:50:06 +0000 (01:50 +0000)
Misc/NEWS
Modules/main.c

index 893b8ac5c016a98d8b0207ecf548cb8c437c94b3..7895e7531d78abbb355d75c357d2933b6cc476bf 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 2?
 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.
 
index 21cb48703d4ebf027a188bf0d96d6279475025e9..a91974012547f1e0c8717718cda3b68a1b81f4b3 100644 (file)
@@ -140,6 +140,15 @@ static void RunStartupFile(PyCompilerFlags *cf)
                        (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();
                }
        }
 }