aboutsummaryrefslogtreecommitdiff
path: root/py/objstr.c
diff options
context:
space:
mode:
authorYonatan Goldschmidt <yon.goldschmidt@gmail.com>2020-01-22 13:19:14 +0100
committerDamien George <damien.p.george@gmail.com>2020-01-24 10:53:45 +1100
commitd9433d3e9497a4ec4cd51eb78d6ca602f310ce91 (patch)
treef615daac13267b60cc61f60d5aaa7e163ef7f43e /py/objstr.c
parent27f41e624c39f661f917c20b58daf6637ada0982 (diff)
py/obj.h: Add and use mp_obj_is_bool() helper.
Commit d96cfd13e3a464862cecffb2718c6286b52c77b0 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). Fixes #5538.
Diffstat (limited to 'py/objstr.c')
-rw-r--r--py/objstr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/py/objstr.c b/py/objstr.c
index 454d1cbcc..7e7e86ddd 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -910,7 +910,7 @@ STATIC bool istype(char ch) {
}
STATIC bool arg_looks_integer(mp_obj_t arg) {
- return mp_obj_is_type(arg, &mp_type_bool) || mp_obj_is_int(arg);
+ return mp_obj_is_bool(arg) || mp_obj_is_int(arg);
}
STATIC bool arg_looks_numeric(mp_obj_t arg) {