From c8845bcddbc47b506298a250c18d86eaf11a0e13 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Tue, 7 Mar 2023 10:37:06 +0100 Subject: [PATCH 1/6] remove ironpython python 2.x version check --- Lib/platform.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index f2b0d1d1bd3f5d..28f51936c975df 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1046,14 +1046,6 @@ def processor(): 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*' @@ -1094,10 +1086,7 @@ def _sys_version(sys_version=None): 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) + match = _ironpython_sys_version_parser.match(sys_version) if match is None: raise ValueError( From b9d0b333edf2066e7d2a96178639182965cfe10b Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Tue, 7 Mar 2023 12:45:59 +0100 Subject: [PATCH 2/6] remove old tests; add a new test for python 3.x --- Lib/test/test_platform.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 72942dda342418..fa5dc811d84b05 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -161,21 +161,17 @@ def test_sys_version(self): ('r261:67515', 'Dec 6 2008 15:26:00'), 'GCC 4.0.1 (Apple Computer, Inc. build 5370)'), + ("3.10.8 (tags/v3.10.8:aaaf517424, Feb 14 2023, 16:28:12) [GCC 9.4.0]", + None, "linux") + : + ('CPython', '3.10.8', 'tags/v3.10.8', 'aaaf517424', + ('tags/v3.10.8:aaaf517424', 'Feb 14 2023 16:28:12'), 'GCC 9.4.0'), + ("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") : From 0b51602abe5deb632f1fce19b87f4d291ed4dece Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Tue, 7 Mar 2023 12:57:09 +0100 Subject: [PATCH 3/6] increase coverage of _sys.version test --- Lib/test/test_platform.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index fa5dc811d84b05..35de13c0568122 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -201,6 +201,9 @@ def test_sys_version(self): 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(), From e56ddfc98e2544b82cb01e587e2ff6fd969c443c Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Tue, 7 Mar 2023 14:18:17 +0100 Subject: [PATCH 4/6] fix test --- Lib/test/test_platform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 35de13c0568122..bad001bdc61d04 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -164,7 +164,7 @@ def test_sys_version(self): ("3.10.8 (tags/v3.10.8:aaaf517424, Feb 14 2023, 16:28:12) [GCC 9.4.0]", None, "linux") : - ('CPython', '3.10.8', 'tags/v3.10.8', 'aaaf517424', + ('CPython', '3.10.8', '', '', ('tags/v3.10.8:aaaf517424', 'Feb 14 2023 16:28:12'), 'GCC 9.4.0'), ("IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.3053", None, "cli") From 839baaea3580e2c8467361f269b0b35f2cabbd21 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 8 Mar 2023 08:37:38 +0000 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2023-03-08-08-37-36.gh-issue-102491.SFvvsC.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-03-08-08-37-36.gh-issue-102491.SFvvsC.rst 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 00000000000000..aae0b02423c567 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-03-08-08-37-36.gh-issue-102491.SFvvsC.rst @@ -0,0 +1 @@ +Improve import time of ``platform`` be removing a legacy ironpython 2.x version check. From 7ffe733302b96f4f61d95eb794205730be1e6e76 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Sun, 12 Mar 2023 21:45:02 +0100 Subject: [PATCH 6/6] remove IronPython version checks --- Lib/platform.py | 24 +------------------ Lib/test/test_platform.py | 9 ------- ...-03-08-08-37-36.gh-issue-102491.SFvvsC.rst | 3 ++- 3 files changed, 3 insertions(+), 33 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index 28f51936c975df..790ef860bf106e 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1040,12 +1040,6 @@ def processor(): r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)" r'\[([^\]]+)\]?', re.ASCII) # "[compiler]" -_ironpython_sys_version_parser = re.compile( - r'IronPython\s*' - r'([\d\.]+)' - r'(?: \(([\d\.]+)\))?' - r' on (.NET [\d\.]+)', re.ASCII) - _pypy_sys_version_parser = re.compile( r'([\w.+]+)\s*' r'\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*' @@ -1082,22 +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' - match = _ironpython_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) @@ -1160,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 bad001bdc61d04..216973350319fe 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -123,10 +123,6 @@ def test_sys_version(self): 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]', @@ -167,11 +163,6 @@ def test_sys_version(self): ('CPython', '3.10.8', '', '', ('tags/v3.10.8:aaaf517424', 'Feb 14 2023 16:28:12'), 'GCC 9.4.0'), - ("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.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") : 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 index aae0b02423c567..5bdc9ed2f37adc 100644 --- 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 @@ -1 +1,2 @@ -Improve import time of ``platform`` be removing a legacy ironpython 2.x version check. +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).