diff options
author | Damien George <damien.p.george@gmail.com> | 2014-05-11 12:10:35 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-05-11 12:10:35 +0100 |
commit | 18ceb7055b43d158e46ff6d0a0389bc3cd05e5d5 (patch) | |
tree | f3b1ad5d9c242a8aec5c0dc58b876e6f57529f05 /py/objtuple.c | |
parent | a7a1a38df43958a267410d333f495db56a8b0902 (diff) | |
parent | eea01186547f0f1568ea1c8f002da4e33b7b0e46 (diff) | |
download | micropython-18ceb7055b43d158e46ff6d0a0389bc3cd05e5d5.tar.gz micropython-18ceb7055b43d158e46ff6d0a0389bc3cd05e5d5.zip |
Merge branch 'master' of github.com:micropython/micropython
Diffstat (limited to 'py/objtuple.c')
-rw-r--r-- | py/objtuple.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/py/objtuple.c b/py/objtuple.c index 7d4e87755f..ca65b28e31 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -99,12 +99,20 @@ mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m // Don't pass MP_BINARY_OP_NOT_EQUAL here STATIC bool tuple_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) { - assert(MP_OBJ_IS_TYPE(self_in, &mp_type_tuple)); - if (!MP_OBJ_IS_TYPE(another_in, &mp_type_tuple)) { - return false; + mp_obj_type_t *self_type = mp_obj_get_type(self_in); + if (self_type->getiter != tuple_getiter) { + assert(0); } + mp_obj_type_t *another_type = mp_obj_get_type(another_in); mp_obj_tuple_t *self = self_in; mp_obj_tuple_t *another = another_in; + if (another_type->getiter != tuple_getiter) { + // Slow path for user subclasses + another = mp_instance_cast_to_native_base(another, &mp_type_tuple); + if (another == MP_OBJ_NULL) { + return false; + } + } return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len); } |