(zelf: &Py<Self>, name_str: &Py<PyStr>, vm: &VirtualMachine)
| 2316 | |
| 2317 | impl GetAttr for PyType { |
| 2318 | fn getattro(zelf: &Py<Self>, name_str: &Py<PyStr>, vm: &VirtualMachine) -> PyResult { |
| 2319 | #[cold] |
| 2320 | fn attribute_error( |
| 2321 | zelf: &Py<PyType>, |
| 2322 | name: &Wtf8, |
| 2323 | vm: &VirtualMachine, |
| 2324 | ) -> PyBaseExceptionRef { |
| 2325 | vm.new_attribute_error(format!( |
| 2326 | "type object '{}' has no attribute '{}'", |
| 2327 | zelf.slot_name(), |
| 2328 | name, |
| 2329 | )) |
| 2330 | } |
| 2331 | |
| 2332 | let Some(name) = vm.ctx.interned_str(name_str) else { |
| 2333 | return Err(attribute_error(zelf, name_str.as_wtf8(), vm)); |
| 2334 | }; |
| 2335 | vm_trace!("type.__getattribute__({:?}, {:?})", zelf, name); |
| 2336 | let mcl = zelf.class(); |
| 2337 | let mcl_attr = mcl.get_attr(name); |
| 2338 | |
| 2339 | if let Some(ref attr) = mcl_attr { |
| 2340 | let attr_class = attr.class(); |
| 2341 | let has_descr_set = attr_class.slots.descr_set.load().is_some(); |
| 2342 | if has_descr_set { |
| 2343 | let descr_get = attr_class.slots.descr_get.load(); |
| 2344 | if let Some(descr_get) = descr_get { |
| 2345 | let mcl = mcl.to_owned().into(); |
| 2346 | return descr_get(attr.clone(), Some(zelf.to_owned().into()), Some(mcl), vm); |
| 2347 | } |
| 2348 | } |
| 2349 | } |
| 2350 | |
| 2351 | let zelf_attr = zelf.get_attr(name); |
| 2352 | |
| 2353 | if let Some(attr) = zelf_attr { |
| 2354 | let descr_get = attr.class().slots.descr_get.load(); |
| 2355 | if let Some(descr_get) = descr_get { |
| 2356 | descr_get(attr, None, Some(zelf.to_owned().into()), vm) |
| 2357 | } else { |
| 2358 | Ok(attr) |
| 2359 | } |
| 2360 | } else if let Some(attr) = mcl_attr { |
| 2361 | vm.call_if_get_descriptor(&attr, zelf.to_owned().into()) |
| 2362 | } else { |
| 2363 | Err(attribute_error(zelf, name_str.as_wtf8(), vm)) |
| 2364 | } |
| 2365 | } |
| 2366 | } |
| 2367 | |
| 2368 | #[pyclass] |
nothing calls this directly
no test coverage detected