Skip to content

Commit

Permalink
improve BadZipFile reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasjuhrich committed Oct 2, 2021
1 parent e1dd4b4 commit 0332250
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pip/_internal/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,12 @@ def get_wheel_distribution(wheel: Wheel, canonical_name: str) -> BaseDistributio
:param canonical_name: Normalized project name of the given wheel.
"""
from .pkg_resources import Distribution

return Distribution.from_wheel(wheel, canonical_name)
from zipfile import BadZipFile

try:
return Distribution.from_wheel(wheel, canonical_name)
except BadZipFile as e:
raise RuntimeError(
"Unable to retrieve wheel {} with canonical name {}"
.format(wheel.location, canonical_name)
) from e

0 comments on commit 0332250

Please sign in to comment.