@@ -12,8 +12,9 @@ struct _mod; // Type defined in pycore_ast.h
1212
1313typedef enum _block_type {
1414 FunctionBlock , ClassBlock , ModuleBlock ,
15- // Used for annotations if 'from __future__ import annotations' is active.
16- // Annotation blocks cannot bind names and are not evaluated.
15+ // Used for annotations. If 'from __future__ import annotations' is active,
16+ // annotation blocks cannot bind names and are not evaluated. Otherwise, they
17+ // are lazily evaluated (see PEP 649).
1718 AnnotationBlock ,
1819 // Used for generics and type aliases. These work mostly like functions
1920 // (see PEP 695 for details). The three different blocks function identically;
@@ -89,6 +90,7 @@ typedef struct _symtable_entry {
8990 including free refs to globals */
9091 unsigned ste_generator : 1 ; /* true if namespace is a generator */
9192 unsigned ste_coroutine : 1 ; /* true if namespace is a coroutine */
93+ unsigned ste_annotations_used : 1 ; /* true if there are any annotations in this scope */
9294 _Py_comprehension_ty ste_comprehension ; /* Kind of comprehension (if any) */
9395 unsigned ste_varargs : 1 ; /* true if block has varargs */
9496 unsigned ste_varkeywords : 1 ; /* true if block has varkeywords */
@@ -110,6 +112,7 @@ typedef struct _symtable_entry {
110112 int ste_end_col_offset ; /* end offset of first line of block */
111113 int ste_opt_lineno ; /* lineno of last exec or import * */
112114 int ste_opt_col_offset ; /* offset of last exec or import * */
115+ struct _symtable_entry * ste_annotation_block ; /* symbol table entry for this entry's annotations */
113116 struct symtable * ste_table ;
114117} PySTEntryObject ;
115118
@@ -126,6 +129,7 @@ extern struct symtable* _PySymtable_Build(
126129 PyObject * filename ,
127130 _PyFutureFeatures * future );
128131extern PySTEntryObject * _PySymtable_Lookup (struct symtable * , void * );
132+ extern int _PySymtable_LookupOptional (struct symtable * , void * , PySTEntryObject * * );
129133
130134extern void _PySymtable_Free (struct symtable * );
131135
0 commit comments