diff options
author | Damien George <damien.p.george@gmail.com> | 2018-05-10 23:07:19 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-05-10 23:07:19 +1000 |
commit | 29d28c2574d6c0b93fd3fc869b389a61dee12102 (patch) | |
tree | 13124d35ef1c497a39cdef82a8303a606bcc0302 /py/modbuiltins.c | |
parent | 7241d90272f4dfe4100723393cc2f348f5d32c0a (diff) |
py/modbuiltins: In built-in dir make use of mp_load_method_protected.
This gives dir() better behaviour when listing the attributes of a user
type that defines __getattr__: it will now not list those attributes for
which __getattr__ raises AttributeError (meaning the attribute is not
supported by the object).
Diffstat (limited to 'py/modbuiltins.c')
-rw-r--r-- | py/modbuiltins.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/py/modbuiltins.c b/py/modbuiltins.c index 2f3526415..bc99f8261 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -188,7 +188,7 @@ STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) { size_t nqstr = QSTR_TOTAL(); for (size_t i = MP_QSTR_ + 1; i < nqstr; ++i) { mp_obj_t dest[2]; - mp_load_method_maybe(args[0], i, dest); + mp_load_method_protected(args[0], i, dest, false); if (dest[0] != MP_OBJ_NULL) { mp_obj_list_append(dir, MP_OBJ_NEW_QSTR(i)); } |