From: Gregory P. Smith Date: Tue, 18 Mar 2008 00:20:01 +0000 (+0000) Subject: Fix the IOError message text when opening a file with an invalid filename. X-Git-Tag: v2.6a2~297 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=887290d275a68754aa15a9924640faab392754b6;p=python Fix the IOError message text when opening a file with an invalid filename. Error reported by Ilan Schnell. --- diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 932b7dc74d..6f8eb7c65c 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;