From c17f3a4ac11f88612e96ea4641bf6e6c1d2db891 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 9 Dec 2025 12:08:15 -0500 Subject: [PATCH] chore: use partition in _parse_project_urls Signed-off-by: Henry Schreiner --- src/packaging/metadata.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/packaging/metadata.py b/src/packaging/metadata.py index dfe51df9..43e8ead9 100644 --- a/src/packaging/metadata.py +++ b/src/packaging/metadata.py @@ -209,15 +209,14 @@ def _parse_project_urls(data: list[str]) -> dict[str, str]: # answer with what to do in that case. As such, we'll do the only # thing we can, which is treat the field as unparsable and add it # to our list of unparsed fields. - parts = [p.strip() for p in pair.split(",", 1)] - parts.extend([""] * (max(0, 2 - len(parts)))) # Ensure 2 items - + # # TODO: The spec doesn't say anything about if the keys should be # considered case sensitive or not... logically they should # be case-preserving and case-insensitive, but doing that # would open up more cases where we might have duplicate # entries. - label, url = parts + label, _, url = (s.strip() for s in pair.partition(",")) + if label in urls: # The label already exists in our set of urls, so this field # is unparsable, and we can just add the whole thing to our