Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 80d93a6

Browse files
committed
Suppress traceback chaining for tex subprocess failures.
For tex failures (e.g., `figtext(.5, .5, "\N{snowman}", usetex=True)`), instead of ``` Traceback (most recent call last): File ".../matplotlib/texmanager.py", line 253, in _run_checked_subprocess report = subprocess.check_output( File "/usr/lib/python3.10/subprocess.py", line 420, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/usr/lib/python3.10/subprocess.py", line 524, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['latex', '-interaction=nonstopmode', '--halt-on-error', '../71cab2b5aca12ed5cad4a481b3b00e42.tex']' returned non-zero exit status 1. The above exception was the direct cause of the following exception: Traceback (most recent call last): <a long traceback> raise RuntimeError( RuntimeError: latex was not able to process the following string: b'\\u2603' Here is the full report generated by latex: This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021) (preloaded format=latex) <the tex output> ``` instead report the failure in a single block, as ``` Traceback (most recent call last): <a long traceback> raise RuntimeError( RuntimeError: latex was not able to process the following string: b'\\u2603' Here is the full command invocation and its output: latex -interaction=nonstopmode --halt-on-error ../71cab2b5aca12ed5cad4a481b3b00e42.tex This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021) (preloaded format=latex) <the tex output> ``` (the exception chaining is not particularly informative, and we can move the only relevant info -- the command we tried to run -- to the second exception).
1 parent 63e9ea3 commit 80d93a6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/texmanager.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,13 @@ def _run_checked_subprocess(cls, command, tex, *, cwd=None):
261261
raise RuntimeError(
262262
'{prog} was not able to process the following string:\n'
263263
'{tex!r}\n\n'
264-
'Here is the full report generated by {prog}:\n'
264+
'Here is the full command invocation and its output:\n\n'
265+
'{format_command}\n\n'
265266
'{exc}\n\n'.format(
266267
prog=command[0],
268+
format_command=cbook._pformat_subprocess(command),
267269
tex=tex.encode('unicode_escape'),
268-
exc=exc.output.decode('utf-8'))) from exc
270+
exc=exc.output.decode('utf-8'))) from None
269271
_log.debug(report)
270272
return report
271273

0 commit comments

Comments
 (0)