Skip to content

Commit 7f94eb2

Browse files
committed
catch OSError instead of FileNotFoundError to resolve #15399
While finding available movie writers, if the executable is presented but cannot be run, the import process will fail upon calling '_get_executable_info' since it only handled CalledProcessError and FileNotFoundError. In this commit, we catch OSError instead of FileNotFoundError in '__init__.py' and log the error message in 'animation.py' to improve the import robustness.
1 parent e672bf8 commit 7f94eb2

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/matplotlib/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ def impl(args, regex, min_ver=None, ignore_exit_code=False):
337337
output = _cpe.output
338338
else:
339339
raise ExecutableNotFoundError(str(_cpe)) from _cpe
340-
except FileNotFoundError as _fnf:
341-
raise ExecutableNotFoundError(str(_fnf)) from _fnf
340+
except OSError as _ose:
341+
raise ExecutableNotFoundError(str(_ose)) from _ose
342342
match = re.search(regex, output)
343343
if match:
344344
version = LooseVersion(match.group(1))

lib/matplotlib/animation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,9 @@ def bin_path(cls):
723723
def isAvailable(cls):
724724
try:
725725
return super().isAvailable()
726-
except mpl.ExecutableNotFoundError:
726+
except mpl.ExecutableNotFoundError as _enf:
727727
# May be raised by get_executable_info.
728+
_log.debug('ImageMagick unavailable due to: %s', _enf)
728729
return False
729730

730731

0 commit comments

Comments
 (0)