summaryrefslogtreecommitdiffstatshomepage
path: root/py/objbool.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/objbool.c')
-rw-r--r--py/objbool.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/py/objbool.c b/py/objbool.c
index 179ab76596..e31e7a2a42 100644
--- a/py/objbool.c
+++ b/py/objbool.c
@@ -49,12 +49,14 @@ STATIC void bool_print(void (*print)(void *env, const char *fmt, ...), void *env
}
STATIC mp_obj_t bool_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
- // TODO check n_kw == 0
+ mp_arg_check_num(n_args, n_kw, 0, 1, false);
switch (n_args) {
- case 0: return mp_const_false;
- case 1: if (mp_obj_is_true(args[0])) { return mp_const_true; } else { return mp_const_false; }
- default: nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "bool takes at most 1 argument, %d given", n_args));
+ case 0:
+ return mp_const_false;
+ case 1:
+ default: // must be 0 or 1
+ if (mp_obj_is_true(args[0])) { return mp_const_true; } else { return mp_const_false; }
}
}