From 6df27f5a58a456ebad9fcecb03dcdbc69c3bd86a Mon Sep 17 00:00:00 2001 From: Aviv Palivoda Date: Thu, 6 Feb 2020 18:29:53 +0200 Subject: [PATCH] Remove unsused code in platform.py --- Lib/platform.py | 133 ------------------------------------------------ 1 file changed, 133 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index c14ce6605..21d11ff17 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -943,139 +943,6 @@ def processor(): """ return uname().processor -### Various APIs for extracting information from sys.version - -_sys_version_parser = re.compile( - r'([\w.+]+)\s*' # "version" - r'\(#?([^,]+)' # "(#buildno" - r'(?:,\s*([\w ]*)' # ", builddate" - 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) - -# 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*' - r'\[PyPy [^\]]+\]?') - -_sys_version_cache = {} - -def _sys_version(sys_version=None): - - """ Returns a parsed version of Python's sys.version as tuple - (name, version, branch, revision, buildno, builddate, compiler) - referring to the Python implementation name, version, branch, - revision, build number, build date/time as string and the compiler - identification string. - - Note that unlike the Python sys.version, the returned value - for the Python version will always include the patchlevel (it - defaults to '.0'). - - The function returns empty strings for tuple entries that - cannot be determined. - - sys_version may be given to parse an alternative version - string, e.g. if the version was read from a different Python - interpreter. - - """ - # Get the Python version - if sys_version is None: - sys_version = sys.version - - # Try the cache first - result = _sys_version_cache.get(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'): - # Jython - name = 'Jython' - match = _sys_version_parser.match(sys_version) - if match is None: - raise ValueError( - 'failed to parse Jython sys.version: %s' % - repr(sys_version)) - version, buildno, builddate, buildtime, _ = match.groups() - if builddate is None: - builddate = '' - compiler = sys.platform - - elif "PyPy" in sys_version: - # PyPy - name = "PyPy" - match = _pypy_sys_version_parser.match(sys_version) - if match is None: - raise ValueError("failed to parse PyPy sys.version: %s" % - repr(sys_version)) - version, buildno, builddate, buildtime = match.groups() - compiler = "" - - else: - # CPython - match = _sys_version_parser.match(sys_version) - if match is None: - raise ValueError( - 'failed to parse CPython sys.version: %s' % - repr(sys_version)) - version, buildno, builddate, buildtime, compiler = \ - match.groups() - name = 'CPython' - if builddate is None: - builddate = '' - elif buildtime: - builddate = builddate + ' ' + buildtime - - if hasattr(sys, '_git'): - _, branch, revision = sys._git - elif hasattr(sys, '_mercurial'): - _, branch, revision = sys._mercurial - else: - branch = '' - revision = '' - - # Add the patchlevel version if missing - l = version.split('.') - if len(l) == 2: - l.append('0') - version = '.'.join(l) - - # Build and cache the result - result = (name, version, branch, revision, buildno, builddate, compiler) - _sys_version_cache[sys_version] = result - return result # RustPython specific from _platform import *