(zelf: &Py<Self>, vm: &VirtualMachine)
| 199 | impl Representable for PyClassMethod { |
| 200 | #[inline] |
| 201 | fn repr_str(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<String> { |
| 202 | let callable = zelf.callable.lock().repr(vm).unwrap(); |
| 203 | let class = Self::class(&vm.ctx); |
| 204 | |
| 205 | let repr = match ( |
| 206 | class |
| 207 | .__qualname__(vm) |
| 208 | .downcast_ref::<PyStr>() |
| 209 | .map(|n| n.as_wtf8()), |
| 210 | class |
| 211 | .__module__(vm) |
| 212 | .downcast_ref::<PyStr>() |
| 213 | .map(|m| m.as_wtf8()), |
| 214 | ) { |
| 215 | (None, _) => return Err(vm.new_type_error("Unknown qualified name")), |
| 216 | (Some(qualname), Some(module)) if module != "builtins" => { |
| 217 | format!("<{module}.{qualname}({callable})>") |
| 218 | } |
| 219 | _ => format!("<{}({})>", class.slot_name(), callable), |
| 220 | }; |
| 221 | Ok(repr) |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | pub(crate) fn init(context: &'static Context) { |
nothing calls this directly
no test coverage detected