This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: platform.python_version_tuple returns tuple of ints, should be strings
Type: Stage:
Components: Library (Lib) Versions: Python 2.7, Python 2.6
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: lemburg Nosy List: larry, lemburg
Priority: normal Keywords:

Created on 2009-03-25 16:26 by larry, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg84161 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2009-03-25 16:26
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('.'))
msg84162 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2009-03-25 18:51
Thanks, that's clearly a bug.

Note that the module is still compatible with Python 1.5.2, so using
string methods is not possible.
msg84165 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2009-03-25 19:52
Checked in a fix for Python 2.7 and 2.6 (r70594:70596).
History
Date User Action Args
2022-04-11 14:56:46adminsetgithub: 49811
2009-03-25 19:52:39lemburgsetstatus: open -> closed

messages: + msg84165
versions: + Python 2.7
2009-03-25 18:51:24lemburgsetmessages: + msg84162
2009-03-25 18:23:13benjamin.petersonsetassignee: lemburg

nosy: + lemburg
2009-03-25 16:26:14Larry Hastingscreate