]> granicus.if.org Git - python/commitdiff
Fix for bug #1442 pythonstartup addition of minor error checking
authorChristian Heimes <christian@cheimes.de>
Wed, 14 Nov 2007 16:21:32 +0000 (16:21 +0000)
committerChristian Heimes <christian@cheimes.de>
Wed, 14 Nov 2007 16:21:32 +0000 (16:21 +0000)
Python failed to report an error when it wasn't able to open the PYTHONSTARTUP file.

Modules/main.c

index ee4a1b8ab021f43309d3d38f7eb73d828f200a6d..df4c6d887f42a60c668ac9eeaed9ae774c705ec9 100644 (file)
@@ -132,6 +132,16 @@ 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();
                }
        }
 }