]> granicus.if.org Git - python/commitdiff
Back-port of rev 61240 for issue #2238, fixing: Some syntax errors in *args
authorSean Reifscheider <jafo@tummy.com>
Thu, 20 Mar 2008 17:39:31 +0000 (17:39 +0000)
committerSean Reifscheider <jafo@tummy.com>
Thu, 20 Mar 2008 17:39:31 +0000 (17:39 +0000)
and **kwargs expressions could give bogus error messages.

Lib/test/test_grammar.py
Misc/NEWS
Python/ast.c

index 89e9e67895028321c99af4114757d6d23294c38d..6a9e5124c690050a74dc29243c30b060a1c23fa7 100644 (file)
@@ -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
index 5fdfce85a74f28fa7e6b5c815c8aa80f36eed116..f8f8735e03a30c50c0a3fc967c8c86bd8abd1ad7 100644 (file)
--- 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
 -------
 
index 3381260d0740d883deb9dad58381c54ce0181827..c7fd8bcc9604cfecd8ead0da6bde2fbea6bed935 100644 (file)
@@ -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++;
        }
     }