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

Function _get_system_version

Lib/_osx_support.py:87–115  ·  view source on GitHub ↗

Return the OS X system version as a string

()

Source from the content-addressed store, hash-verified

85_SYSTEM_VERSION = None
86
87def _get_system_version():
88 """Return the OS X system version as a string"""
89 # Reading this plist is a documented way to get the system
90 # version (see the documentation for the Gestalt Manager)
91 # We avoid using platform.mac_ver to avoid possible bootstrap issues during
92 # the build of Python itself (distutils is used to build standard library
93 # extensions).
94
95 global _SYSTEM_VERSION
96
97 if _SYSTEM_VERSION is None:
98 _SYSTEM_VERSION = ''
99 try:
100 f = open('/System/Library/CoreServices/SystemVersion.plist', encoding="utf-8")
101 except OSError:
102 # We're on a plain darwin box, fall back to the default
103 # behaviour.
104 pass
105 else:
106 try:
107 m = re.search(r'<key>ProductUserVisibleVersion</key>\s*'
108 r'<string>(.*?)</string>', f.read())
109 finally:
110 f.close()
111 if m is not None:
112 _SYSTEM_VERSION = '.'.join(m.group(1).split('.')[:2])
113 # else: fall back to the default behaviour
114
115 return _SYSTEM_VERSION
116
117_SYSTEM_VERSION_TUPLE = None
118def _get_system_version_tuple():

Callers 2

get_platform_osxFunction · 0.85

Calls 7

openFunction · 0.70
searchMethod · 0.45
readMethod · 0.45
closeMethod · 0.45
joinMethod · 0.45
splitMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…