Skip to content

Commit

Permalink
pypi: do not raise exception on 404 (#5698)
Browse files Browse the repository at this point in the history
  • Loading branch information
abn authored May 27, 2022
1 parent 9e4fb44 commit ec89ac4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/poetry/repositories/pypi_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,18 @@ def _get_release_info(

def _get(self, endpoint: str) -> dict[str, Any] | None:
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:
# Cache control redirect loop.
# We try to remove the cache and try again
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

json: dict[str, Any] = json_response.json()
Expand Down

0 comments on commit ec89ac4

Please sign in to comment.