Commit a78fc94f authored by Damien George's avatar Damien George

py/objarray: Fix patch that restricts array equality to allow more cases

parent 817acad9
......@@ -301,7 +301,10 @@ STATIC mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs
if (!mp_get_buffer(rhs_in, &rhs_bufinfo, MP_BUFFER_READ)) {
return mp_const_false;
if (!MP_OBJ_IS_TYPE(rhs_in, &mp_type_array) || lhs_bufinfo.typecode != rhs_bufinfo.typecode) {
// Only allow: bytearray==bytes, bytearray==bytearray, array(T)==array(T)
if (!((lhs_bufinfo.typecode == BYTEARRAY_TYPECODE && MP_OBJ_IS_TYPE(rhs_in, &mp_type_bytes))
|| (lhs_bufinfo.typecode == BYTEARRAY_TYPECODE && rhs_bufinfo.typecode == BYTEARRAY_TYPECODE)
|| (MP_OBJ_IS_TYPE(rhs_in, &mp_type_array) && lhs_bufinfo.typecode == rhs_bufinfo.typecode))) {
mp_raise_NotImplementedError("array equality with different types");
return mp_obj_new_bool(mp_seq_cmp_bytes(op, lhs_bufinfo.buf, lhs_bufinfo.len, rhs_bufinfo.buf, rhs_bufinfo.len));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment