Skip to content

Commit 1be66e4

Browse files
author
gregory.p.smith
committed
Fix the IOError message text when opening a file with an invalid filename.
Error reported by Ilan Schnell. git-svn-id: http://svn.python.org/projects/python/trunk@61468 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent dc3e4b3 commit 1be66e4

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Objects/fileobject.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,12 @@ open_the_file(PyFileObject *f, char *name, char *mode)
256256
else if (errno == EINVAL) /* unknown, but not a mode string */
257257
errno = ENOENT;
258258
#endif
259+
/* EINVAL is returned when an invalid filename or
260+
* an invalid mode is supplied. */
259261
if (errno == EINVAL)
260-
PyErr_Format(PyExc_IOError, "invalid mode: %s",
261-
mode);
262+
PyErr_Format(PyExc_IOError,
263+
"invalid filename: %s or mode: %s",
264+
name, mode);
262265
else
263266
PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, f->f_name);
264267
f = NULL;

0 commit comments

Comments
 (0)