diff options
| author | Damien George | 2015-01-27 18:02:25 +0000 |
|---|---|---|
| committer | Damien George | 2015-01-27 18:02:25 +0000 |
| commit | a5efcd474563ed4e3d979a619f073abab8379a09 (patch) | |
| tree | 89ec313adc7023552dbb09ad92e0ba9ff00082ef /py/objtype.c | |
| parent | a9dc9b8f6dc29d842f0a7427cc3cf068ae1cfbea (diff) | |
py: Specify unary/binary op name in TypeError error message.
Eg, "() + 1" now tells you that __add__ is not supported for tuple and
int types (before it just said the generic "binary operator"). We reuse
the table of names for slot lookup because it would be a waste of code
space to store the pretty name for each operator.
Diffstat (limited to 'py/objtype.c')
| -rw-r--r-- | py/objtype.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/py/objtype.c b/py/objtype.c index 46e892a12..53408a07e 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -323,7 +323,7 @@ mp_obj_t instance_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, c return o; } -STATIC const qstr unary_op_method_name[] = { +const qstr mp_unary_op_method_name[] = { [MP_UNARY_OP_BOOL] = MP_QSTR___bool__, [MP_UNARY_OP_LEN] = MP_QSTR___len__, //[MP_UNARY_OP_POSITIVE, @@ -334,7 +334,7 @@ STATIC const qstr unary_op_method_name[] = { STATIC mp_obj_t instance_unary_op(mp_uint_t op, mp_obj_t self_in) { mp_obj_instance_t *self = self_in; - qstr op_name = unary_op_method_name[op]; + qstr op_name = mp_unary_op_method_name[op]; /* Still try to lookup native slot if (op_name == 0) { return MP_OBJ_NULL; |
