Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fd9c59d

Browse filesBrowse files
authored
Merge pull request #14395 from congma/work-around-nonzero-exit-status-when-guessing-implementation-via-subprocess
MAINT: work around non-zero exit status of "pdftops -v" command.
2 parents 4f2ee1a + ad5ffed commit fd9c59d
Copy full SHA for fd9c59d

File tree

Expand file treeCollapse file tree

1 file changed

+11
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-4
lines changed

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+11-4Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,20 @@ def _get_executable_info(name):
314314
If the executable is not one that we know how to query.
315315
"""
316316

317-
def impl(args, regex, min_ver=None):
317+
def impl(args, regex, min_ver=None, ignore_exit_code=False):
318318
# Execute the subprocess specified by args; capture stdout and stderr.
319319
# Search for a regex match in the output; if the match succeeds, the
320320
# first group of the match is the version.
321321
# Return an _ExecInfo if the executable exists, and has a version of
322322
# at least min_ver (if set); else, raise FileNotFoundError.
323-
output = subprocess.check_output(
324-
args, stderr=subprocess.STDOUT, universal_newlines=True)
323+
try:
324+
output = subprocess.check_output(
325+
args, stderr=subprocess.STDOUT, universal_newlines=True)
326+
except subprocess.CalledProcessError as _cpe:
327+
if ignore_exit_code:
328+
output = _cpe.output
329+
else:
330+
raise _cpe
325331
match = re.search(regex, output)
326332
if match:
327333
version = LooseVersion(match.group(1))
@@ -378,7 +384,8 @@ def impl(args, regex, min_ver=None):
378384
"Failed to find an ImageMagick installation")
379385
return impl([path, "--version"], r"^Version: ImageMagick (\S*)")
380386
elif name == "pdftops":
381-
info = impl(["pdftops", "-v"], "^pdftops version (.*)")
387+
info = impl(["pdftops", "-v"], "^pdftops version (.*)",
388+
ignore_exit_code=True)
382389
if info and not ("3.0" <= info.version
383390
# poppler version numbers.
384391
or "0.9" <= info.version <= "1.0"):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.