Commit 630cc482 authored by R. David Murray's avatar R. David Murray

Issue 6542: Make sure that TestInvalidFD.test_closerange does not

close any valid file descriptors.
parent 953152f0
......@@ -617,7 +617,18 @@ class TestInvalidFD(unittest.TestCase):
def test_closerange(self):
if hasattr(os, "closerange"):
fd = support.make_bad_fd()
self.assertEqual(os.closerange(fd, fd + 10), None)
# Make sure none of the descriptors we are about to close are
# currently valid (issue 6542).
for i in range(10):
try: os.fstat(fd+i)
except OSError:
pass
else:
break
if i < 2:
raise unittest.SkipTest(
"Unable to acquire a range of invalid file descriptors")
self.assertEqual(os.closerange(fd, fd + i-1), None)
def test_dup2(self):
if hasattr(os, "dup2"):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment