@@ -101,7 +101,7 @@ STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_arg
101
101
}
102
102
103
103
// 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 ) {
105
105
// type check is done on getiter method to allow tuple, namedtuple, attrtuple
106
106
mp_check_self (mp_obj_get_type (self_in )-> getiter == mp_obj_tuple_getiter );
107
107
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
110
110
// Slow path for user subclasses
111
111
another_in = mp_instance_cast_to_native_base (another_in , MP_OBJ_FROM_PTR (& mp_type_tuple ));
112
112
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 ;
114
117
}
115
118
}
116
119
mp_obj_tuple_t * another = MP_OBJ_TO_PTR (another_in );
117
120
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 ) );
119
122
}
120
123
121
124
mp_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) {
166
169
case MP_BINARY_OP_LESS_EQUAL :
167
170
case MP_BINARY_OP_MORE :
168
171
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 );
170
173
171
174
default :
172
175
return MP_OBJ_NULL ; // op not supported
0 commit comments