mirror of https://github.com/python/cpython
Fix the IOError message text when opening a file with an invalid filename.
Error reported by Ilan Schnell.
This commit is contained in:
parent
a7d57cd433
commit
887290d275
|
@ -256,9 +256,12 @@ open_the_file(PyFileObject *f, char *name, char *mode)
|
||||||
else if (errno == EINVAL) /* unknown, but not a mode string */
|
else if (errno == EINVAL) /* unknown, but not a mode string */
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
#endif
|
#endif
|
||||||
|
/* EINVAL is returned when an invalid filename or
|
||||||
|
* an invalid mode is supplied. */
|
||||||
if (errno == EINVAL)
|
if (errno == EINVAL)
|
||||||
PyErr_Format(PyExc_IOError, "invalid mode: %s",
|
PyErr_Format(PyExc_IOError,
|
||||||
mode);
|
"invalid filename: %s or mode: %s",
|
||||||
|
name, mode);
|
||||||
else
|
else
|
||||||
PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, f->f_name);
|
PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, f->f_name);
|
||||||
f = NULL;
|
f = NULL;
|
||||||
|
|
Loading…
Reference in New Issue