Raise an exception when find_tex_file fails to find a file.#21356
Merged
QuLogic merged 1 commit intomatplotlib:masterfrom Oct 15, 2021
Merged
Raise an exception when find_tex_file fails to find a file.#21356QuLogic merged 1 commit intomatplotlib:masterfrom
QuLogic merged 1 commit intomatplotlib:masterfrom
Conversation
3064c18 to
63f2914
Compare
timhoffm
reviewed
Oct 14, 2021
Member
There was a problem hiding this comment.
I'm slightly worried on the API change. There might be users out there using find_tex_file to check if a package is installed.
The more defensive approach would be:
- If
find_tex_filedoesn't find a file it issues a warning that it will fali in the future. But it still returns '' for now. - Tempoarily we add a function
def _find_tex_file_or_raise(filename): with.warnings.catch_warnings(): warnings.filter(...) tex_file = find_tex_file(filename) if not tex_file: raise FileNotFoundError(...) return tex_file - and replace all internal usages with this function.
This would give nice error messages for internal problems but still gives find_tex_file users the opportunity to prepare for the API change.
Contributor
Author
|
OK, switch to warning. |
timhoffm
approved these changes
Oct 14, 2021
QuLogic
reviewed
Oct 15, 2021
The exception message is clearer for end users than downstream callers failing to `open()` a file named `""`. Also update the function's docstring. _tfmfile now never returns None (an exception would have been raised earlier by find_tex_file), so remove the corresponding branch.
QuLogic
approved these changes
Oct 15, 2021
tacaswell
pushed a commit
that referenced
this pull request
Oct 20, 2021
Raise an exception when find_tex_file fails to find a file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The exception message is clearer for end users than downstream callers
failing to
open()a file named"".Also update the function's docstring.
_tfmfile now never returns None (an exception would have been raised
earlier by find_tex_file), so remove the corresponding branch.
From a quick look, #21354 seems to arise from a missing
pdftex.map;this patch would have made the error clearer.
PR Summary
PR Checklist
pytestpasses).flake8on changed files to check).flake8-docstringsand runflake8 --docstring-convention=all).doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).