summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorNir Soffer <nirsof@gmail.com>2017-07-24 21:18:06 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-07-24 21:18:06 (GMT)
commitc648a93ae342ac28d2abbb100161eae4f907d001 (patch)
treefe57c9a1fbed51dbfd1d32b3bc73fcb0edfc5756 /Lib/test
parent5b4feb7e86ecb813b2c56560f86cda2fd46b9579 (diff)
downloadcpython-c648a93ae342ac28d2abbb100161eae4f907d001.zip
cpython-c648a93ae342ac28d2abbb100161eae4f907d001.tar.gz
cpython-c648a93ae342ac28d2abbb100161eae4f907d001.tar.bz2
bpo-30980: Fix double close in asyncore.file_wrapper (#2789)
* bpo-30980: Fix close test to fail test_close_twice was not considering the fact that file_wrapper is duping the file descriptor. Closing the original descriptor left the duped one open, hiding the fact that close protection is not effective. * bpo-30980: Fix double close protection Invalidated self.fd before closing, handling correctly the case when os.close raises. * bpo-30980: Fix fd leak introduced in the fixed test
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asyncore.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py
index dc2f716..07edf22 100644
--- a/Lib/test/test_asyncore.py
+++ b/Lib/test/test_asyncore.py
@@ -433,7 +433,10 @@ class FileWrapperTest(unittest.TestCase):
f = asyncore.file_wrapper(fd)
os.close(fd)
- f.close()
+ os.close(f.fd) # file_wrapper dupped fd
+ with self.assertRaises(OSError):
+ f.close()
+
self.assertEqual(f.fd, -1)
# calling close twice should not fail
f.close()