-
-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Changed the names of the symbol tables for lambda expressions and generator | ||
expressions to "<lambda>" and "<genexpr>" respectively to avoid conflicts | ||
with user-defined names. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2413,7 +2413,7 @@ symtable_visit_expr(struct symtable *st, expr_ty e) | |
VISIT_SEQ(st, expr, e->v.Lambda.args->defaults); | ||
if (e->v.Lambda.args->kw_defaults) | ||
VISIT_SEQ_WITH_NULL(st, expr, e->v.Lambda.args->kw_defaults); | ||
if (!symtable_enter_block(st, &_Py_ID(lambda), | ||
if (!symtable_enter_block(st, &_Py_STR(anon_lambda), | ||
FunctionBlock, (void *)e, LOCATION(e))) { | ||
return 0; | ||
} | ||
|
@@ -3055,31 +3055,31 @@ symtable_handle_comprehension(struct symtable *st, expr_ty e, | |
static int | ||
symtable_visit_genexp(struct symtable *st, expr_ty e) | ||
{ | ||
return symtable_handle_comprehension(st, e, &_Py_ID(genexpr), | ||
return symtable_handle_comprehension(st, e, &_Py_STR(anon_genexpr), | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I cannot write them. |
||
e->v.ListComp.generators, | ||
e->v.ListComp.elt, NULL); | ||
} | ||
|
||
static int | ||
symtable_visit_setcomp(struct symtable *st, expr_ty e) | ||
{ | ||
return symtable_handle_comprehension(st, e, &_Py_ID(setcomp), | ||
return symtable_handle_comprehension(st, e, &_Py_STR(anon_setcomp), | ||
e->v.SetComp.generators, | ||
e->v.SetComp.elt, NULL); | ||
} | ||
|
||
static int | ||
symtable_visit_dictcomp(struct symtable *st, expr_ty e) | ||
{ | ||
return symtable_handle_comprehension(st, e, &_Py_ID(dictcomp), | ||
return symtable_handle_comprehension(st, e, &_Py_STR(anon_dictcomp), | ||
e->v.DictComp.generators, | ||
e->v.DictComp.key, | ||
e->v.DictComp.value); | ||
|
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.