Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3c03323

Browse files
committed
Fis SF bug #442647: not all forms of legal future statements were
parsed correctly. Now they are.
1 parent e31c2ee commit 3c03323

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

Parser/parser.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,21 @@ future_hack(parser_state *ps)
175175
{
176176
node *n = ps->p_stack.s_top->s_parent;
177177
node *ch;
178+
int i;
178179

179180
if (strcmp(STR(CHILD(n, 0)), "from") != 0)
180181
return;
181182
ch = CHILD(n, 1);
182183
if (strcmp(STR(CHILD(ch, 0)), "__future__") != 0)
183184
return;
184-
ch = CHILD(n, 3);
185-
if (NCH(ch) == 1 && strcmp(STR(CHILD(ch, 0)), "generators") == 0)
186-
ps->p_generators = 1;
185+
for (i = 3; i < NCH(n); i += 2) {
186+
ch = CHILD(n, i);
187+
if (NCH(ch) >= 1 && TYPE(CHILD(ch, 0)) == NAME &&
188+
strcmp(STR(CHILD(ch, 0)), "generators") == 0) {
189+
ps->p_generators = 1;
190+
break;
191+
}
192+
}
187193
}
188194

189195
int

0 commit comments

Comments
 (0)