mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
#1663329: add os.closerange() to close a range of fds,
ignoring errors, and use this in subprocess to speed up subprocess creation in close_fds mode. Patch by Mike Klaas.
This commit is contained in:
parent
15ce880cc8
commit
309501a617
5 changed files with 44 additions and 7 deletions
|
@ -23,6 +23,12 @@ class FileTests(unittest.TestCase):
|
|||
os.close(f)
|
||||
self.assert_(os.access(test_support.TESTFN, os.W_OK))
|
||||
|
||||
def test_closerange(self):
|
||||
f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR)
|
||||
# close a fd that is open, and one that isn't
|
||||
os.closerange(f, f+2)
|
||||
self.assertRaises(OSError, os.write, f, "a")
|
||||
|
||||
|
||||
class TemporaryFileTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue