diff options
author | Hynek Schlawack <hs@ox.cx> | 2012-05-25 09:24:18 +0200 |
---|---|---|
committer | Hynek Schlawack <hs@ox.cx> | 2012-05-25 09:24:18 +0200 |
commit | 877effc2986ad30ecd5454811b0449bcfe3037f5 (patch) | |
tree | 0987ab6f596a0f6e3975f1e531d7dd76dc01fdbc /Lib/test/test_io.py | |
parent | 8e6287f50df14fb50cea43036ef4eec3998f823e (diff) | |
download | cpython-git-877effc2986ad30ecd5454811b0449bcfe3037f5.tar.gz |
#4841: Fix FileIO constructor to honor closefd when called repeatedly
Patch by Victor Stinner.
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r-- | Lib/test/test_io.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index b9972f3ac5..72feff59e4 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -593,6 +593,19 @@ class IOTest(unittest.TestCase): self.assertEqual(rawio.read(2), None) self.assertEqual(rawio.read(2), b"") + def test_fileio_closefd(self): + # Issue #4841 + with self.open(__file__, 'rb') as f1, \ + self.open(__file__, 'rb') as f2: + fileio = self.FileIO(f1.fileno(), closefd=False) + # .__init__() must not close f1 + fileio.__init__(f2.fileno(), closefd=False) + f1.readline() + # .close() must not close f2 + fileio.close() + f2.readline() + + class CIOTest(IOTest): def test_IOBase_finalize(self): |