@@ -101,7 +101,7 @@ STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_arg
101101}
102102
103103// Don't pass MP_BINARY_OP_NOT_EQUAL here
104- STATIC bool tuple_cmp_helper (mp_uint_t op , mp_obj_t self_in , mp_obj_t another_in ) {
104+ STATIC mp_obj_t tuple_cmp_helper (mp_uint_t op , mp_obj_t self_in , mp_obj_t another_in ) {
105105 // type check is done on getiter method to allow tuple, namedtuple, attrtuple
106106 mp_check_self (mp_obj_get_type (self_in )-> getiter == mp_obj_tuple_getiter );
107107 mp_obj_type_t * another_type = mp_obj_get_type (another_in );
@@ -110,12 +110,15 @@ STATIC bool tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in
110110 // Slow path for user subclasses
111111 another_in = mp_instance_cast_to_native_base (another_in , MP_OBJ_FROM_PTR (& mp_type_tuple ));
112112 if (another_in == MP_OBJ_NULL ) {
113- return false;
113+ if (op == MP_BINARY_OP_EQUAL ) {
114+ return mp_const_false ;
115+ }
116+ return MP_OBJ_NULL ;
114117 }
115118 }
116119 mp_obj_tuple_t * another = MP_OBJ_TO_PTR (another_in );
117120
118- return mp_seq_cmp_objs (op , self -> items , self -> len , another -> items , another -> len );
121+ return mp_obj_new_bool ( mp_seq_cmp_objs (op , self -> items , self -> len , another -> items , another -> len ) );
119122}
120123
121124mp_obj_t mp_obj_tuple_unary_op (mp_unary_op_t op , mp_obj_t self_in ) {
@@ -166,7 +169,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
166169 case MP_BINARY_OP_LESS_EQUAL :
167170 case MP_BINARY_OP_MORE :
168171 case MP_BINARY_OP_MORE_EQUAL :
169- return mp_obj_new_bool ( tuple_cmp_helper (op , lhs , rhs ) );
172+ return tuple_cmp_helper (op , lhs , rhs );
170173
171174 default :
172175 return MP_OBJ_NULL ; // op not supported
0 commit comments