Skip to content

Commit eb2784e

Browse files
committed
py/objtuple: Allow to use inplace-multiplication operator on tuples.
1 parent cb7ecda commit eb2784e

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

py/objtuple.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
148148
mp_seq_cat(s->items, o->items, o->len, p->items, p->len, mp_obj_t);
149149
return MP_OBJ_FROM_PTR(s);
150150
}
151-
case MP_BINARY_OP_MULTIPLY: {
151+
case MP_BINARY_OP_MULTIPLY:
152+
case MP_BINARY_OP_INPLACE_MULTIPLY: {
152153
mp_int_t n;
153154
if (!mp_obj_get_int_maybe(rhs, &n)) {
154155
return MP_OBJ_NULL; // op not supported

tests/basics/tuple_mult.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
c = a * 3
1212
print(a, c)
1313

14+
# inplace multiplication
15+
a = (1, 2)
16+
a *= 2
17+
print(a)
18+
1419
# unsupported type on RHS
1520
try:
1621
() * None

0 commit comments

Comments
 (0)