@@ -739,8 +739,16 @@ def call_annotate_function(annotate, format, *, owner=None, _is_evaluate=False):
739739 closure , _ = _build_closure (
740740 annotate , owner , is_class , globals , allow_evaluation = False
741741 )
742+ try :
743+ annotate_code = annotate .__code__
744+ except AttributeError :
745+ raise AttributeError (
746+ "annotate function requires __code__ attribute" ,
747+ name = "__code__" ,
748+ obj = annotate
749+ )
742750 func = types .FunctionType (
743- annotate . __code__ ,
751+ annotate_code ,
744752 globals ,
745753 closure = closure ,
746754 argdefs = annotate_defaults ,
@@ -784,8 +792,16 @@ def call_annotate_function(annotate, format, *, owner=None, _is_evaluate=False):
784792 closure , cell_dict = _build_closure (
785793 annotate , owner , is_class , globals , allow_evaluation = True
786794 )
795+ try :
796+ annotate_code = annotate .__code__
797+ except AttributeError :
798+ raise AttributeError (
799+ "annotate function requires __code__ attribute" ,
800+ name = "__code__" ,
801+ obj = annotate
802+ )
787803 func = types .FunctionType (
788- annotate . __code__ ,
804+ annotate_code ,
789805 globals ,
790806 closure = closure ,
791807 argdefs = annotate_defaults ,
@@ -815,7 +831,7 @@ def call_annotate_function(annotate, format, *, owner=None, _is_evaluate=False):
815831 annotate , owner , is_class , globals , allow_evaluation = False
816832 )
817833 func = types .FunctionType (
818- annotate . __code__ ,
834+ annotate_code ,
819835 globals ,
820836 closure = closure ,
821837 argdefs = annotate_defaults ,
0 commit comments