summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-03-16 14:30:04 +1100
committerDamien George <damien.p.george@gmail.com>2017-03-16 14:30:04 +1100
commitd279bcff8a18c2153557c2e83cd397f266b5199d (patch)
treef54c1100374a4eaf32f97a52662d5758cefe0ae5 /py
parent7b7ff60f91889f8d601d4b4c6a36e9511fdd40dd (diff)
downloadmicropython-d279bcff8a18c2153557c2e83cd397f266b5199d.tar.gz
micropython-d279bcff8a18c2153557c2e83cd397f266b5199d.zip
py/objstr: Fix eager optimisation of str/bytes addition.
The RHS can only be returned if it is the same type as the LHS.
Diffstat (limited to 'py')
-rw-r--r--py/objstr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/py/objstr.c b/py/objstr.c
index 17d06f88e8..2331004a5b 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -354,7 +354,7 @@ mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
switch (op) {
case MP_BINARY_OP_ADD:
case MP_BINARY_OP_INPLACE_ADD: {
- if (lhs_len == 0) {
+ if (lhs_len == 0 && mp_obj_get_type(rhs_in) == lhs_type) {
return rhs_in;
}
if (rhs_len == 0) {