You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Commit d96cfd1 introduced a regression in
testing for bool objects, that such objects were in some cases no longer
recognised and bools, eg when using mp_obj_is_type(o, &mp_type_bool), or
mp_obj_is_integer(o).
This commit fixes that problem by adding mp_obj_is_bool(o). Builds with
MICROPY_OBJ_IMMEDIATE_OBJS enabled check if the object is any of the const
True or False objects. Builds without it use the old method of ->type
checking, which compiles to smaller code (compared with the former
mentioned method).
Fixesmicropython#5538.
// Note: these are kept as macros because inline functions sometimes use much
666
666
// more code space than the equivalent macros, depending on the compiler.
667
667
#definemp_obj_is_type(o, t) (mp_obj_is_obj(o) && (((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type == (t))) // this does not work for checking int, str or fun; use below macros for that
668
+
#ifMICROPY_OBJ_IMMEDIATE_OBJS
669
+
// bool's are immediates, not real objects, so test for the 2 possible values.
staticinlineboolmp_obj_is_integer(mp_const_obj_to) { returnmp_obj_is_int(o) ||mp_obj_is_type(o, &mp_type_bool); } // returns true if o is bool, small int or long int
730
+
staticinlineboolmp_obj_is_integer(mp_const_obj_to) { returnmp_obj_is_int(o) ||mp_obj_is_bool(o); } // returns true if o is bool, small int or long int
0 commit comments