Skip to content

Commit ee7f965

Browse files
committed
fix: don't renormalize extras
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
1 parent 1c09ddf commit ee7f965

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/packaging/markers.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ def _normalize(
211211
# > compared using the semantics outlined in PEP 503 for names
212212
if key == "extra":
213213
assert isinstance(rhs, str), "extra value must be a string"
214-
return (canonicalize_name(lhs), canonicalize_name(rhs))
214+
# Both sides are normalized at this point already
215+
return (lhs, rhs)
215216
if key in MARKERS_ALLOWING_SET:
216217
if isinstance(rhs, str): # pragma: no cover
217218
return (canonicalize_name(lhs), canonicalize_name(rhs))
@@ -348,10 +349,12 @@ def evaluate(
348349
current_environment["extra"] = ""
349350
if environment is not None:
350351
current_environment.update(environment)
351-
# The API used to allow setting extra to None. We need to handle this
352-
# case for backwards compatibility.
353-
if "extra" in current_environment and current_environment["extra"] is None:
354-
current_environment["extra"] = ""
352+
if "extra" in current_environment:
353+
# The API used to allow setting extra to None. We need to handle
354+
# this case for backwards compatibility. Also skip running
355+
# normalize name if extra is empty.
356+
extra = cast("str | None", current_environment["extra"])
357+
current_environment["extra"] = canonicalize_name(extra) if extra else ""
355358

356359
return _evaluate_markers(
357360
self._markers, _repair_python_full_version(current_environment)

0 commit comments

Comments
 (0)