]> granicus.if.org Git - python/commitdiff
Merged revisions 68134 via svnmerge from
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Thu, 1 Jan 2009 16:03:45 +0000 (16:03 +0000)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Thu, 1 Jan 2009 16:03:45 +0000 (16:03 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r68134 | hirokazu.yamamoto | 2009-01-02 00:45:39 +0900 | 2 lines

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

Misc/NEWS
Modules/_fileio.c

index 30668e67c1f551e759b7887f2d0f6ba3f821911c..c97dacadb0644c34b23398805933508a1f187e2d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 3.1 alpha 0
 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.
 
index c36a5de1c96c260c4b8e2588dc38daf9038ab4b8..8579e4e60bdb0568e0e36519bffe974a89e7ea5d 100644 (file)
@@ -284,10 +284,11 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
                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)