diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-03-26 19:09:21 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-03-26 19:09:21 (GMT) |
commit | 0ad9b7727d172fc772a5499da37efcc9385ed7b0 (patch) | |
tree | e055387b51692e3b1a477f01eee55a5d5f983e96 /Lib | |
parent | 94e4e2a7e583471627d76a2f3b2886c9064b7420 (diff) | |
download | cpython-0ad9b7727d172fc772a5499da37efcc9385ed7b0.zip cpython-0ad9b7727d172fc772a5499da37efcc9385ed7b0.tar.gz cpython-0ad9b7727d172fc772a5499da37efcc9385ed7b0.tar.bz2 |
add support for PyPy
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/platform.py | 15 | ||||
-rw-r--r-- | Lib/test/test_platform.py | 5 |
2 files changed, 20 insertions, 0 deletions
diff --git a/Lib/platform.py b/Lib/platform.py index 7863821..7a6f339 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1270,6 +1270,11 @@ _ironpython_sys_version_parser = re.compile( '(?: \(([\d\.]+)\))?' ' on (.NET [\d\.]+)') +_pypy_sys_version_parser = re.compile( + r'([\w.+]+)\s*' + '\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*' + '\[PyPy [^\]]+\]?') + _sys_version_cache = {} def _sys_version(sys_version=None): @@ -1325,6 +1330,16 @@ def _sys_version(sys_version=None): version, buildno, builddate, buildtime, _ = match.groups() compiler = sys.platform + elif "PyPy" in sys_version: + # PyPy + name = "PyPy" + match = _pypy_sys_version_parser.match(sys_version) + if match is None: + raise ValueError("failed to parse PyPy sys.version: %s" % + repr(sys_version)) + version, buildno, builddate, buildtime = match.groups() + compiler = "" + else: # CPython match = _sys_version_parser.match(sys_version) diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index f10aa06..0ca761c 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -93,6 +93,11 @@ class PlatformTest(unittest.TestCase): : ("Jython", "2.5.0", "trunk", "6107", ('trunk:6107', 'Mar 26 2009'), "java1.5.0_16"), + ("2.5.2 (63378, Mar 26 2009, 18:03:29)\n[PyPy 1.0.0]", + ('PyPy', 'trunk', '63378'), self.save_platform) + : + ("PyPy", "2.5.2", "trunk", "63378", ('63378', 'Mar 26 2009'), + "") } for (version_tag, subversion, sys_platform), info in \ sys_versions.iteritems(): |