Fix #1474677, non-keyword argument following keyword.
This commit is contained in:
parent
02104df4c8
commit
5ef922447c
|
@ -309,6 +309,9 @@ class SyntaxTestCase(unittest.TestCase):
|
||||||
"unindent does not match .* level",
|
"unindent does not match .* level",
|
||||||
subclass=IndentationError)
|
subclass=IndentationError)
|
||||||
|
|
||||||
|
def test_kwargs_last(self):
|
||||||
|
self._check_error("int(base=10, '2')", "non-keyword arg")
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
test_support.run_unittest(SyntaxTestCase)
|
test_support.run_unittest(SyntaxTestCase)
|
||||||
from test import test_syntax
|
from test import test_syntax
|
||||||
|
|
|
@ -1750,6 +1750,11 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func)
|
||||||
if (TYPE(ch) == argument) {
|
if (TYPE(ch) == argument) {
|
||||||
expr_ty e;
|
expr_ty e;
|
||||||
if (NCH(ch) == 1) {
|
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));
|
e = ast_for_expr(c, CHILD(ch, 0));
|
||||||
if (!e)
|
if (!e)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue