@@ -17,8 +17,8 @@ use super::obj::objsequence;
17
17
use super :: obj:: objstr;
18
18
use super :: obj:: objtype;
19
19
use super :: pyobject:: {
20
- AttributeProtocol , DictProtocol , PyContext , PyFuncArgs , PyObjectKind , PyObjectRef , PyResult ,
21
- TypeProtocol ,
20
+ AttributeProtocol , DictProtocol , IdProtocol , PyContext , PyFuncArgs , PyObjectKind , PyObjectRef ,
21
+ PyResult , TypeProtocol ,
22
22
} ;
23
23
use super :: stdlib;
24
24
use super :: sysmodule;
@@ -93,7 +93,11 @@ impl VirtualMachine {
93
93
}
94
94
95
95
pub fn new_bound_method ( & self , function : PyObjectRef , object : PyObjectRef ) -> PyObjectRef {
96
- self . ctx . new_bound_method ( function, object)
96
+ if object. is ( & self . get_none ( ) ) {
97
+ function
98
+ } else {
99
+ self . ctx . new_bound_method ( function, object)
100
+ }
97
101
}
98
102
99
103
pub fn get_type ( & self ) -> PyObjectRef {
@@ -202,7 +206,13 @@ impl VirtualMachine {
202
206
let cls = obj. typ ( ) ;
203
207
match cls. get_attr ( method_name) {
204
208
Some ( func) => {
205
- trace ! ( "vm.call_method {:?} {:?} -> {:?}" , obj, method_name, func) ;
209
+ trace ! (
210
+ "vm.call_method {:?} {:?} {:?} -> {:?}" ,
211
+ obj,
212
+ cls,
213
+ method_name,
214
+ func
215
+ ) ;
206
216
let wrapped = self . call_get_descriptor ( func, obj. clone ( ) ) ?;
207
217
self . invoke ( wrapped, args)
208
218
}
@@ -423,6 +433,7 @@ impl VirtualMachine {
423
433
424
434
// get_attribute should be used for full attribute access (usually from user code).
425
435
pub fn get_attribute ( & mut self , obj : PyObjectRef , attr_name : PyObjectRef ) -> PyResult {
436
+ trace ! ( "vm.__getattribute__: {:?} {:?}" , obj, attr_name) ;
426
437
self . call_method ( & obj, "__getattribute__" , vec ! [ attr_name] )
427
438
}
428
439
0 commit comments