summaryrefslogtreecommitdiffstats
path: root/Lib/platform.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-06-08 06:12:22 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-06-08 06:12:22 (GMT)
commit4e50553823c16a65d80f6734b4ac303c18640380 (patch)
tree3aaf8fb8167af091664cfac37d2c337c1f33c3d6 /Lib/platform.py
parent1bf197eb14c5db5c43b3dc48687ae034690d34c4 (diff)
downloadcpython-4e50553823c16a65d80f6734b4ac303c18640380.zip
cpython-4e50553823c16a65d80f6734b4ac303c18640380.tar.gz
cpython-4e50553823c16a65d80f6734b4ac303c18640380.tar.bz2
Issue #21313: Tolerate truncated buildinfo in sys.version
Diffstat (limited to 'Lib/platform.py')
-rwxr-xr-xLib/platform.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/Lib/platform.py b/Lib/platform.py
index ff036e3..d58494c 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -1146,9 +1146,11 @@ def processor():
### Various APIs for extracting information from sys.version
_sys_version_parser = re.compile(
- r'([\w.+]+)\s*'
- '\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*'
- '\[([^\]]+)\]?', re.ASCII)
+ r'([\w.+]+)\s*' # "version<space>"
+ r'\(#?([^,]+)' # "(#buildno"
+ r'(?:,\s*([\w ]*)' # ", builddate"
+ r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)<space>"
+ r'\[([^\]]+)\]?', re.ASCII) # "[compiler]"
_ironpython_sys_version_parser = re.compile(
r'IronPython\s*'
@@ -1227,6 +1229,8 @@ def _sys_version(sys_version=None):
'failed to parse Jython sys.version: %s' %
repr(sys_version))
version, buildno, builddate, buildtime, _ = match.groups()
+ if builddate is None:
+ builddate = ''
compiler = sys.platform
elif "PyPy" in sys_version:
@@ -1249,7 +1253,10 @@ def _sys_version(sys_version=None):
version, buildno, builddate, buildtime, compiler = \
match.groups()
name = 'CPython'
- builddate = builddate + ' ' + buildtime
+ if builddate is None:
+ builddate = ''
+ elif buildtime:
+ builddate = builddate + ' ' + buildtime
if hasattr(sys, '_mercurial'):
_, branch, revision = sys._mercurial