(vm: &VirtualMachine, obj: PyObjectRef)
| 272 | |
| 273 | impl TryFromObject for NativeFunctionOrMethod { |
| 274 | fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> { |
| 275 | let class = vm.ctx.types.builtin_function_or_method_type; |
| 276 | if obj.fast_isinstance(class) { |
| 277 | // Both PyNativeFunction and PyNativeMethod share the same type now. |
| 278 | // PyNativeMethod has `func: PyNativeFunction` as its first field, |
| 279 | // so we can safely treat the data pointer as PyNativeFunction for reading. |
| 280 | Ok(Self(unsafe { obj.downcast_unchecked() })) |
| 281 | } else { |
| 282 | Err(vm.new_downcast_type_error(class, &obj)) |
| 283 | } |
| 284 | } |
| 285 | } |
nothing calls this directly
no test coverage detected