summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-05-19 06:43:50 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-05-19 06:43:50 (GMT)
commit5ef922447c3dd0f9b306b4fde59481b4d4eaeaa3 (patch)
tree639fe9618a71538e4dfcabc48f8145745e90f9dc
parent02104df4c8fbb1db098646d33453706d2535b51a (diff)
downloadcpython-5ef922447c3dd0f9b306b4fde59481b4d4eaeaa3.zip
cpython-5ef922447c3dd0f9b306b4fde59481b4d4eaeaa3.tar.gz
cpython-5ef922447c3dd0f9b306b4fde59481b4d4eaeaa3.tar.bz2
Fix #1474677, non-keyword argument following keyword.
-rw-r--r--Lib/test/test_syntax.py3
-rw-r--r--Python/ast.c5
2 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 9d3ff02..dc7a16d 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -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
diff --git a/Python/ast.c b/Python/ast.c
index fafa253..9664590 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -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;