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

Function read_refcount_data

Doc/tools/extensions/c_annotations.py:81–114  ·  view source on GitHub ↗
(refcount_filename: Path)

Source from the content-addressed store, hash-verified

79
80
81def read_refcount_data(refcount_filename: Path) -> dict[str, RefCountEntry]:
82 refcount_data = {}
83 refcounts = refcount_filename.read_text(encoding="utf8")
84 for line in refcounts.splitlines():
85 line = line.strip()
86 if not line or line.startswith("#"):
87 # blank lines and comments
88 continue
89
90 # Each line is of the form
91 # function ':' type ':' [param name] ':' [refcount effect] ':' [comment]
92 parts = line.split(":", 4)
93 if len(parts) != 5:
94 raise ValueError(f"Wrong field count in {line!r}")
95 function, type, arg, refcount, _comment = parts
96
97 # Get the entry, creating it if needed:
98 try:
99 entry = refcount_data[function]
100 except KeyError:
101 entry = refcount_data[function] = RefCountEntry(function)
102 if not refcount or refcount == "null":
103 refcount = None
104 else:
105 refcount = int(refcount)
106 # Update the entry with the new parameter
107 # or the result information.
108 if arg:
109 entry.args.append((arg, type, refcount))
110 else:
111 entry.result_type = type
112 entry.result_refs = refcount
113
114 return refcount_data
115
116
117def read_stable_abi_data(stable_abi_file: Path) -> dict[str, StableABIEntry]:

Callers 1

init_annotationsFunction · 0.85

Calls 7

RefCountEntryClass · 0.85
read_textMethod · 0.45
splitlinesMethod · 0.45
stripMethod · 0.45
startswithMethod · 0.45
splitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…