[Python-checkins] r62659 - python/branches/release25-maint/Objects/fileobject.c

gregory.p.smith python-checkins at python.org
Sat May 3 09:12:24 CEST 2008


Author: gregory.p.smith
Date: Sat May  3 09:12:23 2008
New Revision: 62659

Log:
Backport r61468 from trunk: Improves the text of the IOError raised
when open() returns EINVAL.  See issue2158.


Modified:
   python/branches/release25-maint/Objects/fileobject.c

Modified: python/branches/release25-maint/Objects/fileobject.c
==============================================================================
--- python/branches/release25-maint/Objects/fileobject.c	(original)
+++ python/branches/release25-maint/Objects/fileobject.c	Sat May  3 09:12:23 2008
@@ -256,9 +256,12 @@
 		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;


More information about the Python-checkins mailing list