diff options
author | Damien George <damien.p.george@gmail.com> | 2014-08-13 13:22:24 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-08-13 13:22:24 +0100 |
commit | 9b7a8ee8f1032a1c9172afe0bd3ac5be7780e4a2 (patch) | |
tree | 79b3b74827761d1db8b2081a2e1e2be24322a527 /py/objint.c | |
parent | 9d02780eafd9546354fd3ac429b0211f52331650 (diff) |
py: Fix mult by negative number of tuple, list, str, bytes.
Multiplication of a tuple, list, str or bytes now yields an empty
sequence (instead of crashing). Addresses issue #799
Also added ability to mult bytes on LHS by integer.
Diffstat (limited to 'py/objint.c')
-rw-r--r-- | py/objint.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/py/objint.c b/py/objint.c index c08bf7da6..d088ae1a8 100644 --- a/py/objint.c +++ b/py/objint.c @@ -289,7 +289,7 @@ mp_obj_t mp_obj_int_binary_op_extra_cases(int op, mp_obj_t lhs_in, mp_obj_t rhs_ // true acts as 0 return mp_binary_op(op, lhs_in, MP_OBJ_NEW_SMALL_INT(1)); } 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)) { + if (MP_OBJ_IS_STR(rhs_in) || MP_OBJ_IS_TYPE(rhs_in, &mp_type_bytes) || 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); } |