mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
gh-102491: Remove IronPython version check in sys_version (#102492)
This commit is contained in:
parent
699cb20ae6
commit
382ee2f0f2
3 changed files with 10 additions and 51 deletions
|
@ -1040,20 +1040,6 @@ _sys_version_parser = re.compile(
|
||||||
r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)<space>"
|
r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)<space>"
|
||||||
r'\[([^\]]+)\]?', re.ASCII) # "[compiler]"
|
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(
|
_pypy_sys_version_parser = re.compile(
|
||||||
r'([\w.+]+)\s*'
|
r'([\w.+]+)\s*'
|
||||||
r'\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*'
|
r'\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*'
|
||||||
|
@ -1090,25 +1076,7 @@ def _sys_version(sys_version=None):
|
||||||
if result is not None:
|
if result is not None:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# Parse it
|
if sys.platform.startswith('java'):
|
||||||
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'):
|
|
||||||
# Jython
|
# Jython
|
||||||
name = 'Jython'
|
name = 'Jython'
|
||||||
match = _sys_version_parser.match(sys_version)
|
match = _sys_version_parser.match(sys_version)
|
||||||
|
@ -1171,7 +1139,6 @@ def python_implementation():
|
||||||
|
|
||||||
Currently, the following implementations are identified:
|
Currently, the following implementations are identified:
|
||||||
'CPython' (C implementation of Python),
|
'CPython' (C implementation of Python),
|
||||||
'IronPython' (.NET implementation of Python),
|
|
||||||
'Jython' (Java implementation of Python),
|
'Jython' (Java implementation of Python),
|
||||||
'PyPy' (Python implementation of Python).
|
'PyPy' (Python implementation of Python).
|
||||||
|
|
||||||
|
|
|
@ -123,10 +123,6 @@ class PlatformTest(unittest.TestCase):
|
||||||
for input, output in (
|
for input, output in (
|
||||||
('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]',
|
('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)')),
|
('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]',
|
('2.4.3 (truncation, date, t) \n[GCC]',
|
||||||
('CPython', '2.4.3', '', '', 'truncation', 'date t', 'GCC')),
|
('CPython', '2.4.3', '', '', 'truncation', 'date t', 'GCC')),
|
||||||
('2.4.3 (truncation, date, ) \n[GCC]',
|
('2.4.3 (truncation, date, ) \n[GCC]',
|
||||||
|
@ -161,20 +157,11 @@ class PlatformTest(unittest.TestCase):
|
||||||
('r261:67515', 'Dec 6 2008 15:26:00'),
|
('r261:67515', 'Dec 6 2008 15:26:00'),
|
||||||
'GCC 4.0.1 (Apple Computer, Inc. build 5370)'),
|
'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", "", "", ("", ""),
|
('CPython', '3.10.8', '', '',
|
||||||
".NET 2.0.50727.3053"),
|
('tags/v3.10.8:aaaf517424', 'Feb 14 2023 16:28:12'), 'GCC 9.4.0'),
|
||||||
|
|
||||||
("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.\")]",
|
("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', '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_build(), info[4])
|
||||||
self.assertEqual(platform.python_compiler(), info[5])
|
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):
|
def test_system_alias(self):
|
||||||
res = platform.system_alias(
|
res = platform.system_alias(
|
||||||
platform.system(),
|
platform.system(),
|
||||||
|
|
|
@ -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).
|
Loading…
Add table
Add a link
Reference in a new issue