classification
Title: packaging.version: Bug when comparing versions with rc marker
Type: behavior Stage: resolved
Components: Distutils2 Versions: Python 3.3, 3rd party
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: alexis, brett.cannon, eric.araujo, gruszczy, python-dev, tarek
Priority: normal Keywords: patch

Created on 2011-04-13 09:19 by tarek, last changed 2012-02-27 11:50 by eric.araujo. 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) 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) 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) 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
2012-02-27 11:50:46eric.araujosetmessages: + msg154465
2012-02-27 11:50:10gruszczysetmessages: + msg154464
2012-02-27 11:31:26eric.araujosetstatus: open -> closed
resolution: fixed
messages: + msg154462

stage: commit review -> resolved
2012-02-27 11:29:47python-devsetmessages: + msg154459
2012-02-27 10:47:51python-devsetmessages: + msg154451
2012-02-27 10:16:17eric.araujosetstatus: closed -> open
title: Bug in the version comparison -> packaging.version: Bug when comparing versions with rc marker
messages: + msg154449

resolution: out of date -> (no value)
stage: resolved -> commit review
2012-02-08 16:56:42tshepangsettitle: Bug in the verson comparison -> Bug in the version comparison
2011-10-06 11:40:55eric.araujosetstatus: open -> closed
versions: + 3rd party
messages: + msg145000

resolution: out of date
stage: resolved
2011-10-06 11:24:06python-devsetnosy: + python-dev
messages: + msg144997
2011-04-15 17:43:03eric.araujosetmessages: + msg133859
2011-04-15 17:40:10gruszczysetmessages: + msg133858
2011-04-15 17:37:22eric.araujosetassignee: tarek -> eric.araujo
messages: + msg133856
2011-04-15 17:25:17gruszczysetmessages: + msg133855
2011-04-15 17:07:16eric.araujosetmessages: + msg133847
2011-04-13 16:53:30gruszczysetfiles: + 11841.patch

nosy: + gruszczy
messages: + msg133678

keywords: + patch
2011-04-13 09:19:39tarekcreate