Skip to content

packaging 16.4 does not allow whitepace between requirement version conditions #502

@ghost

Description

Originally reported by: drcraig72 (Bitbucket: drcraig72, GitHub: Unknown)


Found in the release of setuptools 20.2.1, which vendors in packaging 16.4. It appears that packaging.requirements.Requirement does not comply with PEP-440's "Whitespace between a conditional operator and the following version identifier is optional, as is the whitespace around the commas.", per https://www.python.org/dev/peps/pep-0440/#version-specifiers. Instead, it fails when there is whitespace.

>>> from pkg_resources.extern.packaging.requirements import Requirement
>>> Requirement('Jinja2 >=2.7, <3')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/v/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 94, in __init__
    requirement_string[e.loc:e.loc + 8]))
pkg_resources._vendor.packaging.requirements.InvalidRequirement: Invalid requirement, parse error at "'<3'"

But it succeeds when the whitespace is removed

>>> Requirement('Jinja2 >=2.7,<3')
<Requirement('Jinja2<3,>=2.7')>

Opened the same ticket on packaging at pypa/packaging#65


Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions