mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Merge pull request #2514 from deantvv/os-closerange
Implement os.closerange
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user