]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Patch #1011822: Display errno/strerror for inaccessible files.
authorMartin v. Löwis <martin@v.loewis.de>
Thu, 19 Aug 2004 11:07:49 +0000 (11:07 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Thu, 19 Aug 2004 11:07:49 +0000 (11:07 +0000)
Modules/main.c

index fc5773c07fbbb58c717f8ed1116ea643f354b0ce..bc543a4cac83734663dd1ce31936853baff99792 100644 (file)
@@ -302,8 +302,13 @@ Py_Main(int argc, char **argv)
 #endif
                if (filename != NULL) {
                        if ((fp = fopen(filename, "r")) == NULL) {
-                               fprintf(stderr, "%s: can't open file '%s'\n",
-                                       argv[0], filename);
+#ifdef HAVE_STRERROR
+                               fprintf(stderr, "%s: can't open file '%s': [Errno %d] %s\n",
+                                       argv[0], filename, errno, strerror(errno));
+#else
+                               fprintf(stderr, "%s: can't open file '%s': Errno %d\n",
+                                       argv[0], filename, errno);
+#endif
                                return 2;
                        }
                        else if (skipfirstline) {