diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-02 12:22:07 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-02 12:22:07 +0100 |
commit | 660aef67c4e7b598d98b7048784065922c7ab393 (patch) | |
tree | c282a939fdd13b514767e1bc97c54e35bb06b456 /py/objint_longlong.c | |
parent | 48815668747a1d684d7fce155b5c54066a9f07e2 (diff) |
py: Allow multiple of str/list/tuple on left by an integer.
Diffstat (limited to 'py/objint_longlong.c')
-rw-r--r-- | py/objint_longlong.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/py/objint_longlong.c b/py/objint_longlong.c index e64cc6734..acbd477a9 100644 --- a/py/objint_longlong.c +++ b/py/objint_longlong.c @@ -9,6 +9,7 @@ #include "mpz.h" #include "objint.h" #include "runtime0.h" +#include "runtime.h" #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG @@ -57,6 +58,13 @@ mp_obj_t int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) { } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_int)) { rhs_val = ((mp_obj_int_t*)rhs_in)->val; } else { + if (op == MP_BINARY_OP_MULTIPLY) { + if (MP_OBJ_IS_STR(rhs_in) || MP_OBJ_IS_TYPE(rhs_in, &mp_type_tuple) || MP_OBJ_IS_TYPE(rhs_in, &mp_type_list)) { + // multiply is commutative for these types, so delegate to them + return mp_binary_op(op, rhs_in, lhs_in); + } + } + // unsupported operation/type return MP_OBJ_NULL; } |