diff options
author | Damien George <damien.p.george@gmail.com> | 2015-11-23 15:57:00 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-11-23 15:57:00 +0000 |
commit | 0e3f29cc9973dc3c522941858f1f0fb4c6b2cba0 (patch) | |
tree | 3fe6fc35c3a453ae6a525a18170cd5bce90220f6 /py/modbuiltins.c | |
parent | a8aa1998ce1d602738dfab15a5d8b9335586aad6 (diff) | |
download | micropython-0e3f29cc9973dc3c522941858f1f0fb4c6b2cba0.tar.gz micropython-0e3f29cc9973dc3c522941858f1f0fb4c6b2cba0.zip |
py: Check that second argument to hasattr is actually a string.
Fixes issue #1623.
Diffstat (limited to 'py/modbuiltins.c')
-rw-r--r-- | py/modbuiltins.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/py/modbuiltins.c b/py/modbuiltins.c index dd8499ba6d..e39c20b60a 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -529,14 +529,14 @@ STATIC mp_obj_t mp_builtin_setattr(mp_obj_t base, mp_obj_t attr, mp_obj_t value) MP_DEFINE_CONST_FUN_OBJ_3(mp_builtin_setattr_obj, mp_builtin_setattr); STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) { - assert(MP_OBJ_IS_QSTR(attr_in)); + qstr attr = mp_obj_str_get_qstr(attr_in); mp_obj_t dest[2]; // TODO: https://docs.python.org/3/library/functions.html?highlight=hasattr#hasattr // explicitly says "This is implemented by calling getattr(object, name) and seeing // whether it raises an AttributeError or not.", so we should explicitly wrap this // in nlr_push and handle exception. - mp_load_method_maybe(object_in, MP_OBJ_QSTR_VALUE(attr_in), dest); + mp_load_method_maybe(object_in, attr, dest); return mp_obj_new_bool(dest[0] != MP_OBJ_NULL); } |