File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -23,12 +23,17 @@ def lazy_import(name: str) -> ModuleType:
2323
2424 From https://docs.python.org/3/library/importlib.html#implementing-lazy-imports
2525 """
26+ # Workaround for PYTHON-4424.
27+ if "__compiled__" in globals ():
28+ return importlib .import_module (name )
2629 try :
2730 spec = importlib .util .find_spec (name )
2831 except ValueError :
29- raise ModuleNotFoundError (name = name ) from None
32+ # Note: this cannot be ModuleNotFoundError, see PYTHON-4424.
33+ raise ImportError (name = name ) from None
3034 if spec is None :
31- raise ModuleNotFoundError (name = name )
35+ # Note: this cannot be ModuleNotFoundError, see PYTHON-4424.
36+ raise ImportError (name = name )
3237 assert spec is not None
3338 loader = importlib .util .LazyLoader (spec .loader ) # type:ignore[arg-type]
3439 spec .loader = loader
You can’t perform that action at this time.
0 commit comments