I noticed a difference between how Sepcifier and SpecifierSet parses the arbitrary equality.
The Specifier's regex accepts almost any character, including commas:
|
[^\s;)]* # The arbitrary version can be just about anything, |
This can lead to funky results such as:
>>> from packaging.specifiers import Specifier, SpecifierSet
>>> spec = Specifier('===hello,')
>>> spec_set1 = SpecifierSet([spec])
>>> spec_set2 = SpecifierSet('===hello,')
>>> # both seem identical but are not equal
>>> print(repr(spec_set1))
<SpecifierSet('===hello,')>
>>> print(repr(spec_set2))
<SpecifierSet('===hello')>
>>> assert spec_set1 != spec_set2
Or if the user is not careful, two specifier are parsed as a single arbitrary equality specifier:
>>> Specifier('===moo,<=0.1')
<Specifier('===moo,<=0.1')>
>>> _.operator
'==='
I'm not sure I understand the specification (for version specifiers) correctly, but I expected that arbitrary equality values would not be allowed to contain commas. I think this is a bug, but I'm not sure.
The commas are handled here:
|
split_specifiers = [s.strip() for s in specifiers.split(",") if s.strip()] |
I checked this behavior on packaging version 25.0
I noticed a difference between how
SepcifierandSpecifierSetparses the arbitrary equality.The
Specifier's regex accepts almost any character, including commas:packaging/src/packaging/specifiers.py
Line 122 in f585376
This can lead to funky results such as:
Or if the user is not careful, two specifier are parsed as a single arbitrary equality specifier:
I'm not sure I understand the specification (for version specifiers) correctly, but I expected that arbitrary equality values would not be allowed to contain commas. I think this is a bug, but I'm not sure.
The commas are handled here:
packaging/src/packaging/specifiers.py
Line 722 in f585376
I checked this behavior on packaging version 25.0