Skip to content

Commit 1cd49ff

Browse files
author
loewis
committed
Patch #1011822: Display errno/strerror for inaccessible files.
git-svn-id: http://svn.python.org/projects/python/trunk@37052 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 651b093 commit 1cd49ff

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)