Commit ca318bba authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

mp_obj_equal(): Compare small and long ints properly.

By dispatching to long int methods.
parent 76a90f2f
......@@ -108,9 +108,15 @@ bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2) {
return val == 0;
} else if (o2 == mp_const_true) {
return val == 1;
} else {
return false;
} else if (MP_OBJ_IS_TYPE(o2, &int_type)) {
// 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)) {
return false;
......
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