[New-bugs-announce] [issue5561] platform.python_version_tuple returns tuple of ints, should be strings
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(), '.')
In 2.6 it changed to this:
if hasattr(sys, 'version_info'):
return tuple(string.split(_sys_version(), '.'))
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:
components: Library (Lib)
nosy: Larry Hastings
title: platform.python_version_tuple returns tuple of ints, should be strings
versions: Python 2.6
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce