summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_fileio.py1
-rw-r--r--Modules/_fileio.c8
2 files changed, 5 insertions, 4 deletions
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py
index 80de93ddb9..817103ed99 100644
--- a/Lib/test/test_fileio.py
+++ b/Lib/test/test_fileio.py
@@ -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")
diff --git a/Modules/_fileio.c b/Modules/_fileio.c
index b892993ae9..c36a5de1c9 100644
--- a/Modules/_fileio.c
+++ b/Modules/_fileio.c
@@ -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;
}