Skip to content

Commit 285683d

Browse files
committed
objboundmeth: If detailed reporting enabled, print object content.
Similar to closure and cell.
1 parent 7aca1ca commit 285683d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

py/objboundmeth.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ typedef struct _mp_obj_bound_meth_t {
3939
mp_obj_t self;
4040
} mp_obj_bound_meth_t;
4141

42+
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
43+
STATIC void bound_meth_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
44+
mp_obj_bound_meth_t *o = o_in;
45+
print(env, "<bound_method %p ", o);
46+
mp_obj_print_helper(print, env, o->self, PRINT_REPR);
47+
print(env, ".");
48+
mp_obj_print_helper(print, env, o->meth, PRINT_REPR);
49+
print(env, ">");
50+
}
51+
#endif
52+
4253
mp_obj_t bound_meth_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
4354
mp_obj_bound_meth_t *self = self_in;
4455

@@ -65,6 +76,9 @@ mp_obj_t bound_meth_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_
6576
const mp_obj_type_t bound_meth_type = {
6677
{ &mp_type_type },
6778
.name = MP_QSTR_bound_method,
79+
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
80+
.print = bound_meth_print,
81+
#endif
6882
.call = bound_meth_call,
6983
};
7084

0 commit comments

Comments
 (0)