diff options
| author | Jim Mussared <jim.mussared@gmail.com> | 2023-05-24 17:06:08 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-06-01 16:21:37 +1000 |
| commit | 952a78f88af5809b2fbf30ed9fa86649cc71c2aa (patch) | |
| tree | 98a76f166cb483ea7c3f75ff7152243e1ffa225e | |
| parent | 99a0c45aef6f0fd64f86a2048b999bdb7d74377c (diff) | |
unix/main: Add NLR scope for checking module __path__.
If the module has a user-defined getattr, this could raise.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
| -rw-r--r-- | ports/unix/main.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ports/unix/main.c b/ports/unix/main.c index 21f59862a..fc0f6da7b 100644 --- a/ports/unix/main.c +++ b/ports/unix/main.c @@ -664,8 +664,9 @@ MP_NOINLINE int main_(int argc, char **argv) { return handle_uncaught_exception(nlr.ret_val) & 0xff; } + // If this module is a package, see if it has a `__main__.py`. mp_obj_t dest[2]; - mp_load_method_maybe(mod, MP_QSTR___path__, dest); + mp_load_method_protected(mod, MP_QSTR___path__, dest, true); if (dest[0] != MP_OBJ_NULL && !subpkg_tried) { subpkg_tried = true; vstr_t vstr; |
