diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-11 20:35:02 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-11 20:51:31 +0300 |
commit | 7e7940c39d757a7f8fdeb809455016816ed90272 (patch) | |
tree | 925ee3e6ad01547b0c34f60056cc46e1a4787f4d /py | |
parent | c48d6f7add021e284558c24b25e53115fe185feb (diff) | |
download | micropython-7e7940c39d757a7f8fdeb809455016816ed90272.tar.gz micropython-7e7940c39d757a7f8fdeb809455016816ed90272.zip |
py: Fix __len__ special method result handling.
Having both MP_OBJ_NOT_SUPPORTED and MP_OBJ_NULL is arguably confusing.
Diffstat (limited to 'py')
-rw-r--r-- | py/obj.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -357,7 +357,12 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { } else { mp_obj_type_t *type = mp_obj_get_type(o_in); if (type->unary_op != NULL) { - return type->unary_op(MP_UNARY_OP_LEN, o_in); + mp_obj_t val = type->unary_op(MP_UNARY_OP_LEN, o_in); + // TODO: Here's the case of having MP_OBJ_NOT_SUPPORTED is confusing + if (val == MP_OBJ_NOT_SUPPORTED) { + return MP_OBJ_NULL; + } + return val; } else { return MP_OBJ_NULL; } |