Skip to content

Commit 3d4e9b1

Browse files
committed
warn if module is found but fails to import in PIL.features
1 parent e971674 commit 3d4e9b1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/PIL/features.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ def check_module(feature):
3333
try:
3434
__import__(module)
3535
return True
36-
except ImportError:
36+
except ModuleNotFoundError:
37+
return False
38+
except ImportError as ex:
39+
warnings.warn(str(ex))
3740
return False
3841

3942

@@ -145,7 +148,10 @@ def check_feature(feature):
145148
try:
146149
imported_module = __import__(module, fromlist=["PIL"])
147150
return getattr(imported_module, flag)
148-
except ImportError:
151+
except ModuleNotFoundError:
152+
return None
153+
except ImportError as ex:
154+
warnings.warn(str(ex))
149155
return None
150156

151157

0 commit comments

Comments
 (0)