Skip to content

Commit

Permalink
Add handling for PyPI 404
Browse files Browse the repository at this point in the history
Now that warehouse set cors to 404, (pypi/warehouse#16339)
we need to change the checked exceptions as there is no more network
errors.
  • Loading branch information
Carreau committed Aug 21, 2024
1 parent c7dfa4e commit 8457bfb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions micropip/package_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from packaging.utils import InvalidWheelFilename
from packaging.version import InvalidVersion, Version

from ._compat import fetch_string_and_headers
from ._compat import HttpStatusError, fetch_string_and_headers
from ._utils import is_package_compatible, parse_version
from .externals.mousebender.simple import from_project_details_html
from .wheelinfo import WheelInfo
Expand Down Expand Up @@ -276,11 +276,16 @@ async def query_package(

try:
metadata, headers = await fetch_string_and_headers(url, _fetch_kwargs)
except OSError:
continue
except HttpStatusError as e:
if e.status_code == 404:
continue
raise

content_type = headers.get("content-type", "").lower()
parser = _select_parser(content_type, name)
try:
parser = _select_parser(content_type, name)
except ValueError as e:
raise ValueError(f"Error trying to decode url: {url}") from e
return parser(metadata)
else:
raise ValueError(
Expand Down

0 comments on commit 8457bfb

Please sign in to comment.