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

Function _build_closure

Lib/annotationlib.py:853–880  ·  view source on GitHub ↗
(annotate, owner, is_class, stringifier_dict, *, allow_evaluation)

Source from the content-addressed store, hash-verified

851
852
853def _build_closure(annotate, owner, is_class, stringifier_dict, *, allow_evaluation):
854 if not annotate.__closure__:
855 return None, None
856 new_closure = []
857 cell_dict = {}
858 for name, cell in zip(annotate.__code__.co_freevars, annotate.__closure__, strict=True):
859 cell_dict[name] = cell
860 new_cell = None
861 if allow_evaluation:
862 try:
863 cell.cell_contents
864 except ValueError:
865 pass
866 else:
867 new_cell = cell
868 if new_cell is None:
869 fwdref = _Stringifier(
870 name,
871 cell=cell,
872 owner=owner,
873 globals=annotate.__globals__,
874 is_class=is_class,
875 stringifier_dict=stringifier_dict,
876 )
877 stringifier_dict.stringifiers.append(fwdref)
878 new_cell = types.CellType(fwdref)
879 new_closure.append(new_cell)
880 return tuple(new_closure), cell_dict
881
882
883def _stringify_single(anno):

Callers 1

call_annotate_functionFunction · 0.85

Calls 2

_StringifierClass · 0.85
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…