mp_obj_equal(): Compare small and long ints properly.
By dispatching to long int methods.
This commit is contained in:
parent
76a90f2f60
commit
ca318bba0d
10
py/obj.c
10
py/obj.c
@ -108,9 +108,15 @@ bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2) {
|
|||||||
return val == 0;
|
return val == 0;
|
||||||
} else if (o2 == mp_const_true) {
|
} else if (o2 == mp_const_true) {
|
||||||
return val == 1;
|
return val == 1;
|
||||||
} else {
|
} else if (MP_OBJ_IS_TYPE(o2, &int_type)) {
|
||||||
return false;
|
// If o2 is long int, dispatch to its virtual methods
|
||||||
|
mp_obj_base_t *o = o2;
|
||||||
|
if (o->type->binary_op != NULL) {
|
||||||
|
mp_obj_t r = o->type->binary_op(RT_COMPARE_OP_EQUAL, o2, o1);
|
||||||
|
return r == mp_const_true ? true : false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} else if (MP_OBJ_IS_QSTR(o1) || MP_OBJ_IS_QSTR(o2)) {
|
} else if (MP_OBJ_IS_QSTR(o1) || MP_OBJ_IS_QSTR(o2)) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user