-
Notifications
You must be signed in to change notification settings - Fork 252
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
Possible bug with wildcard version matching #425
Comments
Hi! Thanks for filing this issue. I'm finding it a little difficult to understand what edge case you're describing. Could you provide a reproducer for this with the following structure? (what you ran + what you got) >>> req = Requirement("A <= 2.0")
>>> req.name
'something-unexpected' (vs what you ran + what you expected) >>> req = Requirement("A <= 2.0")
>>> req.name
'A' |
I think it’s >>> Version('1.0.post1') == Version('1.post1') # These are considered equivalent.
True
>>> '1.0.post1' in SpecifierSet('==1.0.post1.*') # As expected.
True
>>> '1.0.post1' in SpecifierSet('==1.post1.*') # Why not?
False Although I don’t quite get what exactly |
Based on a re-read of the relevant sections of the PEP, AFAICT, the prefix matching stuff is only meant to match prefixes for public versions? Notably, there's the line:
That makes me think that |
But postreleases are neither development nor local releases, so technically
Where a “release segment” is the So I would assume the usage raised by OP is valid, at least according to the intension of PEP 440. But as I previously mentioned, I cannot see how this syntax can be practically useful, so it would not be unreasonable to change the specification to explicitly disallow it either. |
@uranusjr thanks, yes that is what I am describing. The |
Looking back at the spec, this line references that:
|
Another (different situation) reproducer for wildcard matching issue on main:
The 2 versions are semantically identical but prefix matching yields 2 different results. EDIT: I have a feeling I should open another issue for this one. If maintainers feel so too, I'll delete the comment and open another issue. |
@mayeut up to you if you want to open a separate issue. Without investigating where in the code the bug is your case could be the same or could be entirely different. |
#563 fixes this to prevent the wildcard and I'm up for merging it. Any objections? |
Hi all,
I'm implementing a PEP 440 parser in another language and have been using
packaging
to validate, and came across this possible corner case.The specifier
==1.1.0.post0.*
matches the version1.1.post0
because the version is zero-padded (as expected).The specifier
==1.1.post0.*
does not match the version1.1.0.post0
, even though I'd expect it to. My understanding is that the version in the specifier should also get zero-padded and result in a match (for the same reason that==1.1.post0
is zero-padded to match1.1.0.post0
).The text was updated successfully, but these errors were encountered: