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

Function setrecursionlimit

crates/vm/src/stdlib/sys.rs:1354–1371  ·  view source on GitHub ↗
(recursion_limit: i32, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1352
1353 #[pyfunction]
1354 fn setrecursionlimit(recursion_limit: i32, vm: &VirtualMachine) -> PyResult<()> {
1355 let recursion_limit = recursion_limit
1356 .to_usize()
1357 .filter(|&u| u >= 1)
1358 .ok_or_else(|| {
1359 vm.new_value_error("recursion limit must be greater than or equal to one")
1360 })?;
1361 let recursion_depth = vm.current_recursion_depth();
1362
1363 if recursion_limit > recursion_depth {
1364 vm.recursion_limit.set(recursion_limit);
1365 Ok(())
1366 } else {
1367 Err(vm.new_recursion_error(format!(
1368 "cannot set the recursion limit to {recursion_limit} at the recursion depth {recursion_depth}: the limit is too low"
1369 )))
1370 }
1371 }
1372
1373 #[pyfunction]
1374 fn settrace(tracefunc: PyObjectRef, vm: &VirtualMachine) {

Callers

nothing calls this directly

Calls 6

ok_or_elseMethod · 0.80
ErrClass · 0.50
filterMethod · 0.45
to_usizeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected