Skip to content

Commit 7197e17

Browse files
committed
prepare for handling PEP 649
1 parent 1352d08 commit 7197e17

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Lib/symtable.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
DEF_GLOBAL, DEF_NONLOCAL, DEF_LOCAL,
77
DEF_PARAM, DEF_TYPE_PARAM, DEF_IMPORT, DEF_BOUND, DEF_ANNOT,
88
SCOPE_OFF, SCOPE_MASK,
9-
FREE, LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL
9+
FREE, LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL,
1010
)
1111

1212
import weakref
@@ -231,13 +231,14 @@ def is_local_symbol(ident):
231231
if is_local_symbol(st.name):
232232
if st.type == _symtable.TYPE_TYPE_PARAM:
233233
# Current 'st' is an annotation scope with one or
234-
# more children (we expect only one, but we might
235-
# have more in the future). In particular, we need
236-
# to find the corresponding inner function, class or
237-
# type alias.
238-
st = next((c for c in st.children if c.name == st.name), None)
239-
# if 'st' is None, then the annotation scopes are broken
240-
assert st is not None, 'annotation scopes are broken'
234+
# more children and we expect at most one to be of
235+
# type TYPE_FUNCTION and with the same identifier.
236+
for st_c in st.children:
237+
if st_c.name == st.name and st_c.type == _symtable.TYPE_FUNCTION:
238+
d[st.name] = 1
239+
break
240+
else:
241+
continue
241242

242243
# only select function-like symbols
243244
if st.type == _symtable.TYPE_FUNCTION:

0 commit comments

Comments
 (0)