(
obj: &PyObject,
name: &'static PyStrInterned,
vm: &VirtualMachine,
)
| 88 | } |
| 89 | |
| 90 | pub(crate) fn get_special<const DIRECT: bool>( |
| 91 | obj: &PyObject, |
| 92 | name: &'static PyStrInterned, |
| 93 | vm: &VirtualMachine, |
| 94 | ) -> PyResult<Option<Self>> { |
| 95 | let obj_cls = obj.class(); |
| 96 | let attr = if DIRECT { |
| 97 | obj_cls.get_direct_attr(name) |
| 98 | } else { |
| 99 | obj_cls.get_attr(name) |
| 100 | }; |
| 101 | let func = match attr { |
| 102 | Some(f) => f, |
| 103 | None => { |
| 104 | return Ok(None); |
| 105 | } |
| 106 | }; |
| 107 | let meth = if func |
| 108 | .class() |
| 109 | .slots |
| 110 | .flags |
| 111 | .has_feature(PyTypeFlags::METHOD_DESCRIPTOR) |
| 112 | { |
| 113 | Self::Function { |
| 114 | target: obj.to_owned(), |
| 115 | func, |
| 116 | } |
| 117 | } else { |
| 118 | let obj_cls = obj_cls.to_owned().into(); |
| 119 | let attr = vm |
| 120 | .call_get_descriptor_specific(&func, Some(obj.to_owned()), Some(obj_cls)) |
| 121 | .unwrap_or(Ok(func))?; |
| 122 | Self::Attribute(attr) |
| 123 | }; |
| 124 | Ok(Some(meth)) |
| 125 | } |
| 126 | |
| 127 | pub fn invoke(self, args: impl IntoFuncArgs, vm: &VirtualMachine) -> PyResult { |
| 128 | let (func, args) = match self { |
nothing calls this directly
no test coverage detected