Skip to content

gh-119180: Only fetch globals and locals if necessary in annotationlib.get_annotations() #135644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lib/annotationlib.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ def get_annotations(
if not eval_str: if not eval_str:
return dict(ann) return dict(ann)


if globals is None or locals is None:
if isinstance(obj, type): if isinstance(obj, type):
# class # class
obj_globals = None obj_globals = None
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,2 @@
Only fetch globals and locals if necessary in
:func:`annotationlib.get_annotations`
Loading