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

Function bool_wrapper

crates/vm/src/types/slot.rs:563–573  ·  view source on GitHub ↗
(num: PyNumber<'_>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

561}
562
563fn bool_wrapper(num: PyNumber<'_>, vm: &VirtualMachine) -> PyResult<bool> {
564 let result = vm.call_special_method(num.obj, identifier!(vm, __bool__), ())?;
565 // __bool__ must return exactly bool, not int subclass
566 if !result.class().is(vm.ctx.types.bool_type) {
567 return Err(vm.new_type_error(format!(
568 "__bool__ should return bool, returned {}",
569 result.class().name()
570 )));
571 }
572 Ok(crate::builtins::bool_::get_value(&result))
573}
574
575// PyObject_SelfIter in CPython
576const fn self_iter(zelf: PyObjectRef, _vm: &VirtualMachine) -> PyResult {

Callers

nothing calls this directly

Calls 5

call_special_methodMethod · 0.80
isMethod · 0.80
ErrClass · 0.50
get_valueFunction · 0.50
classMethod · 0.45

Tested by

no test coverage detected