Skip to content

Commit 540f8fb

Browse files
committed
Keep empty hash, as before
1 parent 48152bb commit 540f8fb

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/pip/_internal/models/link.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class LinkHash:
6161
# against Hashes when hash-checking is needed. This is easier to debug than
6262
# proactively discarding an invalid hex digest, as we handle incorrect hashes
6363
# and malformed hashes in the same place.
64-
r"[#&]({choices})=([^&]+)".format(
64+
r"[#&]({choices})=([^&]*)".format(
6565
choices="|".join(re.escape(hash_name) for hash_name in _SUPPORTED_HASHES)
6666
),
6767
)

tests/unit/test_collector.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,8 +1061,11 @@ def expand_path(path: str) -> str:
10611061
),
10621062
# "xsha256" is not a valid algorithm, so we discard it.
10631063
("https://pypi.org/pip-18.0.tar.gz#xsha256=aa113592bbe", None),
1064-
# Discard empty hash.
1065-
("https://pypi.org/pip-18.0.tar.gz#sha256=", None),
1064+
# Empty hash.
1065+
(
1066+
"https://pypi.org/pip-18.0.tar.gz#sha256=",
1067+
LinkHash("sha256", ""),
1068+
),
10661069
(
10671070
"https://pypi.org/pip-18.0.tar.gz#md5=aa113592bbe",
10681071
LinkHash("md5", "aa113592bbe"),
@@ -1080,6 +1083,7 @@ def test_link_hash_parsing(url: str, result: Optional[LinkHash]) -> None:
10801083
"dist_info_metadata, result",
10811084
[
10821085
("sha256=aa113592bbe", LinkHash("sha256", "aa113592bbe")),
1086+
("sha256=", LinkHash("sha256", "")),
10831087
("sha500=aa113592bbe", None),
10841088
("true", None),
10851089
("", None),

0 commit comments

Comments
 (0)