# should raise on closed file
self.assertRaises(ValueError, method)
+ def testOpendir(self):
+ # Issue 3703: opening a directory should fill the errno
+ # Windows always returns "[Errno 13]: Permission denied
+ # Unix calls dircheck() and returns "[Errno 21]: Is a directory"
+ try:
+ _fileio._FileIO('.', 'r')
+ except IOError as e:
+ self.assertNotEqual(e.errno, 0)
+ else:
+ self.fail("Should have raised IOError")
+
class OtherFileTests(unittest.TestCase):
#endif
self->fd = open(name, flags, 0666);
Py_END_ALLOW_THREADS
- if (self->fd < 0 || dircheck(self) < 0) {
+ if (self->fd < 0) {
#ifdef MS_WINDOWS
PyErr_SetFromErrnoWithUnicodeFilename(PyExc_IOError, widename);
#else
#endif
goto error;
}
+ if(dircheck(self) < 0)
+ goto error;
}
goto done;