summaryrefslogtreecommitdiffstats
path: root/Lib/platform.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/platform.py')
-rwxr-xr-xLib/platform.py43
1 files changed, 25 insertions, 18 deletions
diff --git a/Lib/platform.py b/Lib/platform.py
index 04f7f9b..21e098b 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -1240,15 +1240,17 @@ _sys_version_parser = re.compile(
'\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*'
'\[([^\]]+)\]?', re.ASCII)
-_jython_sys_version_parser = re.compile(
- r'([\d\.]+)', re.ASCII)
-
_ironpython_sys_version_parser = re.compile(
r'IronPython\s*'
'([\d\.]+)'
'(?: \(([\d\.]+)\))?'
' on (.NET [\d\.]+)', re.ASCII)
+_pypy_sys_version_parser = re.compile(
+ r'([\w.+]+)\s*'
+ '\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*'
+ '\[PyPy [^\]]+\]?')
+
_sys_version_cache = {}
def _sys_version(sys_version=None):
@@ -1290,25 +1292,29 @@ def _sys_version(sys_version=None):
'failed to parse IronPython sys.version: %s' %
repr(sys_version))
version, alt_version, compiler = match.groups()
- branch = ''
- revision = ''
buildno = ''
builddate = ''
elif sys.platform[:4] == 'java':
# Jython
name = 'Jython'
- match = _jython_sys_version_parser.match(sys_version)
+ match = _sys_version_parser.match(sys_version)
if match is None:
raise ValueError(
'failed to parse Jython sys.version: %s' %
repr(sys_version))
- version, = match.groups()
- branch = ''
- revision = ''
+ version, buildno, builddate, buildtime, _ = match.groups()
compiler = sys.platform
- buildno = ''
- builddate = ''
+
+ 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
@@ -1319,15 +1325,16 @@ def _sys_version(sys_version=None):
repr(sys_version))
version, buildno, builddate, buildtime, compiler = \
match.groups()
- if hasattr(sys, 'subversion'):
- # sys.subversion was added in Python 2.5
- name, branch, revision = sys.subversion
- else:
- name = 'CPython'
- branch = ''
- revision = ''
+ name = 'CPython'
builddate = builddate + ' ' + buildtime
+ if hasattr(sys, 'subversion'):
+ # sys.subversion was added in Python 2.5
+ _, branch, revision = sys.subversion
+ else:
+ branch = ''
+ revision = ''
+
# Add the patchlevel version if missing
l = version.split('.')
if len(l) == 2: