]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 68017 via svnmerge from
authorGeorg Brandl <georg@python.org>
Sat, 3 Jan 2009 23:50:37 +0000 (23:50 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 3 Jan 2009 23:50:37 +0000 (23:50 +0000)
svn+ssh://svn.python.org/python/branches/py3k

................
  r68017 | benjamin.peterson | 2008-12-29 19:02:28 +0100 (Mon, 29 Dec 2008) | 9 lines

  Merged revisions 68016 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r68016 | benjamin.peterson | 2008-12-29 11:56:58 -0600 (Mon, 29 Dec 2008) | 1 line

    #4764 in io.open, set IOError.filename when trying to open a directory on POSIX platforms
  ........
................

Lib/test/test_fileio.py
Modules/_fileio.c

index 80de93ddb9f0863edd8ad185c66cc8beaa074fd8..817103ed9973dc299f6e0c605e3b5882211211cc 100644 (file)
@@ -108,6 +108,7 @@ class AutoFileTests(unittest.TestCase):
             _fileio._FileIO('.', 'r')
         except IOError as e:
             self.assertNotEqual(e.errno, 0)
+            self.assertEqual(e.filename, ".")
         else:
             self.fail("Should have raised IOError")
 
index b892993ae9ad253d6649822484af6c0f8f9f667d..c36a5de1c96c260c4b8e2588dc38daf9038ab4b8 100644 (file)
@@ -116,7 +116,7 @@ fileio_new(PyTypeObject *type, PyObject *args, PyObject *kews)
    directories, so we need a check.  */
 
 static int
-dircheck(PyFileIOObject* self)
+dircheck(PyFileIOObject* self, char *name)
 {
 #if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR)
        struct stat buf;
@@ -128,8 +128,8 @@ dircheck(PyFileIOObject* self)
                if (internal_close(self))
                        return -1;
 
-               exc = PyObject_CallFunction(PyExc_IOError, "(is)",
-                                           EISDIR, msg);
+               exc = PyObject_CallFunction(PyExc_IOError, "(iss)",
+                                           EISDIR, msg, name);
                PyErr_SetObject(PyExc_IOError, exc);
                Py_XDECREF(exc);
                return -1;
@@ -290,7 +290,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
 #endif
                        goto error;
                }
-               if(dircheck(self) < 0)
+               if(dircheck(self, name) < 0)
                        goto error;
        }