Patch #1011822: Display errno/strerror for inaccessible files.

This commit is contained in:
Martin v. Löwis 2004-08-19 11:07:49 +00:00
parent 26b3ebb515
commit 4d4dfb7a2b
1 changed files with 7 additions and 2 deletions

View 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) {