[New-bugs-announce] [issue5561] platform.python_version_tuple returns tuple of ints, should be strings

Larry Hastings report at bugs.python.org
Wed Mar 25 17:26:15 CET 2009


New submission from Larry Hastings <larry at hastings.org>:

The documentation for platform.python_version_tuple() says:
"Returns the Python version as tuple (major, minor, patchlevel) of strings."

In 2.4 and 2.5 it correctly returned a tuple of strings.  In 2.6 it
returns a tuple of ints.

In 2.4 and 2.5 the implementation was this:
  return string.split(_sys_version()[0], '.')
In 2.6 it changed to this:
    if hasattr(sys, 'version_info'):
        return sys.version_info[:3]
    return tuple(string.split(_sys_version()[1], '.'))
The fields used from sys.version_info are ints, and always have been.  I
am mystified as to why the "if hasattr" lines were added; they broke it,
and it's not like that's superior information somehow.

I suggest modernizing it slightly when you fix the bug; use the .split()
method on strings.  Like so:
    return tuple(_sys_version()[1].split('.'))

----------
components: Library (Lib)
messages: 84161
nosy: Larry Hastings
severity: normal
status: open
title: platform.python_version_tuple returns tuple of ints, should be strings
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5561>
_______________________________________


More information about the New-bugs-announce mailing list