]> granicus.if.org Git - python/commitdiff
Teach the parsermodule about floor division. Fixes
authorMichael W. Hudson <mwh@python.net>
Wed, 29 Jan 2003 14:20:23 +0000 (14:20 +0000)
committerMichael W. Hudson <mwh@python.net>
Wed, 29 Jan 2003 14:20:23 +0000 (14:20 +0000)
[ 676521 ] parser module validation failure

bugfix candidate.

Lib/test/test_parser.py
Modules/parsermodule.c

index c0b1bfcedec11b241dad1e51ddeefa5ccece30ac..81708b5309539915a5fb7d7c2c26bd3f377a0c36 100644 (file)
@@ -51,6 +51,10 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
         self.check_expr("foo(a, b, c, *args, **kw)")
         self.check_expr("foo(a, b, c, **kw)")
         self.check_expr("foo + bar")
+        self.check_expr("foo - bar")
+        self.check_expr("foo * bar")
+        self.check_expr("foo / bar")
+        self.check_expr("foo // bar")
         self.check_expr("lambda: 0")
         self.check_expr("lambda x: 0")
         self.check_expr("lambda *y: 0")
@@ -85,6 +89,7 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
         self.check_suite("a -= b")
         self.check_suite("a *= b")
         self.check_suite("a /= b")
+        self.check_suite("a //= b")
         self.check_suite("a %= b")
         self.check_suite("a &= b")
         self.check_suite("a |= b")
index e0c74313c8208d7be3a44fd68f8ec0b9ec908bc8..fd030678e6f5fea3ae1722bcf8453800e64ac0b5 100644 (file)
@@ -1440,6 +1440,7 @@ validate_expr_stmt(node *tree)
                    || strcmp(s, "-=") == 0
                    || strcmp(s, "*=") == 0
                    || strcmp(s, "/=") == 0
+                   || strcmp(s, "//=") == 0
                    || strcmp(s, "%=") == 0
                    || strcmp(s, "&=") == 0
                    || strcmp(s, "|=") == 0
@@ -2095,6 +2096,7 @@ validate_term(node *tree)
     for ( ; res && (pos < nch); pos += 2)
         res = (((TYPE(CHILD(tree, pos)) == STAR)
                || (TYPE(CHILD(tree, pos)) == SLASH)
+               || (TYPE(CHILD(tree, pos)) == DOUBLESLASH)
                || (TYPE(CHILD(tree, pos)) == PERCENT))
                && validate_factor(CHILD(tree, pos + 1)));