| 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")] |