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

This commit is contained in:
Benjamin Peterson 2008-12-29 17:47:42 +00:00
parent 732479f50b
commit fe231b07e4
3 changed files with 18 additions and 2 deletions

View file

@ -132,8 +132,8 @@ dircheck(PyFileObject* f)
if (fstat(fileno(f->f_fp), &buf) == 0 &&
S_ISDIR(buf.st_mode)) {
char *msg = strerror(EISDIR);
PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(is)",
EISDIR, msg);
PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(isO)",
EISDIR, msg, f->f_name);
PyErr_SetObject(PyExc_IOError, exc);
Py_XDECREF(exc);
return NULL;