mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #15247: FileIO now raises an error when given a file descriptor pointing to a directory.
This commit is contained in:
parent
01cca5e451
commit
9235b254dc
3 changed files with 16 additions and 12 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue