Skip to content

Commit 382ee2f

Browse files
authored
gh-102491: Remove IronPython version check in sys_version (#102492)
1 parent 699cb20 commit 382ee2f

File tree

3 files changed

+10
-51
lines changed

3 files changed

+10
-51
lines changed

Lib/platform.py

+1-34
Original file line numberDiff line numberDiff line change
@@ -1040,20 +1040,6 @@ def processor():
10401040
r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)<space>"
10411041
r'\[([^\]]+)\]?', re.ASCII) # "[compiler]"
10421042

1043-
_ironpython_sys_version_parser = re.compile(
1044-
r'IronPython\s*'
1045-
r'([\d\.]+)'
1046-
r'(?: \(([\d\.]+)\))?'
1047-
r' on (.NET [\d\.]+)', re.ASCII)
1048-
1049-
# IronPython covering 2.6 and 2.7
1050-
_ironpython26_sys_version_parser = re.compile(
1051-
r'([\d.]+)\s*'
1052-
r'\(IronPython\s*'
1053-
r'[\d.]+\s*'
1054-
r'\(([\d.]+)\) on ([\w.]+ [\d.]+(?: \(\d+-bit\))?)\)'
1055-
)
1056-
10571043
_pypy_sys_version_parser = re.compile(
10581044
r'([\w.+]+)\s*'
10591045
r'\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*'
@@ -1090,25 +1076,7 @@ def _sys_version(sys_version=None):
10901076
if result is not None:
10911077
return result
10921078

1093-
# Parse it
1094-
if 'IronPython' in sys_version:
1095-
# IronPython
1096-
name = 'IronPython'
1097-
if sys_version.startswith('IronPython'):
1098-
match = _ironpython_sys_version_parser.match(sys_version)
1099-
else:
1100-
match = _ironpython26_sys_version_parser.match(sys_version)
1101-
1102-
if match is None:
1103-
raise ValueError(
1104-
'failed to parse IronPython sys.version: %s' %
1105-
repr(sys_version))
1106-
1107-
version, alt_version, compiler = match.groups()
1108-
buildno = ''
1109-
builddate = ''
1110-
1111-
elif sys.platform.startswith('java'):
1079+
if sys.platform.startswith('java'):
11121080
# Jython
11131081
name = 'Jython'
11141082
match = _sys_version_parser.match(sys_version)
@@ -1171,7 +1139,6 @@ def python_implementation():
11711139
11721140
Currently, the following implementations are identified:
11731141
'CPython' (C implementation of Python),
1174-
'IronPython' (.NET implementation of Python),
11751142
'Jython' (Java implementation of Python),
11761143
'PyPy' (Python implementation of Python).
11771144

Lib/test/test_platform.py

+7-17
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ def test_sys_version(self):
123123
for input, output in (
124124
('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]',
125125
('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')),
126-
('IronPython 1.0.60816 on .NET 2.0.50727.42',
127-
('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')),
128-
('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42',
129-
('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')),
130126
('2.4.3 (truncation, date, t) \n[GCC]',
131127
('CPython', '2.4.3', '', '', 'truncation', 'date t', 'GCC')),
132128
('2.4.3 (truncation, date, ) \n[GCC]',
@@ -161,20 +157,11 @@ def test_sys_version(self):
161157
('r261:67515', 'Dec 6 2008 15:26:00'),
162158
'GCC 4.0.1 (Apple Computer, Inc. build 5370)'),
163159

164-
("IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.3053", None, "cli")
160+
("3.10.8 (tags/v3.10.8:aaaf517424, Feb 14 2023, 16:28:12) [GCC 9.4.0]",
161+
None, "linux")
165162
:
166-
("IronPython", "2.0.0", "", "", ("", ""),
167-
".NET 2.0.50727.3053"),
168-
169-
("2.6.1 (IronPython 2.6.1 (2.6.10920.0) on .NET 2.0.50727.1433)", None, "cli")
170-
:
171-
("IronPython", "2.6.1", "", "", ("", ""),
172-
".NET 2.0.50727.1433"),
173-
174-
("2.7.4 (IronPython 2.7.4 (2.7.0.40) on Mono 4.0.30319.1 (32-bit))", None, "cli")
175-
:
176-
("IronPython", "2.7.4", "", "", ("", ""),
177-
"Mono 4.0.30319.1 (32-bit)"),
163+
('CPython', '3.10.8', '', '',
164+
('tags/v3.10.8:aaaf517424', 'Feb 14 2023 16:28:12'), 'GCC 9.4.0'),
178165

179166
("2.5 (trunk:6107, Mar 26 2009, 13:02:18) \n[Java HotSpot(TM) Client VM (\"Apple Computer, Inc.\")]",
180167
('Jython', 'trunk', '6107'), "java1.5.0_16")
@@ -205,6 +192,9 @@ def test_sys_version(self):
205192
self.assertEqual(platform.python_build(), info[4])
206193
self.assertEqual(platform.python_compiler(), info[5])
207194

195+
with self.assertRaises(ValueError):
196+
platform._sys_version('2. 4.3 (truncation) \n[GCC]')
197+
208198
def test_system_alias(self):
209199
res = platform.system_alias(
210200
platform.system(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improve import time of ``platform`` by removing IronPython version parsing. The IronPython version parsing
2+
was not functional (see https://github.com/IronLanguages/ironpython3/issues/1667).

0 commit comments

Comments
 (0)