-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Make WHEEL file errors more explicit #7529
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
chrahunt
merged 13 commits into
pypa:master
from
chrahunt:refactor/cleanup-wheel-parsing
Dec 31, 2019
Merged
Make WHEEL file errors more explicit #7529
chrahunt
merged 13 commits into
pypa:master
from
chrahunt:refactor/cleanup-wheel-parsing
Dec 31, 2019
Conversation
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
We plan to replace this code with direct extraction from a zip, so no point catching anything more precise.
get_metadata delegates to the underlying implementation which tries to locate and read the file, throwing an IOError (Python 2) or OSError subclass on any errors. Since the new explicit test checks the same case as brokenwheel in test_wheel_version we remove the redundant test. get_metadata may also throw a UnicodeDecodeError which we'll handle next, so to preserve the existing behavior we return None on any other exception.
This was the last error that could be thrown by get_metadata, so we can also remove the catch-all except block.
This API does not raise an exception, but returns any errors on the message object itself. We are preserving the original behavior, and can decide later whether to start warning or raising our own exception.
`email.message.Message.__getitem__` returns None on missing values, so we have to check for ourselves explicitly.
This is also the last exception that can be raised, so we remove `except Exception`.
Since wheel_version never returns None, this exception will never be raised.
pradyunsg
approved these changes
Dec 31, 2019
(noting that I didn't run the code from this PR, to validate the error messages) |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
auto-locked
Outdated issues that have been locked by automation
skip news
Does not need a NEWS file entry (eg: trivial changes)
type: refactor
Refactoring code
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.
Removes an
except Exception
that was glossing over what could actually go wrong during parsing and extraction ofWheel-Version
from theWHEEL
metadata file. We should be able to transition this code much more easily to direct parsing ofWHEEL
(instead of usingpkg_resources
) and re-purpose it for reading from a zipfile directly.The only change in behavior is an improvement in our error messages.