Commit 9e6649f8 authored by Gregory P. Smith's avatar Gregory P. Smith

Backport r61468 from trunk: Improves the text of the IOError raised

when open() returns EINVAL.  See issue2158.
parent fb30cdbf
......@@ -256,9 +256,12 @@ open_the_file(PyFileObject *f, char *name, char *mode)
else if (errno == EINVAL) /* unknown, but not a mode string */
errno = ENOENT;
#endif
/* EINVAL is returned when an invalid filename or
* an invalid mode is supplied. */
if (errno == EINVAL)
PyErr_Format(PyExc_IOError, "invalid mode: %s",
mode);
PyErr_Format(PyExc_IOError,
"invalid filename: %s or mode: %s",
name, mode);
else
PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, f->f_name);
f = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment