From b897603cfa6f0f37dea4e1f9592a78d34d809f23 Mon Sep 17 00:00:00 2001 From: Noralf Trønnes Date: Sun, 7 Oct 2018 15:54:36 +0200 Subject: 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. --- py/objboundmeth.c | 3 +++ 1 file changed, 3 insertions(+) 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 -- cgit v1.2.3