@@ -108,7 +108,6 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block,
108108 ste -> ste_id = k ; /* ste owns reference to k */
109109
110110 ste -> ste_name = Py_NewRef (name );
111- ste -> ste_function_name = NULL ;
112111
113112 ste -> ste_symbols = NULL ;
114113 ste -> ste_varnames = NULL ;
@@ -186,7 +185,6 @@ ste_dealloc(PyObject *op)
186185 ste -> ste_table = NULL ;
187186 Py_XDECREF (ste -> ste_id );
188187 Py_XDECREF (ste -> ste_name );
189- Py_XDECREF (ste -> ste_function_name );
190188 Py_XDECREF (ste -> ste_symbols );
191189 Py_XDECREF (ste -> ste_varnames );
192190 Py_XDECREF (ste -> ste_children );
@@ -198,9 +196,17 @@ ste_dealloc(PyObject *op)
198196
199197#define OFF (x ) offsetof(PySTEntryObject, x)
200198
199+ static PyObject *
200+ ste_get_name (PySTEntryObject * ste , void * context )
201+ {
202+ if (ste -> ste_type == AnnotationBlock ) {
203+ return Py_NewRef (& _Py_ID (__annotate__ ));
204+ }
205+ return Py_NewRef (ste -> ste_name );
206+ }
207+
201208static PyMemberDef ste_memberlist [] = {
202209 {"id" , _Py_T_OBJECT , OFF (ste_id ), Py_READONLY },
203- {"name" , _Py_T_OBJECT , OFF (ste_name ), Py_READONLY },
204210 {"symbols" , _Py_T_OBJECT , OFF (ste_symbols ), Py_READONLY },
205211 {"varnames" , _Py_T_OBJECT , OFF (ste_varnames ), Py_READONLY },
206212 {"children" , _Py_T_OBJECT , OFF (ste_children ), Py_READONLY },
@@ -210,6 +216,14 @@ static PyMemberDef ste_memberlist[] = {
210216 {NULL }
211217};
212218
219+ static PyGetSetDef ste_getsetlist [] = {
220+ {"name" ,
221+ (getter )ste_get_name , NULL ,
222+ NULL ,
223+ NULL },
224+ {NULL }
225+ };
226+
213227PyTypeObject PySTEntry_Type = {
214228 PyVarObject_HEAD_INIT (& PyType_Type , 0 )
215229 "symtable entry" ,
@@ -240,7 +254,7 @@ PyTypeObject PySTEntry_Type = {
240254 0 , /* tp_iternext */
241255 0 , /* tp_methods */
242256 ste_memberlist , /* tp_members */
243- 0 , /* tp_getset */
257+ ste_getsetlist , /* tp_getset */
244258 0 , /* tp_base */
245259 0 , /* tp_dict */
246260 0 , /* tp_descr_get */
@@ -2773,7 +2787,8 @@ symtable_visit_annotation(struct symtable *st, expr_ty annotation, void *key)
27732787 struct _symtable_entry * parent_ste = st -> st_cur ;
27742788 if (parent_ste -> ste_annotation_block == NULL ) {
27752789 _Py_block_ty current_type = parent_ste -> ste_type ;
2776- if (!symtable_enter_block (st , & _Py_ID (__annotate__ ), AnnotationBlock ,
2790+ _Py_DECLARE_STR (empty , "" );
2791+ if (!symtable_enter_block (st , & _Py_STR (empty ), AnnotationBlock ,
27772792 key , LOCATION (annotation ))) {
27782793 return 0 ;
27792794 }
@@ -2828,11 +2843,10 @@ symtable_visit_annotations(struct symtable *st, stmt_ty o, arguments_ty a, expr_
28282843{
28292844 int is_in_class = st -> st_cur -> ste_can_see_class_scope ;
28302845 _Py_block_ty current_type = st -> st_cur -> ste_type ;
2831- if (!symtable_enter_block (st , & _Py_ID ( __annotate__ ) , AnnotationBlock ,
2846+ if (!symtable_enter_block (st , function_ste -> ste_name , AnnotationBlock ,
28322847 (void * )a , LOCATION (o ))) {
28332848 return 0 ;
28342849 }
2835- Py_XSETREF (st -> st_cur -> ste_function_name , Py_NewRef (function_ste -> ste_name ));
28362850 if (is_in_class || current_type == ClassBlock ) {
28372851 st -> st_cur -> ste_can_see_class_scope = 1 ;
28382852 if (!symtable_add_def (st , & _Py_ID (__classdict__ ), USE , LOCATION (o ))) {
0 commit comments