[Python-checkins] r68134 - in python/trunk: Misc/NEWS Modules/_fileio.c

hirokazu.yamamoto python-checkins at python.org
Thu Jan 1 16:45:40 CET 2009


Author: hirokazu.yamamoto
Date: Thu Jan  1 16:45:39 2009
New Revision: 68134

Log:
Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open
file with `str' filename on Windows.

Modified:
   python/trunk/Misc/NEWS
   python/trunk/Modules/_fileio.c

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Thu Jan  1 16:45:39 2009
@@ -12,6 +12,9 @@
 Core and Builtins
 -----------------
 
+- Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open
+  file with `str' filename on Windows.
+
 - Issue #3680: Reference cycles created through a dict, set or deque iterator
   did not get collected.
 

Modified: python/trunk/Modules/_fileio.c
==============================================================================
--- python/trunk/Modules/_fileio.c	(original)
+++ python/trunk/Modules/_fileio.c	Thu Jan  1 16:45:39 2009
@@ -265,10 +265,11 @@
 		Py_END_ALLOW_THREADS
 		if (self->fd < 0) {
 #ifdef MS_WINDOWS
-			PyErr_SetFromErrnoWithUnicodeFilename(PyExc_IOError, widename);
-#else
-			PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
+			if (widename != NULL)
+				PyErr_SetFromErrnoWithUnicodeFilename(PyExc_IOError, widename);
+			else
 #endif
+				PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
 			goto error;
 		}
 		if(dircheck(self, name) < 0)


More information about the Python-checkins mailing list