8000 Don't capture stderr in _check_and_log_subprocess. · matplotlib/matplotlib@31e1d95 · GitHub
[go: up one dir, main page]

Skip to content

Commit 31e1d95

Browse files
committed
Don't capture stderr in _check_and_log_subprocess.
... to avoid capturing kpsewhich's "warning: running with administrator privileges" (that occurs at the only place where we actually care about the return value of _check_and_log_subprocess).
1 parent 110f297 commit 31e1d95

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,24 +2030,25 @@ def _pformat_subprocess(command):
20302030

20312031
def _check_and_log_subprocess(command, logger, **kwargs):
20322032
"""
2033-
Run *command* using `subprocess.check_output`. If it succeeds, return the
2034-
output (stdout and stderr); if not, raise an exception whose text includes
2035-
the failed command and captured output. Both the command and the output
2036-
are logged at DEBUG level on *logger*.
2033+
Run *command*. If it succeeds, return the its stdout output; if not, raise
2034+
an exception whose text includes the failed command and captured stdout and
2035+
stderr output. Both the command and the output are logged at DEBUG level
2036+
on *logger*.
20372037
"""
20382038
logger.debug('%s', _pformat_subprocess(command))
2039-
try:
2040-
report = subprocess.check_output(
2041-
command, stderr=subprocess.STDOUT, **kwargs)
2042-
except subprocess.CalledProcessError as exc:
2039+
proc = subprocess.run(
2040+
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)
2041+
if proc.returncode:
20432042
raise RuntimeError(
2044-
'The command\n'
2045-
' {}\n'
2046-
'failed and generated the following output:\n'
2047-
'{}'
2048-
.format(_pformat_subprocess(command), exc.output.decode('utf-8')))
2049-
logger.debug(report)
2050-
return report
2043+
f"The command\n"
2044+
f" {_pformat_subprocess(command)}\n"
2045+
f"failed and generated the following output:\n"
2046+
f"{proc.stdout.decode('utf-8')}\n"
2047+
f"and the following error:\n"
2048+
f"{proc.stderr.decode('utf-8')}")
2049+
logger.debug("stdout:\n%s", proc.stdout)
2050+
logger.debug("stderr:\n%s", proc.stderr)
2051+
return proc.stdout
20512052

20522053

20532054
def _check_isinstance(types, **kwargs):

0 commit comments

Comments
 (0)
0