]> granicus.if.org Git - python/commitdiff
Fis SF bug #442647: not all forms of legal future statements were
authorGuido van Rossum <guido@python.org>
Thu, 19 Jul 2001 15:27:45 +0000 (15:27 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 19 Jul 2001 15:27:45 +0000 (15:27 +0000)
parsed correctly.  Now they are.

Parser/parser.c

index 753c43ac9c9eb03234ac722c21361dbc11cec10c..a9125e29a99d7a0de780c372866a7bf96cd034e0 100644 (file)
@@ -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