8000 gh-119698: fix `symtable.Class.get_methods` and document its behaviour correctly by picnixz · Pull Request #120151 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-119698: fix symtable.Class.get_methods and document its behaviour correctly #120151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jun 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update comments
  • Loading branch information
picnixz committed Jun 8, 2024
commit 1352d0856ba7d513d341a29b30675312d98f145c
8 changes: 5 additions & 3 deletions Lib/symtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,15 @@ def is_local_symbol(ident):
if is_local_symbol(st.name):
if st.type == _symtable.TYPE_TYPE_PARAM:
# Current 'st' is an annotation scope with one or
# more children (we expect only one, but ,
# so we need to find the corresponding inner function,
# class or type alias.
# more children (we expect only one, but we might
# have more in the future). In particular, we need
# to find the corresponding inner function, class or
# type alias.
st = next((c for c in st.children if c.name == st.name), None)
# if 'st' is None, then the annotation scopes are broken
assert st is not None, 'annotation scopes are broken'

# only select function-like symbols
if st.type == _symtable.TYPE_FUNCTION:
d[st.name] = 1
self.__methods = tuple(d)
Expand Down
0