summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-10-21 00:03:32 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-10-21 00:03:32 (GMT)
commitbc385481453bf4fe8205b21c1538955517b2955c (patch)
treea10013fafd93bf6d6519825b7bc153c9e0a74ffb
parentcef2d491224d0e83a988c3ef3c32f74eab90b497 (diff)
downloadcpython-bc385481453bf4fe8205b21c1538955517b2955c.zip
cpython-bc385481453bf4fe8205b21c1538955517b2955c.tar.gz
cpython-bc385481453bf4fe8205b21c1538955517b2955c.tar.bz2
#8964: fix platform._sys_version to handle IronPython 2.6+.
-rwxr-xr-xLib/platform.py19
-rw-r--r--Lib/test/test_platform.py13
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS3
4 files changed, 33 insertions, 3 deletions
diff --git a/Lib/platform.py b/Lib/platform.py
index b6dab3b..df2af83 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -1371,6 +1371,14 @@ _ironpython_sys_version_parser = re.compile(
'(?: \(([\d\.]+)\))?'
' on (.NET [\d\.]+)')
+# IronPython covering 2.6 and 2.7
+_ironpython26_sys_version_parser = re.compile(
+ r'([\d.]+)\s*'
+ '\(IronPython\s*'
+ '[\d.]+\s*'
+ '\(([\d.]+)\) on ([\w.]+ [\d.]+(?: \(\d+-bit\))?)\)'
+)
+
_pypy_sys_version_parser = re.compile(
r'([\w.+]+)\s*'
'\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*'
@@ -1408,19 +1416,24 @@ def _sys_version(sys_version=None):
return result
# Parse it
- if sys_version[:10] == 'IronPython':
+ if 'IronPython' in sys_version:
# IronPython
name = 'IronPython'
- match = _ironpython_sys_version_parser.match(sys_version)
+ if sys_version.startswith('IronPython'):
+ match = _ironpython_sys_version_parser.match(sys_version)
+ else:
+ match = _ironpython26_sys_version_parser.match(sys_version)
+
if match is None:
raise ValueError(
'failed to parse IronPython sys.version: %s' %
repr(sys_version))
+
version, alt_version, compiler = match.groups()
buildno = ''
builddate = ''
- elif sys.platform[:4] == 'java':
+ elif sys.platform.startswith('java'):
# Jython
name = 'Jython'
match = _sys_version_parser.match(sys_version)
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index 941d428..331995f 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -84,15 +84,28 @@ class PlatformTest(unittest.TestCase):
("CPython", "2.6.1", "tags/r261", "67515",
('r261:67515', 'Dec 6 2008 15:26:00'),
'GCC 4.0.1 (Apple Computer, Inc. build 5370)'),
+
("IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.3053", None, "cli")
:
("IronPython", "2.0.0", "", "", ("", ""),
".NET 2.0.50727.3053"),
+
+ ("2.6.1 (IronPython 2.6.1 (2.6.10920.0) on .NET 2.0.50727.1433)", None, "cli")
+ :
+ ("IronPython", "2.6.1", "", "", ("", ""),
+ ".NET 2.0.50727.1433"),
+
+ ("2.7.4 (IronPython 2.7.4 (2.7.0.40) on Mono 4.0.30319.1 (32-bit))", None, "cli")
+ :
+ ("IronPython", "2.7.4", "", "", ("", ""),
+ "Mono 4.0.30319.1 (32-bit)"),
+
("2.5 (trunk:6107, Mar 26 2009, 13:02:18) \n[Java HotSpot(TM) Client VM (\"Apple Computer, Inc.\")]",
('Jython', 'trunk', '6107'), "java1.5.0_16")
:
("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)
:
diff --git a/Misc/ACKS b/Misc/ACKS
index 769624c..ffa3154 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -663,6 +663,7 @@ Roger Masse
Nick Mathewson
Laura Matson
Graham Matthews
+Martin Matusiak
Dieter Maurer
Daniel May
Arnaud Mazin
diff --git a/Misc/NEWS b/Misc/NEWS
index 312bfe1..e9d692c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -37,6 +37,9 @@ Core and Builtins
Library
-------
+- Issue #8964: fix platform._sys_version to handle IronPython 2.6+.
+ Patch by Martin Matusiak.
+
- Issue #16038: CVE-2013-1752: ftplib: Limit amount of data read by
limiting the call to readline(). Original patch by Michał
Jastrzębski and Giampaolo Rodola.