(&self, args: impl IntoFuncArgs, vm: &VirtualMachine)
| 73 | } |
| 74 | |
| 75 | pub fn invoke(&self, args: impl IntoFuncArgs, vm: &VirtualMachine) -> PyResult { |
| 76 | let args = args.into_args(vm); |
| 77 | if !vm.use_tracing.get() { |
| 78 | return (self.call)(self.obj, args, vm); |
| 79 | } |
| 80 | // Python functions get 'call'/'return' events from with_frame(). |
| 81 | // Bound methods delegate to the inner callable, which fires its own events. |
| 82 | // All other callables (built-in functions, etc.) get 'c_call'/'c_return'/'c_exception'. |
| 83 | let is_python_callable = self.obj.downcast_ref::<PyFunction>().is_some() |
| 84 | || self.obj.downcast_ref::<PyBoundMethod>().is_some(); |
| 85 | if is_python_callable { |
| 86 | (self.call)(self.obj, args, vm) |
| 87 | } else { |
| 88 | let callable = self.obj.to_owned(); |
| 89 | vm.trace_event(TraceEvent::CCall, Some(callable.clone()))?; |
| 90 | let result = (self.call)(self.obj, args, vm); |
| 91 | if result.is_ok() { |
| 92 | vm.trace_event(TraceEvent::CReturn, Some(callable))?; |
| 93 | } else { |
| 94 | let _ = vm.trace_event(TraceEvent::CException, Some(callable)); |
| 95 | } |
| 96 | result |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | /// Vectorcall dispatch: use vectorcall slot if available, else fall back to FuncArgs. |
| 101 | #[inline] |
no test coverage detected