Skip to content

Commit 9140918

Browse files
authored
Merge pull request RustPython#2694 from deantvv/os-openpty-fix-test
os: Fix openpty test
2 parents 6471ad8 + ff87ad0 commit 9140918

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Lib/test/test_os.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3616,8 +3616,6 @@ def test_dup2(self):
36163616
self.assertEqual(os.dup2(fd, fd3, inheritable=False), fd3)
36173617
self.assertFalse(os.get_inheritable(fd3))
36183618

3619-
# TODO: RUSTPYTHON
3620-
@unittest.expectedFailure
36213619
@unittest.skipUnless(hasattr(os, 'openpty'), "need os.openpty()")
36223620
def test_openpty(self):
36233621
master_fd, slave_fd = os.openpty()

vm/src/stdlib/os.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,6 +2371,9 @@ mod posix {
23712371
#[pyfunction]
23722372
fn openpty(vm: &VirtualMachine) -> PyResult {
23732373
let r = nix::pty::openpty(None, None).map_err(|err| err.into_pyexception(vm))?;
2374+
for fd in &[r.master, r.slave] {
2375+
raw_set_inheritable(*fd, false).map_err(|e| e.into_pyexception(vm))?;
2376+
}
23742377
Ok(vm
23752378
.ctx
23762379
.new_tuple(vec![vm.ctx.new_int(r.master), vm.ctx.new_int(r.slave)]))

0 commit comments

Comments
 (0)