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).
This commit is contained in:
Damien George
2017-08-09 21:25:48 +10:00
parent eb2784e8a2
commit 3d25d9c7d9
2 changed files with 14 additions and 2 deletions

View File

@@ -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) {