diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index c1aaf4fc5..0b95d2b49 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -159,8 +159,6 @@ class FileTests(unittest.TestCase): os.close(f) self.assertTrue(os.access(support.TESTFN, os.W_OK)) - # TODO: RUSTPYTHON (AttributeError: module 'os' has no attribute 'dup') - @unittest.expectedFailure def test_closerange(self): first = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR) # We must allocate two consecutive file descriptors, otherwise @@ -1625,8 +1623,6 @@ class URandomFDTests(unittest.TestCase): """ assert_python_ok('-c', code) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_urandom_fd_closed(self): # Issue #21207: urandom() should reopen its fd to /dev/urandom if # closed. @@ -1641,8 +1637,6 @@ class URandomFDTests(unittest.TestCase): """ rc, out, err = assert_python_ok('-Sc', code) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_urandom_fd_reopened(self): # Issue #21207: urandom() should detect its fd to /dev/urandom # changed to something else, and reopen it. diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index 6e1c9d685..a8626ab05 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -332,6 +332,13 @@ mod _os { rust_file(fileno); } + #[pyfunction] + fn closerange(fd_low: i64, fd_high: i64) { + for fileno in fd_low..fd_high { + close(fileno); + } + } + #[cfg(any(unix, windows, target_os = "wasi"))] #[pyfunction] pub(crate) fn open(