Skip to content

Suppress traceback chaining for tex subprocess failures. #23036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2022

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented May 12, 2022

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).

See also #23033 (comment)

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

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).
@timhoffm timhoffm added this to the v3.6.0 milestone May 12, 2022
@timhoffm timhoffm merged commit 07f8987 into matplotlib:main May 12, 2022
@anntzer anntzer deleted the tsp branch May 12, 2022 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants