Merge pull request #6539 from jepler/issue4171

modbuiltins: Catch most exceptions during dir()
This commit is contained in:
Dan Halbert 2022-06-30 22:53:10 -04:00 committed by GitHub
commit 819b5d12b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -190,8 +190,8 @@ STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
// Implemented by probing all possible qstrs with mp_load_method_maybe
size_t nqstr = QSTR_TOTAL();
for (size_t i = MP_QSTR_ + 1; i < nqstr; ++i) {
mp_obj_t dest[2];
mp_load_method_protected(args[0], i, dest, false);
mp_obj_t dest[2] = {};
mp_load_method_protected(args[0], i, dest, true);
if (dest[0] != MP_OBJ_NULL) {
#if MICROPY_PY_ALL_SPECIAL_METHODS
// Support for __dir__: see if we can dispatch to this special method