diff options
author | Hynek Schlawack <hs@ox.cx> | 2012-05-25 10:05:53 +0200 |
---|---|---|
committer | Hynek Schlawack <hs@ox.cx> | 2012-05-25 10:05:53 +0200 |
commit | 2cc71565154b2092da9b15e205567c13e07f331a (patch) | |
tree | 4ce37916feb8fa7c9d496281f793038893446e52 /Lib/test/test_io.py | |
parent | 1a01ebc41cbbfc127865f82656879a58c2560543 (diff) | |
download | cpython-git-2cc71565154b2092da9b15e205567c13e07f331a.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 ea82cea17a..95ecd90a8e 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -634,6 +634,19 @@ class IOTest(unittest.TestCase): for obj in test: self.assertTrue(hasattr(obj, "__dict__")) + 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): |