Skip to content

Commit f076f53

Browse files
committed
#8964: fix platform._sys_version to handle IronPython 2.6+.
1 parent c318442 commit f076f53

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

Lib/platform.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,14 @@ def processor():
12481248
'(?: \(([\d\.]+)\))?'
12491249
' on (.NET [\d\.]+)', re.ASCII)
12501250

1251+
# IronPython covering 2.6 and 2.7
1252+
_ironpython26_sys_version_parser = re.compile(
1253+
r'([\d.]+)\s*'
1254+
'\(IronPython\s*'
1255+
'[\d.]+\s*'
1256+
'\(([\d.]+)\) on ([\w.]+ [\d.]+(?: \(\d+-bit\))?)\)'
1257+
)
1258+
12511259
_pypy_sys_version_parser = re.compile(
12521260
r'([\w.+]+)\s*'
12531261
'\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*'
@@ -1285,19 +1293,24 @@ def _sys_version(sys_version=None):
12851293
return result
12861294

12871295
# Parse it
1288-
if sys_version[:10] == 'IronPython':
1296+
if 'IronPython' in sys_version:
12891297
# IronPython
12901298
name = 'IronPython'
1291-
match = _ironpython_sys_version_parser.match(sys_version)
1299+
if sys_version.startswith('IronPython'):
1300+
match = _ironpython_sys_version_parser.match(sys_version)
1301+
else:
1302+
match = _ironpython26_sys_version_parser.match(sys_version)
1303+
12921304
if match is None:
12931305
raise ValueError(
12941306
'failed to parse IronPython sys.version: %s' %
12951307
repr(sys_version))
1308+
12961309
version, alt_version, compiler = match.groups()
12971310
buildno = ''
12981311
builddate = ''
12991312

1300-
elif sys.platform[:4] == 'java':
1313+
elif sys.platform.startswith('java'):
13011314
# Jython
13021315
name = 'Jython'
13031316
match = _sys_version_parser.match(sys_version)

Lib/test/test_platform.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,28 @@ def test_sys_version(self):
9191
("CPython", "2.6.1", "tags/r261", "67515",
9292
('r261:67515', 'Dec 6 2008 15:26:00'),
9393
'GCC 4.0.1 (Apple Computer, Inc. build 5370)'),
94+
9495
("IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.3053", None, "cli")
9596
:
9697
("IronPython", "2.0.0", "", "", ("", ""),
9798
".NET 2.0.50727.3053"),
99+
100+
("2.6.1 (IronPython 2.6.1 (2.6.10920.0) on .NET 2.0.50727.1433)", None, "cli")
101+
:
102+
("IronPython", "2.6.1", "", "", ("", ""),
103+
".NET 2.0.50727.1433"),
104+
105+
("2.7.4 (IronPython 2.7.4 (2.7.0.40) on Mono 4.0.30319.1 (32-bit))", None, "cli")
106+
:
107+
("IronPython", "2.7.4", "", "", ("", ""),
108+
"Mono 4.0.30319.1 (32-bit)"),
109+
98110
("2.5 (trunk:6107, Mar 26 2009, 13:02:18) \n[Java HotSpot(TM) Client VM (\"Apple Computer, Inc.\")]",
99111
('Jython', 'trunk', '6107'), "java1.5.0_16")
100112
:
101113
("Jython", "2.5.0", "trunk", "6107",
102114
('trunk:6107', 'Mar 26 2009'), "java1.5.0_16"),
115+
103116
("2.5.2 (63378, Mar 26 2009, 18:03:29)\n[PyPy 1.0.0]",
104117
('PyPy', 'trunk', '63378'), self.save_platform)
105118
:

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@ Nick Mathewson
791791
Simon Mathieu
792792
Laura Matson
793793
Graham Matthews
794+
Martin Matusiak
794795
Dieter Maurer
795796
Daniel May
796797
Madison May

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ Core and Builtins
7878
Library
7979
-------
8080

81+
- Issue #8964: fix platform._sys_version to handle IronPython 2.6+.
82+
Patch by Martin Matusiak.
83+
8184
- Issue #16038: CVE-2013-1752: ftplib: Limit amount of data read by
8285
limiting the call to readline(). Original patch by Michał
8386
Jastrzębski and Giampaolo Rodola.

0 commit comments

Comments
 (0)