Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marker.evaluate with extra=None fails in 22.0 #638

Closed
rth opened this issue Dec 10, 2022 · 1 comment · Fixed by #650
Closed

Marker.evaluate with extra=None fails in 22.0 #638

rth opened this issue Dec 10, 2022 · 1 comment · Fixed by #650

Comments

@rth
Copy link

rth commented Dec 10, 2022

Previously in v21.3

>>> from packaging.markers import Marker
>>> marker=Marker('extra == "opt-feature"')
>>> marker.evaluate({"extra": None})
False

With v22.0, we get,

>>> from packaging.markers import Marker
>>> marker=Marker('extra == "opt-feature"')
>>> marker.evaluate({"extra": None})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rth/.miniforge/envs/pyodide-env/lib/python3.10/site-packages/packaging/markers.py", line 241, in evaluate
    return _evaluate_markers(self._markers, current_environment)
  File "/home/rth/.miniforge/envs/pyodide-env/lib/python3.10/site-packages/packaging/markers.py", line 150, in _evaluate_markers
    lhs_value, rhs_value = _normalize(lhs_value, rhs_value, key=environment_key)
  File "/home/rth/.miniforge/envs/pyodide-env/lib/python3.10/site-packages/packaging/markers.py", line 124, in _normalize
    return tuple(canonicalize_name(v) for v in values)
  File "/home/rth/.miniforge/envs/pyodide-env/lib/python3.10/site-packages/packaging/markers.py", line 124, in <genexpr>
    return tuple(canonicalize_name(v) for v in values)
  File "/home/rth/.miniforge/envs/pyodide-env/lib/python3.10/site-packages/packaging/utils.py", line 34, in canonicalize_name
    value = _canonicalize_regex.sub("-", name).lower()
TypeError: expected string or bytes-like object

I'm aware of #550 but it is a breaking change with a not very helpful error message so I'm not sure if it was intended or not.

For instance, pkg_resources can fail with the above error here (or at least it does in micropip). The fix is easy in user code, but it still feels like a regression.

Otherwise thanks a lot for the new release!

@pradyunsg
Copy link
Member

#650 should fix this. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants