Skip to content

Commit aa955c9

Browse files
committed
Support **kwargs to __call__.
1 parent 5c7b0da commit aa955c9

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

vm/src/vm.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,27 @@ impl VirtualMachine {
170170
obj: &PyObjectRef,
171171
method_name: &str,
172172
args: Vec<PyObjectRef>,
173+
) -> PyResult {
174+
self.call_method_pyargs(
175+
obj,
176+
method_name,
177+
PyFuncArgs {
178+
args: args,
179+
kwargs: vec![],
180+
},
181+
)
182+
}
183+
184+
pub fn call_method_pyargs(
185+
&mut self,
186+
obj: &PyObjectRef,
187+
method_name: &str,
188+
args: PyFuncArgs,
173189
) -> PyResult {
174190
let cls = obj.typ();
175191
let func = cls.get_attr(method_name).unwrap();
176192
trace!("vm.call_method {:?} {:?} -> {:?}", obj, method_name, func);
177193
let wrapped = self.call_get_descriptor(func, obj.clone())?;
178-
let args = PyFuncArgs {
179-
args: args,
180-
kwargs: vec![],
181-
};
182194
self.invoke(wrapped, args)
183195
}
184196

@@ -195,12 +207,12 @@ impl VirtualMachine {
195207
name: _,
196208
dict: _,
197209
mro: _,
198-
} => self.call_method(&func_ref, "__call__", args.args),
210+
} => self.call_method_pyargs(&func_ref, "__call__", args),
199211
PyObjectKind::BoundMethod {
200212
ref function,
201213
ref object,
202214
} => self.invoke(function.clone(), args.insert(object.clone())),
203-
PyObjectKind::Instance { .. } => self.call_method(&func_ref, "__call__", args.args),
215+
PyObjectKind::Instance { .. } => self.call_method_pyargs(&func_ref, "__call__", args),
204216
ref kind => {
205217
unimplemented!("invoke unimplemented for: {:?}", kind);
206218
}

0 commit comments

Comments
 (0)