Skip to content

Commit 97d8de8

Browse files
authored
Canonicalize the correct side of the name comparison when verifying sdist filenames with post releases (pypi#15825)
* Add a failing test * Canonicalize the right side of the comparison The project name is already canonicalized after calling `parse_sdist_filename`, what we actually need to canonicalize is the name that was provided to us in the POST data, which isn't guaranteed to be canonicalized.
1 parent 5a2d6f8 commit 97d8de8

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

tests/unit/forklift/test_legacy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2699,6 +2699,7 @@ def storage_service_store(path, file_path, *, meta):
26992699
("foo-.bar", "foo_bar", "1.0.0"),
27002700
("leo", "leo", "6.7.9-9"),
27012701
("leo_something", "leo-something", "6.7.9-9"),
2702+
("PyAlgoEngine", "PyAlgoEngine", "0.3.12.post4"),
27022703
],
27032704
)
27042705
def test_upload_succeeds_pep625_normalized_filename(

warehouse/forklift/legacy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ def file_upload(request):
970970
# what we were expecting
971971
if (
972972
meta.version.is_postrelease
973-
and packaging.utils.canonicalize_name(name) != meta.name
973+
and name != packaging.utils.canonicalize_name(meta.name)
974974
):
975975
# The distribution is a source distribution, the version is a
976976
# postrelease, and the project name doesn't match, so

0 commit comments

Comments
 (0)