]> granicus.if.org Git - python/commitdiff
Fix #1474677, non-keyword argument following keyword.
authorNeal Norwitz <nnorwitz@gmail.com>
Fri, 19 May 2006 06:43:50 +0000 (06:43 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Fri, 19 May 2006 06:43:50 +0000 (06:43 +0000)
Lib/test/test_syntax.py
Python/ast.c

index 9d3ff02c55cc214758403cca1a7e0648c81e1e4d..dc7a16d1e26330867e79be93b48697f61fff6ad3 100644 (file)
@@ -309,6 +309,9 @@ class SyntaxTestCase(unittest.TestCase):
                           "unindent does not match .* level",
                           subclass=IndentationError)
 
+    def test_kwargs_last(self):
+        self._check_error("int(base=10, '2')", "non-keyword arg")
+
 def test_main():
     test_support.run_unittest(SyntaxTestCase)
     from test import test_syntax
index fafa25310b9dd54613b125b12011087dcfa6a960..96645900552dd644ba2a198ac810d8f9357a550b 100644 (file)
@@ -1750,6 +1750,11 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func)
        if (TYPE(ch) == argument) {
            expr_ty e;
            if (NCH(ch) == 1) {
+               if (nkeywords) {
+                   ast_error(CHILD(ch, 0),
+                             "non-keyword arg after keyword arg");
+                   return NULL;
+               }
                e = ast_for_expr(c, CHILD(ch, 0));
                 if (!e)
                     return NULL;