diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 7f84b1972..3dfce9b7d 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -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: diff --git a/vm/src/stdlib/posix.rs b/vm/src/stdlib/posix.rs index 90e244de5..3d841cba4 100644 --- a/vm/src/stdlib/posix.rs +++ b/vm/src/stdlib/posix.rs @@ -1278,7 +1278,10 @@ pub mod module { fn spawn(self, spawnp: bool, vm: &VirtualMachine) -> PyResult { 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)) } } }