File tree 1 file changed +7
-2
lines changed
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:
23
23
24
24
From https://docs.python.org/3/library/importlib.html#implementing-lazy-imports
25
25
"""
26
+ # Workaround for PYTHON-4424.
27
+ if "__compiled__" in globals ():
28
+ return importlib .import_module (name )
26
29
try :
27
30
spec = importlib .util .find_spec (name )
28
31
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
30
34
if spec is None :
31
- raise ModuleNotFoundError (name = name )
35
+ # Note: this cannot be ModuleNotFoundError, see PYTHON-4424.
36
+ raise ImportError (name = name )
32
37
assert spec is not None
33
38
loader = importlib .util .LazyLoader (spec .loader ) # type:ignore[arg-type]
34
39
spec .loader = loader
You can’t perform that action at this time.
0 commit comments