@@ -170,15 +170,27 @@ impl VirtualMachine {
170
170
obj : & PyObjectRef ,
171
171
method_name : & str ,
172
172
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 ,
173
189
) -> PyResult {
174
190
let cls = obj. typ ( ) ;
175
191
let func = cls. get_attr ( method_name) . unwrap ( ) ;
176
192
trace ! ( "vm.call_method {:?} {:?} -> {:?}" , obj, method_name, func) ;
177
193
let wrapped = self . call_get_descriptor ( func, obj. clone ( ) ) ?;
178
- let args = PyFuncArgs {
179
- args : args,
180
- kwargs : vec ! [ ] ,
181
- } ;
182
194
self . invoke ( wrapped, args)
183
195
}
184
196
@@ -195,12 +207,12 @@ impl VirtualMachine {
195
207
name : _,
196
208
dict : _,
197
209
mro : _,
198
- } => self . call_method ( & func_ref, "__call__" , args . args ) ,
210
+ } => self . call_method_pyargs ( & func_ref, "__call__" , args) ,
199
211
PyObjectKind :: BoundMethod {
200
212
ref function,
201
213
ref object,
202
214
} => 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) ,
204
216
ref kind => {
205
217
unimplemented ! ( "invoke unimplemented for: {:?}" , kind) ;
206
218
}
0 commit comments