From: Martin v. Löwis Date: Thu, 19 Aug 2004 11:07:49 +0000 (+0000) Subject: Patch #1011822: Display errno/strerror for inaccessible files. X-Git-Tag: v2.4a3~195 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4d4dfb7a2b3bf4ed49a9f72ae8b802280b4e6154;p=thirdparty%2FPython%2Fcpython.git Patch #1011822: Display errno/strerror for inaccessible files. --- diff --git a/Modules/main.c b/Modules/main.c index fc5773c07fbb..bc543a4cac83 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -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) {