mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
Bring handling of genexpr in line with other anonymous scope names
This commit is contained in:
parent
a3fd07d524
commit
99b2533539
1 changed files with 3 additions and 4 deletions
|
@ -170,7 +170,7 @@ static int symtable_visit_params_nested(struct symtable *st, asdl_seq *args);
|
||||||
static int symtable_implicit_arg(struct symtable *st, int pos);
|
static int symtable_implicit_arg(struct symtable *st, int pos);
|
||||||
|
|
||||||
|
|
||||||
static identifier top = NULL, lambda = NULL;
|
static identifier top = NULL, lambda = NULL, genexpr = NULL;
|
||||||
|
|
||||||
#define GET_IDENTIFIER(VAR) \
|
#define GET_IDENTIFIER(VAR) \
|
||||||
((VAR) ? (VAR) : ((VAR) = PyString_InternFromString(# VAR)))
|
((VAR) ? (VAR) : ((VAR) = PyString_InternFromString(# VAR)))
|
||||||
|
@ -1329,14 +1329,13 @@ symtable_visit_slice(struct symtable *st, slice_ty s)
|
||||||
static int
|
static int
|
||||||
symtable_visit_genexp(struct symtable *st, expr_ty e)
|
symtable_visit_genexp(struct symtable *st, expr_ty e)
|
||||||
{
|
{
|
||||||
identifier tmp;
|
|
||||||
comprehension_ty outermost = ((comprehension_ty)
|
comprehension_ty outermost = ((comprehension_ty)
|
||||||
(asdl_seq_GET(e->v.GeneratorExp.generators, 0)));
|
(asdl_seq_GET(e->v.GeneratorExp.generators, 0)));
|
||||||
/* Outermost iterator is evaluated in current scope */
|
/* Outermost iterator is evaluated in current scope */
|
||||||
VISIT(st, expr, outermost->iter);
|
VISIT(st, expr, outermost->iter);
|
||||||
/* Create generator scope for the rest */
|
/* Create generator scope for the rest */
|
||||||
tmp = PyString_FromString("<genexpr>");
|
if (!symtable_enter_block(st, GET_IDENTIFIER(genexpr),
|
||||||
if (!symtable_enter_block(st, tmp, FunctionBlock, (void *)e, 0)) {
|
FunctionBlock, (void *)e, 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
st->st_cur->ste_generator = 1;
|
st->st_cur->ste_generator = 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue