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

Function read_threadsafety_data

Doc/tools/extensions/c_annotations.py:136–155  ·  view source on GitHub ↗
(
    threadsafety_filename: Path,
)

Source from the content-addressed store, hash-verified

134
135
136def read_threadsafety_data(
137 threadsafety_filename: Path,
138) -> dict[str, ThreadSafetyEntry]:
139 threadsafety_data = {}
140 for line in threadsafety_filename.read_text(encoding="utf8").splitlines():
141 line = line.strip()
142 if not line or line.startswith("#"):
143 continue
144 # Each line is of the form: function_name : level : [comment]
145 parts = line.split(":", 2)
146 if len(parts) < 2:
147 raise ValueError(f"Wrong field count in {line!r}")
148 name, level = parts[0].strip(), parts[1].strip()
149 if level not in _VALID_THREADSAFETY_LEVELS:
150 raise ValueError(
151 f"Unknown thread safety level {level!r} for {name!r}. "
152 f"Valid levels: {sorted(_VALID_THREADSAFETY_LEVELS)}"
153 )
154 threadsafety_data[name] = ThreadSafetyEntry(name=name, level=level)
155 return threadsafety_data
156
157
158def add_annotations(app: Sphinx, doctree: nodes.document) -> None:

Callers 1

init_annotationsFunction · 0.85

Calls 6

ThreadSafetyEntryClass · 0.85
splitlinesMethod · 0.45
read_textMethod · 0.45
stripMethod · 0.45
startswithMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…