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

Function _read_patchlevel_version

PC/layout/support/constants.py:37–61  ·  view source on GitHub ↗
(sources)

Source from the content-addressed store, hash-verified

35
36
37def _read_patchlevel_version(sources):
38 if not sources.match("Include"):
39 sources /= "Include"
40 values = {}
41 with open(sources / "patchlevel.h", "r", encoding="utf-8") as f:
42 for line in f:
43 m = re.match(r'#\s*define\s+(PY_\S+?)\s+(\S+)', line.strip(), re.I)
44 if m and m.group(2):
45 v = m.group(2)
46 if v.startswith('"'):
47 v = v[1:-1]
48 else:
49 v = values.get(v, v)
50 if isinstance(v, str):
51 try:
52 v = int(v, 16 if v.startswith("0x") else 10)
53 except ValueError:
54 pass
55 values[m.group(1)] = v
56 return (
57 values["PY_MAJOR_VERSION"],
58 values["PY_MINOR_VERSION"],
59 values["PY_MICRO_VERSION"],
60 values["PY_RELEASE_LEVEL"] << 4 | values["PY_RELEASE_SERIAL"],
61 )
62
63
64def check_patchlevel_version(sources):

Callers 2

_unpack_hexversionFunction · 0.85
check_patchlevel_versionFunction · 0.85

Calls 6

openFunction · 0.50
matchMethod · 0.45
stripMethod · 0.45
groupMethod · 0.45
startswithMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…