summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorHynek Schlawack <hs@ox.cx>2012-05-25 08:27:43 (GMT)
committerHynek Schlawack <hs@ox.cx>2012-05-25 08:27:43 (GMT)
commit9866d96e48e884edb8d7db468c03db316503bbbc (patch)
tree85d09a932a4453937921b777437ed8cf4e9fa566 /Lib/test/test_io.py
parent18eac4a1d67b3b4a6f51608f0c3c82fa662100b0 (diff)
parent2cc71565154b2092da9b15e205567c13e07f331a (diff)
downloadcpython-9866d96e48e884edb8d7db468c03db316503bbbc.zip
cpython-9866d96e48e884edb8d7db468c03db316503bbbc.tar.gz
cpython-9866d96e48e884edb8d7db468c03db316503bbbc.tar.bz2
#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.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 96258b4..f5bb732 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -643,6 +643,19 @@ class IOTest(unittest.TestCase):
with self.open("non-existent", "r", opener=opener) as f:
self.assertEqual(f.read(), "egg\n")
+ 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):