diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2008-05-03 07:12:23 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2008-05-03 07:12:23 (GMT) |
commit | 9e6649f8ee278d0528cb76462b91ee29ee68af19 (patch) | |
tree | 766fbdc8a163ff137f1e412e9d433f40a89612c2 /Objects | |
parent | fb30cdbf98db63131514ea196290c89905c3457d (diff) | |
download | cpython-9e6649f8ee278d0528cb76462b91ee29ee68af19.zip cpython-9e6649f8ee278d0528cb76462b91ee29ee68af19.tar.gz cpython-9e6649f8ee278d0528cb76462b91ee29ee68af19.tar.bz2 |
Backport r61468 from trunk: Improves the text of the IOError raised
when open() returns EINVAL. See issue2158.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/fileobject.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c index f954e36..565bf5c 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -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; |