summaryrefslogtreecommitdiff
path: root/py/objboundmeth.c
diff options
context:
space:
mode:
authorNoralf Trønnes <noralf@tronnes.org>2018-10-07 15:54:36 +0200
committerNoralf Trønnes <noralf@tronnes.org>2018-10-07 19:36:24 +0200
commitb897603cfa6f0f37dea4e1f9592a78d34d809f23 (patch)
treeba06cc1fc6c023b43d9cd21a12a7607e7b6af480 /py/objboundmeth.c
parenta63555abc1ce07fe4e9420b5835865282adcd1db (diff)
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.
Diffstat (limited to 'py/objboundmeth.c')
-rw-r--r--py/objboundmeth.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/py/objboundmeth.c b/py/objboundmeth.c
index b0df6a68a..a05680d41 100644
--- a/py/objboundmeth.c
+++ b/py/objboundmeth.c
@@ -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