MCPcopy Index your code
hub / github.com/RustPython/RustPython / execv

Function execv

crates/vm/src/stdlib/posix.rs:1294–1316  ·  view source on GitHub ↗
(
        path: OsPath,
        argv: Either<PyListRef, PyTupleRef>,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

1292
1293 #[pyfunction]
1294 fn execv(
1295 path: OsPath,
1296 argv: Either<PyListRef, PyTupleRef>,
1297 vm: &VirtualMachine,
1298 ) -> PyResult<()> {
1299 let path = path.into_cstring(vm)?;
1300
1301 let argv = vm.extract_elements_with(argv.as_ref(), |obj| {
1302 OsPath::try_from_object(vm, obj)?.into_cstring(vm)
1303 })?;
1304 let argv: Vec<&CStr> = argv.iter().map(|entry| entry.as_c_str()).collect();
1305
1306 let first = argv
1307 .first()
1308 .ok_or_else(|| vm.new_value_error("execv() arg 2 must not be empty"))?;
1309 if first.to_bytes().is_empty() {
1310 return Err(vm.new_value_error("execv() arg 2 first element cannot be empty"));
1311 }
1312
1313 unistd::execv(&path, &argv)
1314 .map(|_ok| ())
1315 .map_err(|err| err.into_pyexception(vm))
1316 }
1317
1318 #[pyfunction]
1319 fn execve(

Callers

nothing calls this directly

Calls 12

into_cstringMethod · 0.80
extract_elements_withMethod · 0.80
collectMethod · 0.80
ok_or_elseMethod · 0.80
to_bytesMethod · 0.80
ErrClass · 0.50
as_refMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
firstMethod · 0.45
is_emptyMethod · 0.45
into_pyexceptionMethod · 0.45

Tested by

no test coverage detected