Skip to content

Commit d9bf2e8

Browse files
committed
Remove wrapping of annotate.__code__ AttributeErrors
1 parent 095cfb5 commit d9bf2e8

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

Lib/annotationlib.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -740,14 +740,7 @@ def call_annotate_function(annotate, format, *, owner=None, _is_evaluate=False):
740740
annotate, owner, is_class, globals,
741741
getattr(annotate, "__globals__", {}), allow_evaluation=False
742742
)
743-
try:
744-
annotate_code = annotate.__code__
745-
except AttributeError:
746-
raise AttributeError(
747-
"annotate function requires __code__ attribute",
748-
name="__code__",
749-
obj=annotate
750-
)
743+
annotate_code = annotate.__code__
751744
func = types.FunctionType(
752745
annotate_code,
753746
globals,
@@ -798,14 +791,7 @@ def call_annotate_function(annotate, format, *, owner=None, _is_evaluate=False):
798791
closure, cell_dict = _build_closure(
799792
annotate, owner, is_class, globals, annotate_globals, allow_evaluation=True
800793
)
801-
try:
802-
annotate_code = annotate.__code__
803-
except AttributeError:
804-
raise AttributeError(
805-
"annotate function requires __code__ attribute",
806-
name="__code__",
807-
obj=annotate
808-
)
794+
annotate_code = annotate.__code__
809795
func = types.FunctionType(
810796
annotate_code,
811797
globals,

0 commit comments

Comments
 (0)