Skip to content

Commit

Permalink
stubtest: catch BaseException on module imports (#14284)
Browse files Browse the repository at this point in the history
This came up in python/typeshed#9347
  • Loading branch information
hauntsaninja authored Dec 12, 2022
1 parent 7849b8f commit b0003af
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ def test_module(module_name: str) -> Iterator[Error]:

try:
runtime = silent_import_module(module_name)
except Exception as e:
except KeyboardInterrupt:
raise
except BaseException as e:
yield Error([module_name], f"failed to import, {type(e).__name__}: {e}", stub, MISSING)
return

Expand Down Expand Up @@ -1500,7 +1502,9 @@ def build_stubs(modules: list[str], options: Options, find_submodules: bool = Fa
for m in pkgutil.walk_packages(runtime.__path__, runtime.__name__ + ".")
if m.name not in all_modules
)
except Exception:
except KeyboardInterrupt:
raise
except BaseException:
pass

if sources:
Expand Down

0 comments on commit b0003af

Please sign in to comment.