From 9235b254dcad979abe36be1024f8e89b04c764be Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Fri, 6 Jul 2012 18:48:24 +0200 Subject: Issue #15247: FileIO now raises an error when given a file descriptor pointing to a directory. --- Lib/test/test_fileio.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Lib') diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index 173ec25437..5504ea321b 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -127,6 +127,14 @@ class AutoFileTests(unittest.TestCase): else: self.fail("Should have raised IOError") + @unittest.skipIf(os.name == 'nt', "test only works on a POSIX-like system") + def testOpenDirFD(self): + fd = os.open('.', os.O_RDONLY) + with self.assertRaises(IOError) as cm: + _FileIO(fd, 'r') + os.close(fd) + self.assertEqual(cm.exception.errno, errno.EISDIR) + #A set of functions testing that we get expected behaviour if someone has #manually closed the internal file descriptor. First, a decorator: def ClosedFD(func): -- cgit v1.2.1