]> granicus.if.org Git - python/commitdiff
Fix the IOError message text when opening a file with an invalid filename.
authorGregory P. Smith <greg@mad-scientist.com>
Tue, 18 Mar 2008 00:20:01 +0000 (00:20 +0000)
committerGregory P. Smith <greg@mad-scientist.com>
Tue, 18 Mar 2008 00:20:01 +0000 (00:20 +0000)
Error reported by Ilan Schnell.

Objects/fileobject.c

index 932b7dc74da50d3c3f1aad797eed160367b7de91..6f8eb7c65c678216b1bcbf62f88e802d14e55140 100644 (file)
@@ -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;