summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Reifscheider <jafo@tummy.com>2008-03-20 17:39:31 +0000
committerSean Reifscheider <jafo@tummy.com>2008-03-20 17:39:31 +0000
commit4af861cb4e3705d531e684f859f30df2a368bdc1 (patch)
treebff2a7e6680b4d76b8d982adbfc7c25e5bf51101
parenteff5a4e9014dfa8134d955ec69685e47cb6b03ed (diff)
downloadcpython-git-4af861cb4e3705d531e684f859f30df2a368bdc1.tar.gz
Back-port of rev 61240 for issue #2238, fixing: Some syntax errors in *args
and **kwargs expressions could give bogus error messages.
-rw-r--r--Lib/test/test_grammar.py4
-rw-r--r--Misc/NEWS3
-rw-r--r--Python/ast.c4
3 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 89e9e67895..6a9e5124c6 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -260,6 +260,10 @@ d31v(1)
def d32v((x,)): pass
d32v((1,))
+# Check ast errors in *args and *kwargs
+check_syntax("f(*g(1=2))")
+check_syntax("f(**g(1=2))")
+
### lambdef: 'lambda' [varargslist] ':' test
print 'lambdef'
l1 = lambda : 0
diff --git a/Misc/NEWS b/Misc/NEWS
index 5fdfce85a7..f8f8735e03 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -14,6 +14,9 @@ Core and builtins
- Issue #2321: use pymalloc for unicode object string data to reduce
memory usage in some circumstances.
+- Issue #2238: Some syntax errors in *args and **kwargs expressions could give
+ bogus error messages.
+
Library
-------
diff --git a/Python/ast.c b/Python/ast.c
index 3381260d07..c7fd8bcc96 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -1878,10 +1878,14 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func)
}
else if (TYPE(ch) == STAR) {
vararg = ast_for_expr(c, CHILD(n, i+1));
+ if (!vararg)
+ return NULL;
i++;
}
else if (TYPE(ch) == DOUBLESTAR) {
kwarg = ast_for_expr(c, CHILD(n, i+1));
+ if (!kwarg)
+ return NULL;
i++;
}
}