Commit ec89ac45 by Arun Babu Neelicattu Committed by GitHub

pypi: do not raise exception on 404 (#5698)

parent 9e4fb44b
...@@ -243,14 +243,18 @@ class PyPiRepository(HTTPRepository): ...@@ -243,14 +243,18 @@ class PyPiRepository(HTTPRepository):
def _get(self, endpoint: str) -> dict[str, Any] | None: def _get(self, endpoint: str) -> dict[str, Any] | None:
try: try:
json_response = self.session.get(self._base_url + endpoint) json_response = self.session.get(
self._base_url + endpoint, raise_for_status=False
)
except requests.exceptions.TooManyRedirects: except requests.exceptions.TooManyRedirects:
# Cache control redirect loop. # Cache control redirect loop.
# We try to remove the cache and try again # We try to remove the cache and try again
self.session.delete_cache(self._base_url + endpoint) self.session.delete_cache(self._base_url + endpoint)
json_response = self.session.get(self._base_url + endpoint) json_response = self.session.get(
self._base_url + endpoint, raise_for_status=False
)
if json_response.status_code == 404: if json_response.status_code != 200:
return None return None
json: dict[str, Any] = json_response.json() json: dict[str, Any] = json_response.json()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment