Issue 11841: packaging.version: Bug when comparing versions with rc marker (original) (raw)

Created on 2011-04-13 09:19 by tarek, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
11841.patch gruszczy,2011-04-13 16:53
Messages (15)
msg133656 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2011-04-13 09:19
The NormalizedVersion class is not correctly sorting rc1: >>> from packaging.version import NormalizedVersion >>> NormalizedVersion('0.7.0') < NormalizedVersion('0.7.0rc1') True >>> NormalizedVersion('0.7.0rc1') NormalizedVersion('0.7rc1') >>> NormalizedVersion('0.7.0') < NormalizedVersion('0.7.0a1') False >>> NormalizedVersion('0.7.0') < NormalizedVersion('0.7.0c1') False
msg133678 - (view) Author: Filip Gruszczyński (gruszczy) Date: 2011-04-13 16:53
Here is a patch that I made against distutils2 tip. I have changed _FINAL_MARKER from 'f' to 'z', which works with rc. Also I have added constant _FINAL_MARKER_CHAR, since later in the code you make a check against 'f' and it surprised me a little at first. There are also tests in the patch. I hope it's good to make patch against the distutils2, since I couldn't yet find packaging in cpython default branch.
msg133847 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-04-15 17:07
Thanks, looks great! Why does the code use both a string and a singleton tuple?
msg133855 - (view) Author: Filip Gruszczyński (gruszczy) Date: 2011-04-15 17:25
The reason for the use of two constants is that previously there was comparison in the code with a hardcoded 'f': if postdev[0] == 'f': I think it's a common practice to create constants for such hardcoded values. Also this hit when I was making a patch. I didn't know, that 'f' was used in the code and when I changed _FINAL_MARKER to ('f',), some tests failed. Alternatively to what I did in the patch you can use: if postdev[0] == _FINAL_MARKER[0]: but it just doesn't feel right for me. Anyway, I can't find packaging package in default branch of python. Where is the development done? I'd be happy to try to provide some more patches for this package, if there is a need for any.
msg133856 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-04-15 17:37
> I think it's a common practice to create constants for such hardcoded > values. Yep, _FINAL_MARKER is clearer here that a cryptic character. An alternate fix would be to use a c as rc marker (like what Python itself does in sys.hexversion and elsewhere). I’ll see if I can use only one object instead of two. > Anyway, I can't find packaging package in default branch of python. The merge started at the PyCon sprints is still underway at https://bitbucket.org/tarek/cpython/ Follow the fellowship ML for details. There’ll be an announcement on python-dev too when it’s complete, and then we’ll restart fixing bugs.
msg133858 - (view) Author: Filip Gruszczyński (gruszczy) Date: 2011-04-15 17:40
I understand that ML is mailing list, but I have no idea what is fellowship mailing list. Could you elaborate on this?
msg133859 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-04-15 17:43
http://groups.google.com/group/the-fellowship-of-the-packaging/
msg144997 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-10-06 11:24
New changeset 2105ab8553b7 by Éric Araujo in branch 'default': Add tests for comparing candidate and final versions in packaging (#11841). http://hg.python.org/cpython/rev/2105ab8553b7
msg145000 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-10-06 11:40
I couldn’t reproduce the bugs but added the tests. Thanks!
msg154449 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-27 10:16
I don’t remember how I did it last time, but yesterday I was able to reproduce the bug. I have added unit tests, as the lines I added to the doctest were actually no run (I’m working on it in #13953), and applied the fix. I will push shortly.
msg154451 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-02-27 10:47
New changeset 32cb52bee738 by Éric Araujo in branch 'default': Fix comparison bug with 'rc' versions in packaging.version (#11841). http://hg.python.org/cpython/rev/32cb52bee738
msg154459 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-02-27 11:29
New changeset c82c97b2eae1 by Éric Araujo in branch 'default': Fix comparison bug with 'rc' versions (#11841) http://hg.python.org/distutils2/rev/c82c97b2eae1 New changeset 7d1a7251d771 by Éric Araujo in branch 'python3': Merge fixes for #13974, #6884 and #11841 from default http://hg.python.org/distutils2/rev/7d1a7251d771
msg154462 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-27 11:31
Thanks again for the patch. Next time I say that I couldn’t reproduce a bug, please insist :)
msg154464 - (view) Author: Filip Gruszczyński (gruszczy) Date: 2012-02-27 11:50
I prefer to be humble and trust core devs, when I post some patch to a codebase I don't know very well. I am glad you managed to reproduce it and I could help :-)
msg154465 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-27 11:50
Having push rights does not make me smarter :)
History
Date User Action Args
2022-04-11 14:57:16 admin set github: 56050
2012-02-27 11:50:46 eric.araujo set messages: +
2012-02-27 11:50:10 gruszczy set messages: +
2012-02-27 11:31:26 eric.araujo set status: open -> closedresolution: fixedmessages: + stage: commit review -> resolved
2012-02-27 11:29:47 python-dev set messages: +
2012-02-27 10:47:51 python-dev set messages: +
2012-02-27 10:16:17 eric.araujo set status: closed -> opentitle: Bug in the version comparison -> packaging.version: Bug when comparing versions with rc markermessages: + resolution: out of date -> (no value)stage: resolved -> commit review
2012-02-08 16:56:42 tshepang set title: Bug in the verson comparison -> Bug in the version comparison
2011-10-06 11:40:55 eric.araujo set status: open -> closedversions: + 3rd partymessages: + resolution: out of datestage: resolved
2011-10-06 11:24:06 python-dev set nosy: + python-devmessages: +
2011-04-15 17:43:03 eric.araujo set messages: +
2011-04-15 17:40:10 gruszczy set messages: +
2011-04-15 17:37:22 eric.araujo set assignee: tarek -> eric.araujomessages: +
2011-04-15 17:25:17 gruszczy set messages: +
2011-04-15 17:07:16 eric.araujo set messages: +
2011-04-13 16:53:30 gruszczy set files: + 11841.patchnosy: + gruszczymessages: + keywords: + patch
2011-04-13 09:19:39 tarek create