MCPcopy Index your code
hub / github.com/python/cpython / _sys_version

Function _sys_version

Lib/platform.py:1076–1178  ·  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 identification s

(sys_version=None)

Source from the content-addressed store, hash-verified

1074_sys_version_cache = {}
1075
1076def _sys_version(sys_version=None):
1077
1078 """ Returns a parsed version of Python's sys.version as tuple
1079 (name, version, branch, revision, buildno, builddate, compiler)
1080 referring to the Python implementation name, version, branch,
1081 revision, build number, build date/time as string and the compiler
1082 identification string.
1083
1084 Note that unlike the Python sys.version, the returned value
1085 for the Python version will always include the patchlevel (it
1086 defaults to '.0').
1087
1088 The function returns empty strings for tuple entries that
1089 cannot be determined.
1090
1091 sys_version may be given to parse an alternative version
1092 string, e.g. if the version was read from a different Python
1093 interpreter.
1094
1095 """
1096 # Get the Python version
1097 if sys_version is None:
1098 sys_version = sys.version
1099
1100 # Try the cache first
1101 result = _sys_version_cache.get(sys_version, None)
1102 if result is not None:
1103 return result
1104
1105 if sys.platform.startswith('java'):
1106 # Jython
1107 jython_sys_version_parser = re.compile(
1108 r'([\w.+]+)\s*' # "version<space>"
1109 r'\(#?([^,]+)' # "(#buildno"
1110 r'(?:,\s*([\w ]*)' # ", builddate"
1111 r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)<space>"
1112 r'\[([^\]]+)\]?', re.ASCII) # "[compiler]"
1113 name = 'Jython'
1114 match = jython_sys_version_parser.match(sys_version)
1115 if match is None:
1116 raise ValueError(
1117 'failed to parse Jython sys.version: %s' %
1118 repr(sys_version))
1119 version, buildno, builddate, buildtime, _ = match.groups()
1120 if builddate is None:
1121 builddate = ''
1122 compiler = sys.platform
1123
1124 elif "PyPy" in sys_version:
1125 # PyPy
1126 pypy_sys_version_parser = re.compile(
1127 r'([\w.+]+)\s*'
1128 r'\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*'
1129 r'\[PyPy [^\]]+\]?')
1130
1131 name = "PyPy"
1132 match = pypy_sys_version_parser.match(sys_version)
1133 if match is None:

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 8

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…