From 3d4e9b107d22a3a3c4dee6fb20eb25d6f2639da8 Mon Sep 17 00:00:00 2001 From: nulano Date: Fri, 31 Mar 2023 02:57:58 +0200 Subject: [PATCH] warn if module is found but fails to import in PIL.features --- src/PIL/features.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PIL/features.py b/src/PIL/features.py index 6f9d99e76..80a16a75e 100644 --- a/src/PIL/features.py +++ b/src/PIL/features.py @@ -33,7 +33,10 @@ def check_module(feature): try: __import__(module) return True - except ImportError: + except ModuleNotFoundError: + return False + except ImportError as ex: + warnings.warn(str(ex)) return False @@ -145,7 +148,10 @@ def check_feature(feature): try: imported_module = __import__(module, fromlist=["PIL"]) return getattr(imported_module, flag) - except ImportError: + except ModuleNotFoundError: + return None + except ImportError as ex: + warnings.warn(str(ex)) return None