Skip to content

Commit 904959b

Browse files
committed
Add builtinfunc.__call__
1 parent a129080 commit 904959b

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

vm/src/obj/objfunction.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::function::{Args, KwArgs};
1+
use crate::function::PyFuncArgs;
22
use crate::obj::objcode::PyCodeRef;
33
use crate::obj::objdict::PyDictRef;
44
use crate::obj::objtuple::PyTupleRef;
@@ -44,8 +44,8 @@ impl PyValue for PyFunction {
4444
}
4545

4646
impl PyFunctionRef {
47-
fn call(self, args: Args, kwargs: KwArgs, vm: &VirtualMachine) -> PyResult {
48-
vm.invoke(&self.into_object(), (&args, &kwargs))
47+
fn call(func: PyObjectRef, args: PyFuncArgs, vm: &VirtualMachine) -> PyResult {
48+
vm.invoke(&func, args)
4949
}
5050

5151
fn code(self, _vm: &VirtualMachine) -> PyCodeRef {
@@ -92,7 +92,8 @@ pub fn init(context: &PyContext) {
9292

9393
let builtin_function_or_method_type = &context.types.builtin_function_or_method_type;
9494
extend_class!(context, builtin_function_or_method_type, {
95-
"__get__" => context.new_rustfunc(bind_method)
95+
"__get__" => context.new_rustfunc(bind_method),
96+
"__call__" => context.new_rustfunc(PyFunctionRef::call),
9697
});
9798
}
9899

0 commit comments

Comments
 (0)