summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-07-19 15:27:45 (GMT)
committerGuido van Rossum <guido@python.org>2001-07-19 15:27:45 (GMT)
commit3c033230ec2f81c9d61ba1b1f19a99f8bf4f4bd3 (patch)
treebab14648c41c483ceec80cb2c1cb4dd0d01ae734 /Parser
parente31c2eeb410464084e6dc88beae03da766a68ee4 (diff)
downloadcpython-3c033230ec2f81c9d61ba1b1f19a99f8bf4f4bd3.zip
cpython-3c033230ec2f81c9d61ba1b1f19a99f8bf4f4bd3.tar.gz
cpython-3c033230ec2f81c9d61ba1b1f19a99f8bf4f4bd3.tar.bz2
Fis SF bug #442647: not all forms of legal future statements were
parsed correctly. Now they are.
Diffstat (limited to 'Parser')
-rw-r--r--Parser/parser.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/Parser/parser.c b/Parser/parser.c
index 753c43a..a9125e2 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -175,15 +175,21 @@ future_hack(parser_state *ps)
{
node *n = ps->p_stack.s_top->s_parent;
node *ch;
+ int i;
if (strcmp(STR(CHILD(n, 0)), "from") != 0)
return;
ch = CHILD(n, 1);
if (strcmp(STR(CHILD(ch, 0)), "__future__") != 0)
return;
- ch = CHILD(n, 3);
- if (NCH(ch) == 1 && strcmp(STR(CHILD(ch, 0)), "generators") == 0)
- ps->p_generators = 1;
+ for (i = 3; i < NCH(n); i += 2) {
+ ch = CHILD(n, i);
+ if (NCH(ch) >= 1 && TYPE(CHILD(ch, 0)) == NAME &&
+ strcmp(STR(CHILD(ch, 0)), "generators") == 0) {
+ ps->p_generators = 1;
+ break;
+ }
+ }
}
int