Merge pull request #3416 from deantvv/os-posix-spawn

os: fix posix_spawn exception
This commit is contained in:
Jeong YunWon
2021-11-06 18:53:29 +09:00
committed by GitHub
2 changed files with 10 additions and 5 deletions

View File

@@ -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:

View File

@@ -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))
}
}
}