From 28d5c007d8a73fac466deedd3b691fbf14bd9fff Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Fri, 1 Mar 2024 22:03:18 -0800 Subject: [PATCH] Hash metadata as bytes (#9049) Because warehouse doesn't send a charset, this can get decoded as something other than utf-8, which doesn't encode (as utf-8) back to the same bytes. For hash purposes especially, just look at the original bytes. --- src/poetry/repositories/http_repository.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/poetry/repositories/http_repository.py b/src/poetry/repositories/http_repository.py index db7a365405c..515907e72e5 100644 --- a/src/poetry/repositories/http_repository.py +++ b/src/poetry/repositories/http_repository.py @@ -169,7 +169,7 @@ def _get_info_from_metadata(self, link: Link) -> PackageInfo | None: ) ): metadata_hash = getattr(hashlib, hash_name)( - response.text.encode() + response.content ).hexdigest() if metadata_hash != link.metadata_hashes[hash_name]: self._log(