(
mode: i32,
path: OsPath,
argv: Either<PyListRef, PyTupleRef>,
vm: &VirtualMachine,
)
| 1061 | #[cfg(target_env = "msvc")] |
| 1062 | #[pyfunction] |
| 1063 | fn spawnv( |
| 1064 | mode: i32, |
| 1065 | path: OsPath, |
| 1066 | argv: Either<PyListRef, PyTupleRef>, |
| 1067 | vm: &VirtualMachine, |
| 1068 | ) -> PyResult<intptr_t> { |
| 1069 | use crate::function::FsPath; |
| 1070 | use core::iter::once; |
| 1071 | |
| 1072 | let path = path.to_wide_cstring(vm)?; |
| 1073 | |
| 1074 | let argv = vm.extract_elements_with(argv.as_ref(), |obj| { |
| 1075 | let fspath = FsPath::try_from_path_like(obj, true, vm)?; |
| 1076 | fspath.to_wide_cstring(vm) |
| 1077 | })?; |
| 1078 | |
| 1079 | let first = argv |
| 1080 | .first() |
| 1081 | .ok_or_else(|| vm.new_value_error("spawnv() arg 3 must not be empty"))?; |
| 1082 | |
| 1083 | if first.is_empty() { |
| 1084 | return Err(vm.new_value_error("spawnv() arg 3 first element cannot be empty")); |
| 1085 | } |
| 1086 | |
| 1087 | let argv_spawn: Vec<*const u16> = argv |
| 1088 | .iter() |
| 1089 | .map(|v| v.as_ptr()) |
| 1090 | .chain(once(core::ptr::null())) |
| 1091 | .collect(); |
| 1092 | |
| 1093 | let result = unsafe { suppress_iph!(_wspawnv(mode, path.as_ptr(), argv_spawn.as_ptr())) }; |
| 1094 | if result == -1 { |
| 1095 | Err(vm.new_last_errno_error()) |
| 1096 | } else { |
| 1097 | Ok(result) |
| 1098 | } |
| 1099 | } |
| 1100 | |
| 1101 | #[cfg(target_env = "msvc")] |
| 1102 | #[pyfunction] |
nothing calls this directly
no test coverage detected