https://github.com/python/cpython/commit/83cfd87568b99539cb6ce30220177101f890d6b3 commit: 83cfd87568b99539cb6ce30220177101f890d6b3 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: JelleZijlstra <[email protected]> date: 2025-11-20T04:33:18Z summary:
[3.14] gh-141489: Simplify closure/freevar iteration in `annotationlib._build_closure()` (GH-141490) (#141776) gh-141489: Simplify closure/freevar iteration in `annotationlib._build_closure()` (GH-141490) (cherry picked from commit a35c683da55e77c96828fd0421640787337cfc64) Co-authored-by: dr-carlos <[email protected]> files: M Lib/annotationlib.py diff --git a/Lib/annotationlib.py b/Lib/annotationlib.py index 33907b1fc2a53a..a5788cdbfae3f5 100644 --- a/Lib/annotationlib.py +++ b/Lib/annotationlib.py @@ -844,14 +844,9 @@ def call_annotate_function(annotate, format, *, owner=None, _is_evaluate=False): def _build_closure(annotate, owner, is_class, stringifier_dict, *, allow_evaluation): if not annotate.__closure__: return None, None - freevars = annotate.__code__.co_freevars new_closure = [] cell_dict = {} - for i, cell in enumerate(annotate.__closure__): - if i < len(freevars): - name = freevars[i] - else: - name = "__cell__" + for name, cell in zip(annotate.__code__.co_freevars, annotate.__closure__, strict=True): cell_dict[name] = cell new_cell = None if allow_evaluation: _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
