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

Function displayhook

crates/vm/src/stdlib/sys.rs:822–834  ·  view source on GitHub ↗
(obj: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

820 #[pyfunction(name = "__displayhook__")]
821 #[pyfunction]
822 fn displayhook(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
823 // Save non-None values as "_"
824 if vm.is_none(&obj) {
825 return Ok(());
826 }
827 // set to none to avoid recursion while printing
828 vm.builtins.set_attr("_", vm.ctx.none(), vm)?;
829 // TODO: catch encoding errors
830 let repr = obj.repr(vm)?.into();
831 builtins::print(PosArgs::new(vec![repr]), Default::default(), vm)?;
832 vm.builtins.set_attr("_", obj, vm)?;
833 Ok(())
834 }
835
836 #[pyfunction(name = "__excepthook__")]
837 #[pyfunction]

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
noneMethod · 0.80
printFunction · 0.70
is_noneMethod · 0.45
set_attrMethod · 0.45
reprMethod · 0.45

Tested by

no test coverage detected