-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-121914: Change the names of the symbol tables for lambda and genexpr #135288
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
base: main
Are you sure you want to change the base?
gh-121914: Change the names of the symbol tables for lambda and genexpr #135288
Conversation
… genexpr Change the names of the symbol tables for lambda expressions and generator expressions to "<lambda>" and "<genexpr>" respectively to avoid conflicts with user-defined names.
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. This hack was ugly.
e->v.GeneratorExp.generators, | ||
e->v.GeneratorExp.elt, NULL); | ||
} | ||
|
||
static int | ||
symtable_visit_listcomp(struct symtable *st, expr_ty e) | ||
{ | ||
return symtable_handle_comprehension(st, e, &_Py_ID(listcomp), | ||
return symtable_handle_comprehension(st, e, &_Py_STR(anon_listcomp), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be tests for this one too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot write them.
Change the names of the symbol tables for lambda expressions and generator expressions to "
<lambda>
" and "<genexpr>
" respectively to avoid conflicts with user-defined names.