summaryrefslogtreecommitdiffstatshomepage
path: root/py/objlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/objlist.c')
-rw-r--r--py/objlist.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/py/objlist.c b/py/objlist.c
index fb68e2c566..81040e3b8e 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -125,7 +125,8 @@ static bool list_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
static mp_obj_t list_unary_op(int op, mp_obj_t self_in) {
mp_obj_list_t *self = self_in;
switch (op) {
- case RT_UNARY_OP_NOT: if (self->len == 0) { return mp_const_true; } else { return mp_const_false; }
+ case RT_UNARY_OP_BOOL: return MP_BOOL(self->len != 0);
+ case RT_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->len);
default: return MP_OBJ_NULL; // op not supported for None
}
}