summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPieter Eendebak <pieter.eendebak@gmail.com>2023-03-19 22:52:47 (GMT)
committerGitHub <noreply@github.com>2023-03-19 22:52:47 (GMT)
commit382ee2f0f2be662fbcabcb4a6b38de416cea0cae (patch)
tree2ee5635ec21239c9ca9b21dd2929510eed6ad9cf
parent699cb20ae6fdef8b0f13d633cf4858465ef3469f (diff)
downloadcpython-382ee2f0f2be662fbcabcb4a6b38de416cea0cae.zip
cpython-382ee2f0f2be662fbcabcb4a6b38de416cea0cae.tar.gz
cpython-382ee2f0f2be662fbcabcb4a6b38de416cea0cae.tar.bz2
gh-102491: Remove IronPython version check in sys_version (#102492)
-rwxr-xr-xLib/platform.py35
-rw-r--r--Lib/test/test_platform.py24
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2023-03-08-08-37-36.gh-issue-102491.SFvvsC.rst2
3 files changed, 10 insertions, 51 deletions
diff --git a/Lib/platform.py b/Lib/platform.py
index f2b0d1d..790ef86 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -1040,20 +1040,6 @@ _sys_version_parser = re.compile(
r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)<space>"
r'\[([^\]]+)\]?', re.ASCII) # "[compiler]"
-_ironpython_sys_version_parser = re.compile(
- r'IronPython\s*'
- r'([\d\.]+)'
- r'(?: \(([\d\.]+)\))?'
- r' on (.NET [\d\.]+)', re.ASCII)
-
-# IronPython covering 2.6 and 2.7
-_ironpython26_sys_version_parser = re.compile(
- r'([\d.]+)\s*'
- r'\(IronPython\s*'
- r'[\d.]+\s*'
- r'\(([\d.]+)\) on ([\w.]+ [\d.]+(?: \(\d+-bit\))?)\)'
-)
-
_pypy_sys_version_parser = re.compile(
r'([\w.+]+)\s*'
r'\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*'
@@ -1090,25 +1076,7 @@ def _sys_version(sys_version=None):
if result is not None:
return result
- # Parse it
- if 'IronPython' in sys_version:
- # IronPython
- name = 'IronPython'
- 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.startswith('java'):
+ if sys.platform.startswith('java'):
# Jython
name = 'Jython'
match = _sys_version_parser.match(sys_version)
@@ -1171,7 +1139,6 @@ def python_implementation():
Currently, the following implementations are identified:
'CPython' (C implementation of Python),
- 'IronPython' (.NET implementation of Python),
'Jython' (Java implementation of Python),
'PyPy' (Python implementation of Python).
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index 72942dd..2169733 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -123,10 +123,6 @@ class PlatformTest(unittest.TestCase):
for input, output in (
('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]',
('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')),
- ('IronPython 1.0.60816 on .NET 2.0.50727.42',
- ('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')),
- ('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42',
- ('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')),
('2.4.3 (truncation, date, t) \n[GCC]',
('CPython', '2.4.3', '', '', 'truncation', 'date t', 'GCC')),
('2.4.3 (truncation, date, ) \n[GCC]',
@@ -161,20 +157,11 @@ class PlatformTest(unittest.TestCase):
('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")
+ ("3.10.8 (tags/v3.10.8:aaaf517424, Feb 14 2023, 16:28:12) [GCC 9.4.0]",
+ None, "linux")
:
- ("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)"),
+ ('CPython', '3.10.8', '', '',
+ ('tags/v3.10.8:aaaf517424', 'Feb 14 2023 16:28:12'), 'GCC 9.4.0'),
("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")
@@ -205,6 +192,9 @@ class PlatformTest(unittest.TestCase):
self.assertEqual(platform.python_build(), info[4])
self.assertEqual(platform.python_compiler(), info[5])
+ with self.assertRaises(ValueError):
+ platform._sys_version('2. 4.3 (truncation) \n[GCC]')
+
def test_system_alias(self):
res = platform.system_alias(
platform.system(),
diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-03-08-08-37-36.gh-issue-102491.SFvvsC.rst b/Misc/NEWS.d/next/Core and Builtins/2023-03-08-08-37-36.gh-issue-102491.SFvvsC.rst
new file mode 100644
index 0000000..5bdc9ed
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2023-03-08-08-37-36.gh-issue-102491.SFvvsC.rst
@@ -0,0 +1,2 @@
+Improve import time of ``platform`` by removing IronPython version parsing. The IronPython version parsing
+was not functional (see https://github.com/IronLanguages/ironpython3/issues/1667).