mirror of
https://github.com/python/cpython.git
synced 2025-11-03 15:11:34 +00:00
[3.13] gh-119698: fix a special case in symtable.Class.get_methods (GH-121802) (#121909)
(cherry picked from commit 6682d91678)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
4395d68c70
commit
c6ef5aca61
2 changed files with 68 additions and 2 deletions
|
|
@ -238,6 +238,11 @@ def is_local_symbol(ident):
|
|||
if is_local_symbol(st.name):
|
||||
match st.type:
|
||||
case _symtable.TYPE_FUNCTION:
|
||||
# generators are of type TYPE_FUNCTION with a ".0"
|
||||
# parameter as a first parameter (which makes them
|
||||
# distinguishable from a function named 'genexpr')
|
||||
if st.name == 'genexpr' and '.0' in st.varnames:
|
||||
continue
|
||||
d[st.name] = 1
|
||||
case _symtable.TYPE_TYPE_PARAMETERS:
|
||||
# Get the function-def block in the annotation
|
||||
|
|
@ -245,7 +250,14 @@ def is_local_symbol(ident):
|
|||
scope_name = st.name
|
||||
for c in st.children:
|
||||
if c.name == scope_name and c.type == _symtable.TYPE_FUNCTION:
|
||||
d[st.name] = 1
|
||||
# A generic generator of type TYPE_FUNCTION
|
||||
# cannot be a direct child of 'st' (but it
|
||||
# can be a descendant), e.g.:
|
||||
#
|
||||
# class A:
|
||||
# type genexpr[genexpr] = (x for x in [])
|
||||
assert scope_name != 'genexpr' or '.0' not in c.varnames
|
||||
d[scope_name] = 1
|
||||
break
|
||||
self.__methods = tuple(d)
|
||||
return self.__methods
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue