@@ -108,6 +108,7 @@ 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 ;
111112
112113 ste -> ste_symbols = NULL ;
113114 ste -> ste_varnames = NULL ;
@@ -185,6 +186,7 @@ ste_dealloc(PyObject *op)
185186 ste -> ste_table = NULL ;
186187 Py_XDECREF (ste -> ste_id );
187188 Py_XDECREF (ste -> ste_name );
189+ Py_XDECREF (ste -> ste_function_name );
188190 Py_XDECREF (ste -> ste_symbols );
189191 Py_XDECREF (ste -> ste_varnames );
190192 Py_XDECREF (ste -> ste_children );
@@ -196,17 +198,9 @@ ste_dealloc(PyObject *op)
196198
197199#define OFF (x ) offsetof(PySTEntryObject, x)
198200
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-
208201static PyMemberDef ste_memberlist [] = {
209202 {"id" , _Py_T_OBJECT , OFF (ste_id ), Py_READONLY },
203+ {"name" , _Py_T_OBJECT , OFF (ste_name ), Py_READONLY },
210204 {"symbols" , _Py_T_OBJECT , OFF (ste_symbols ), Py_READONLY },
211205 {"varnames" , _Py_T_OBJECT , OFF (ste_varnames ), Py_READONLY },
212206 {"children" , _Py_T_OBJECT , OFF (ste_children ), Py_READONLY },
@@ -216,14 +210,6 @@ static PyMemberDef ste_memberlist[] = {
216210 {NULL }
217211};
218212
219- static PyGetSetDef ste_getsetlist [] = {
220- {"name" ,
221- (getter )ste_get_name , NULL ,
222- NULL ,
223- NULL },
224- {NULL }
225- };
226-
227213PyTypeObject PySTEntry_Type = {
228214 PyVarObject_HEAD_INIT (& PyType_Type , 0 )
229215 "symtable entry" ,
@@ -254,7 +240,7 @@ PyTypeObject PySTEntry_Type = {
254240 0 , /* tp_iternext */
255241 0 , /* tp_methods */
256242 ste_memberlist , /* tp_members */
257- ste_getsetlist , /* tp_getset */
243+ 0 , /* tp_getset */
258244 0 , /* tp_base */
259245 0 , /* tp_dict */
260246 0 , /* tp_descr_get */
@@ -2787,8 +2773,7 @@ symtable_visit_annotation(struct symtable *st, expr_ty annotation, void *key)
27872773 struct _symtable_entry * parent_ste = st -> st_cur ;
27882774 if (parent_ste -> ste_annotation_block == NULL ) {
27892775 _Py_block_ty current_type = parent_ste -> ste_type ;
2790- _Py_DECLARE_STR (empty , "" );
2791- if (!symtable_enter_block (st , & _Py_STR (empty ), AnnotationBlock ,
2776+ if (!symtable_enter_block (st , & _Py_ID (__annotate__ ), AnnotationBlock ,
27922777 key , LOCATION (annotation ))) {
27932778 return 0 ;
27942779 }
@@ -2843,10 +2828,11 @@ symtable_visit_annotations(struct symtable *st, stmt_ty o, arguments_ty a, expr_
28432828{
28442829 int is_in_class = st -> st_cur -> ste_can_see_class_scope ;
28452830 _Py_block_ty current_type = st -> st_cur -> ste_type ;
2846- if (!symtable_enter_block (st , function_ste -> ste_name , AnnotationBlock ,
2831+ if (!symtable_enter_block (st , & _Py_ID ( __annotate__ ) , AnnotationBlock ,
28472832 (void * )a , LOCATION (o ))) {
28482833 return 0 ;
28492834 }
2835+ Py_XSETREF (st -> st_cur -> ste_function_name , Py_NewRef (function_ste -> ste_name ));
28502836 if (is_in_class || current_type == ClassBlock ) {
28512837 st -> st_cur -> ste_can_see_class_scope = 1 ;
28522838 if (!symtable_add_def (st , & _Py_ID (__classdict__ ), USE , LOCATION (o ))) {
0 commit comments