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

Method repr_wtf8

crates/vm/src/stdlib/os.rs:883–910  ·  view source on GitHub ↗
(zelf: &Py<Self>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

881 impl Representable for DirEntry {
882 #[inline]
883 fn repr_wtf8(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<Wtf8Buf> {
884 let name = match zelf.as_object().get_attr("name", vm) {
885 Ok(name) => Some(name),
886 Err(e)
887 if e.fast_isinstance(vm.ctx.exceptions.attribute_error)
888 || e.fast_isinstance(vm.ctx.exceptions.value_error) =>
889 {
890 None
891 }
892 Err(e) => return Err(e),
893 };
894 if let Some(name) = name {
895 if let Some(_guard) = ReprGuard::enter(vm, zelf.as_object()) {
896 let repr = name.repr(vm)?;
897 let mut result = Wtf8Buf::from(format!("<{} ", zelf.class()));
898 result.push_wtf8(repr.as_wtf8());
899 result.push_char('>');
900 Ok(result)
901 } else {
902 Err(vm.new_runtime_error(format!(
903 "reentrant call inside {}.__repr__",
904 zelf.class()
905 )))
906 }
907 } else {
908 Ok(Wtf8Buf::from(format!("<{}>", zelf.class())))
909 }
910 }
911 }
912 #[pyattr]
913 #[pyclass(name = "ScandirIter")]

Callers

nothing calls this directly

Calls 9

fast_isinstanceMethod · 0.80
push_wtf8Method · 0.80
SomeClass · 0.50
ErrClass · 0.50
get_attrMethod · 0.45
as_objectMethod · 0.45
reprMethod · 0.45
as_wtf8Method · 0.45
push_charMethod · 0.45

Tested by

no test coverage detected