MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _sys_version

Function _sys_version

tools/python-3.11.9-amd64/Lib/platform.py:1002–1104  ·  view source on GitHub ↗

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 identificati

(sys_version=None)

Source from the content-addressed store, hash-verified

1000_sys_version_cache = {}
1001
1002def _sys_version(sys_version=None):
1003
1004 """ Returns a parsed version of Python's sys.version as tuple
1005 (name, version, branch, revision, buildno, builddate, compiler)
1006 referring to the Python implementation name, version, branch,
1007 revision, build number, build date/time as string and the compiler
1008 identification string.
1009
1010 Note that unlike the Python sys.version, the returned value
1011 for the Python version will always include the patchlevel (it
1012 defaults to '.0').
1013
1014 The function returns empty strings for tuple entries that
1015 cannot be determined.
1016
1017 sys_version may be given to parse an alternative version
1018 string, e.g. if the version was read from a different Python
1019 interpreter.
1020
1021 """
1022 # Get the Python version
1023 if sys_version is None:
1024 sys_version = sys.version
1025
1026 # Try the cache first
1027 result = _sys_version_cache.get(sys_version, None)
1028 if result is not None:
1029 return result
1030
1031 # Parse it
1032 if 'IronPython' in sys_version:
1033 # IronPython
1034 name = 'IronPython'
1035 if sys_version.startswith('IronPython'):
1036 match = _ironpython_sys_version_parser.match(sys_version)
1037 else:
1038 match = _ironpython26_sys_version_parser.match(sys_version)
1039
1040 if match is None:
1041 raise ValueError(
1042 'failed to parse IronPython sys.version: %s' %
1043 repr(sys_version))
1044
1045 version, alt_version, compiler = match.groups()
1046 buildno = ''
1047 builddate = ''
1048
1049 elif sys.platform.startswith('java'):
1050 # Jython
1051 name = 'Jython'
1052 match = _sys_version_parser.match(sys_version)
1053 if match is None:
1054 raise ValueError(
1055 'failed to parse Jython sys.version: %s' %
1056 repr(sys_version))
1057 version, buildno, builddate, buildtime, _ = match.groups()
1058 if builddate is None:
1059 builddate = ''

Callers 7

python_implementationFunction · 0.85
python_versionFunction · 0.85
python_version_tupleFunction · 0.85
python_branchFunction · 0.85
python_revisionFunction · 0.85
python_buildFunction · 0.85
python_compilerFunction · 0.85

Calls 7

startswithMethod · 0.80
getMethod · 0.45
matchMethod · 0.45
groupsMethod · 0.45
splitMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected