aboutsummaryrefslogtreecommitdiff
path: root/py/objstr.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-08-09 21:25:48 +1000
committerDamien George <damien.p.george@gmail.com>2017-08-09 21:25:48 +1000
commit3d25d9c7d96f9a54ad510391901af8f5bd82b306 (patch)
tree0f3ce56bee2fe8ffebc6ef7ca4fa0bebf1e0d610 /py/objstr.c
parenteb2784e8a2dc17b0f551b68d2b41eece3e5348a7 (diff)
py/objstr: Raise an exception for wrong type on RHS of str binary op.
The main case to catch is invalid types for the containment operator, of the form str.__contains__(non-str).
Diffstat (limited to 'py/objstr.c')
-rw-r--r--py/objstr.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/py/objstr.c b/py/objstr.c
index ddad7d3bd..cc3dda59e 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -347,8 +347,9 @@ mp_obj_t mp_obj_str_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
rhs_data = bufinfo.buf;
rhs_len = bufinfo.len;
} else {
- // incompatible types
- return MP_OBJ_NULL; // op not supported
+ // LHS is str and RHS has an incompatible type
+ // (except if operation is EQUAL, but that's handled by mp_obj_equal)
+ bad_implicit_conversion(rhs_in);
}
switch (op) {