mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Merge pull request #3416 from deantvv/os-posix-spawn
os: fix posix_spawn exception
This commit is contained in:
2
Lib/test/test_posix.py
vendored
2
Lib/test/test_posix.py
vendored
@@ -1554,8 +1554,6 @@ class _PosixSpawnMixin:
|
||||
with open(pidfile) as f:
|
||||
self.assertEqual(f.read(), str(pid))
|
||||
|
||||
# TODO: RUSTPYTHON: AssertionError: None != 'no_such_executable'
|
||||
@unittest.expectedFailure
|
||||
def test_no_such_executable(self):
|
||||
no_such_executable = 'no_such_executable'
|
||||
try:
|
||||
|
||||
@@ -1278,7 +1278,10 @@ pub mod module {
|
||||
fn spawn(self, spawnp: bool, vm: &VirtualMachine) -> PyResult<libc::pid_t> {
|
||||
use crate::TryFromBorrowedObject;
|
||||
|
||||
let path = CString::new(self.path.into_bytes())
|
||||
let path = self
|
||||
.path
|
||||
.clone()
|
||||
.into_cstring(vm)
|
||||
.map_err(|_| vm.new_value_error("path should not have nul bytes".to_owned()))?;
|
||||
|
||||
let mut file_actions = unsafe {
|
||||
@@ -1331,7 +1334,9 @@ pub mod module {
|
||||
}
|
||||
};
|
||||
if ret != 0 {
|
||||
return Err(errno_err(vm));
|
||||
return Err(IOErrorBuilder::new(std::io::Error::from_raw_os_error(ret))
|
||||
.filename(self.path)
|
||||
.into_pyexception(vm));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1403,7 +1408,9 @@ pub mod module {
|
||||
if ret == 0 {
|
||||
Ok(pid)
|
||||
} else {
|
||||
Err(errno_err(vm))
|
||||
Err(IOErrorBuilder::new(std::io::Error::from_raw_os_error(ret))
|
||||
.filename(self.path)
|
||||
.into_pyexception(vm))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user