warn if module is found but fails to import in PIL.features

This commit is contained in:
nulano 2023-03-31 02:57:58 +02:00
parent e971674011
commit 3d4e9b107d
No known key found for this signature in database
GPG Key ID: B650CDF63B705766

View File

@ -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