[Python-checkins] r70594 - in python/trunk/Lib: platform.py test/test_platform.py

marc-andre.lemburg python-checkins at python.org
Wed Mar 25 20:44:59 CET 2009


Author: marc-andre.lemburg
Date: Wed Mar 25 20:44:58 2009
New Revision: 70594
Log:
Remove the sys.version_info shortcut, since they cause the APIs
to return different information than the _sys_version() output
used in previous Python versions.
This also fixes issue5561: platform.python_version_tuple returns tuple of ints, should be strings
Added more tests for the various platform functions.
Modified:
 python/trunk/Lib/platform.py
 python/trunk/Lib/test/test_platform.py
Modified: python/trunk/Lib/platform.py
==============================================================================
--- python/trunk/Lib/platform.py	(original)
+++ python/trunk/Lib/platform.py	Wed Mar 25 20:44:58 2009
@@ -1278,10 +1278,10 @@
 def _sys_version(sys_version=None):
 
 """ Returns a parsed version of Python's sys.version as tuple
- (name, version, branch, revision, buildno, builddate, compiler)
- referring to the Python implementation name, version, branch,
- revision, build number, build date/time as string and the compiler
- identification string.
+ (name, version, branch, revision, buildno, builddate, compiler)
+ referring to the Python implementation name, version, branch,
+ revision, build number, build date/time as string and the compiler
+ identification string.
 
 Note that unlike the Python sys.version, the returned value
 for the Python version will always include the patchlevel (it
@@ -1383,8 +1383,6 @@
 will always include the patchlevel (it defaults to 0).
 
 """
- if hasattr(sys, 'version_info'):
- return '%i.%i.%i' % sys.version_info[:3]
 return _sys_version()[1]
 
 def python_version_tuple():
@@ -1396,8 +1394,6 @@
 will always include the patchlevel (it defaults to 0).
 
 """
- if hasattr(sys, 'version_info'):
- return sys.version_info[:3]
 return tuple(string.split(_sys_version()[1], '.'))
 
 def python_branch():
Modified: python/trunk/Lib/test/test_platform.py
==============================================================================
--- python/trunk/Lib/test/test_platform.py	(original)
+++ python/trunk/Lib/test/test_platform.py	Wed Mar 25 20:44:58 2009
@@ -25,39 +25,48 @@
 finally:
 os.remove(link)
 
- def test_machine(self):
- res = platform.machine()
-
- def test_node(self):
- res = platform.node()
-
 def test_platform(self):
 for aliased in (False, True):
 for terse in (False, True):
 res = platform.platform(aliased, terse)
 
- def test_processor(self):
- res = platform.processor()
+ def test_system(self):
+ res = platform.system()
 
- def test_python_build(self):
- res = platform.python_build()
+ def test_node(self):
+ res = platform.node()
 
- def test_python_compiler(self):
- res = platform.python_compiler()
+ def test_release(self):
+ res = platform.release()
 
 def test_version(self):
- res1 = platform.version()
- res2 = platform.version_tuple()
+ res = platform.version()
+
+ def test_machine(self):
+ res = platform.machine()
+
+ def test_processor(self):
+ res = platform.processor()
+
+ def test_python_implementation(self):
+ res = platform.python_implementation()
+
+ def test_python_version(self):
+ res1 = platform.python_version()
+ res2 = platform.python_version_tuple()
 self.assertEqual(res1, ".".join(res2))
 
- def test_release(self):
- res = platform.release()
+ def test_python_branch(self):
+ res = platform.python_branch()
 
- def test_system(self):
- res = platform.system()
+ def test_python_revision(self):
+ res = platform.python_revision()
 
- def test_version(self):
- res = platform.version()
+ def test_python_build(self):
+ res = platform.python_build()
+
+ def test_python_compiler(self):
+ res = platform.python_compiler()
 
 def test_system_alias(self):
 res = platform.system_alias(


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /