Skip to content

Commit b0003af

Browse files
authored
stubtest: catch BaseException on module imports (#14284)
This came up in python/typeshed#9347
1 parent 7849b8f commit b0003af

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mypy/stubtest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ def test_module(module_name: str) -> Iterator[Error]:
205205

206206
try:
207207
runtime = silent_import_module(module_name)
208-
except Exception as e:
208+
except KeyboardInterrupt:
209+
raise
210+
except BaseException as e:
209211
yield Error([module_name], f"failed to import, {type(e).__name__}: {e}", stub, MISSING)
210212
return
211213

@@ -1500,7 +1502,9 @@ def build_stubs(modules: list[str], options: Options, find_submodules: bool = Fa
15001502
for m in pkgutil.walk_packages(runtime.__path__, runtime.__name__ + ".")
15011503
if m.name not in all_modules
15021504
)
1503-
except Exception:
1505+
except KeyboardInterrupt:
1506+
raise
1507+
except BaseException:
15041508
pass
15051509

15061510
if sources:

0 commit comments

Comments
 (0)