Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d4dfb7

Browse files
committed
Patch #1011822: Display errno/strerror for inaccessible files.
1 parent 26b3ebb commit 4d4dfb7

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Modules/main.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,13 @@ Py_Main(int argc, char **argv)
302302
#endif
303303
if (filename != NULL) {
304304
if ((fp = fopen(filename, "r")) == NULL) {
305-
fprintf(stderr, "%s: can't open file '%s'\n",
306-
argv[0], filename);
305+
#ifdef HAVE_STRERROR
306+
fprintf(stderr, "%s: can't open file '%s': [Errno %d] %s\n",
307+
argv[0], filename, errno, strerror(errno));
308+
#else
309+
fprintf(stderr, "%s: can't open file '%s': Errno %d\n",
310+
argv[0], filename, errno);
311+
#endif
307312
return 2;
308313
}
309314
else if (skipfirstline) {

0 commit comments

Comments
 (0)