[Python-checkins] r61240 - in python/trunk: Lib/test/test_grammar.py Misc/NEWS Python/ast.c
amaury.forgeotdarc
python-checkins at python.org
Wed Mar 5 02:50:34 CET 2008
Author: amaury.forgeotdarc
Date: Wed Mar 5 02:50:33 2008
New Revision: 61240
Modified:
python/trunk/Lib/test/test_grammar.py
python/trunk/Misc/NEWS
python/trunk/Python/ast.c
Log:
Issue#2238: some syntax errors from *args or **kwargs expressions
would give bogus error messages, because of untested exceptions::
>>> f(**g(1=2))
XXX undetected error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable
instead of the expected SyntaxError: keyword can't be an expression
Will backport.
Modified: python/trunk/Lib/test/test_grammar.py
==============================================================================
--- python/trunk/Lib/test/test_grammar.py (original)
+++ python/trunk/Lib/test/test_grammar.py Wed Mar 5 02:50:33 2008
@@ -282,6 +282,10 @@
def d32v((x,)): pass
d32v((1,))
+ # Check ast errors in *args and *kwargs
+ check_syntax_error(self, "f(*g(1=2))")
+ check_syntax_error(self, "f(**g(1=2))")
+
def testLambdef(self):
### lambdef: 'lambda' [varargslist] ':' test
l1 = lambda : 0
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Wed Mar 5 02:50:33 2008
@@ -9,6 +9,12 @@
*Release date: XX-XXX-2008*
+Core and builtins
+-----------------
+
+- Issue #2238: Some syntax errors in *args and **kwargs expressions could give
+ bogus error messages.
+
What's New in Python 2.6 alpha 1?
=================================
Modified: python/trunk/Python/ast.c
==============================================================================
--- python/trunk/Python/ast.c (original)
+++ python/trunk/Python/ast.c Wed Mar 5 02:50:33 2008
@@ -1934,10 +1934,14 @@
}
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++;
}
}
More information about the Python-checkins
mailing list