py/objboundmeth: Support __func__ property as in CPython
This gives access to the function underlying the bound method. Used in the converted CPython stdlib logging.Formatter class to handle overrriding a default converter method bound to a class variable. The method becomes bound when accessed from an instance of that class. I didn't investigate why CircuitPython turns it into a bound method.
This commit is contained in:
parent
a63555abc1
commit
b897603cfa
@ -92,6 +92,9 @@ STATIC void bound_meth_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
if (attr == MP_QSTR___name__) {
|
||||
mp_obj_bound_meth_t *o = MP_OBJ_TO_PTR(self_in);
|
||||
dest[0] = MP_OBJ_NEW_QSTR(mp_obj_fun_get_name(o->meth));
|
||||
} else if (attr == MP_QSTR___func__) {
|
||||
mp_obj_bound_meth_t *o = MP_OBJ_TO_PTR(self_in);
|
||||
dest[0] = o->meth;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user