py/runtime: Simplify handling of containment binary operator.
In mp_binary_op, there is no need to explicitly check for type->getiter being non-null and raising an exception because this is handled exactly by mp_getiter(). So just call the latter unconditionally.
This commit is contained in:
parent
067bf849d2
commit
9783ac282e
12
py/runtime.c
12
py/runtime.c
|
@ -536,8 +536,8 @@ mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
|
|||
return res;
|
||||
}
|
||||
}
|
||||
if (type->getiter != NULL) {
|
||||
/* second attempt, walk the iterator */
|
||||
|
||||
// final attempt, walk the iterator (will raise if rhs is not iterable)
|
||||
mp_obj_iter_buf_t iter_buf;
|
||||
mp_obj_t iter = mp_getiter(rhs, &iter_buf);
|
||||
mp_obj_t next;
|
||||
|
@ -549,14 +549,6 @@ mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
|
|||
return mp_const_false;
|
||||
}
|
||||
|
||||
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
|
||||
mp_raise_TypeError("object not iterable");
|
||||
} else {
|
||||
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
|
||||
"'%s' object is not iterable", mp_obj_get_type_str(rhs)));
|
||||
}
|
||||
}
|
||||
|
||||
// generic binary_op supplied by type
|
||||
mp_obj_type_t *type;
|
||||
generic_binary_op:
|
||||
|
|
Loading…
Reference in New Issue