yet another issue in parse_version

Create issue
Issue #370 invalid
Guy Rozendorn created an issue

parse_version uses the \d regex and then calls int on the result, this makes, e.g. "06" == "6" so "2.06" == "2.6.0":

pkg_resources.parse_version("2.6.0") == pkg_resources.parse_version("2.06")

PEP 386 specifies that this type of version number is valid (listing "8.02" in the list of valid version numbers) but does not specify how it should be parsed.

Comments (2)

  1. Jason R. Coombs

    This behavior doesn't seem like a bug to me. In general, software versioning systems, especially those found in open source, treat numbers between periods as integers, and that '2.6.0' is in fact equivalent to '2.6' and '2.06', and '2.006', and ''.

    And in fact, the docs explicitly state:

    Leading zeros within a series of digits are also ignored, so 2.01 is the same as 2.1, and different from 2.0.1.

    So, since this scheme doesn't violate PEP 386 and since it's internally consistent, I don't see any issue.

    Please elaborate and/or re-open the ticket if you believe there's further reason to pursue this issue.

  2. Log in to comment