[Python-checkins] r84215 - in python/branches/release31-maint: Lib/test/test_syntax.py Python/ast.c
amaury.forgeotdarc
python-checkins at python.org
Thu Aug 19 23:35:59 CEST 2010
Author: amaury.forgeotdarc
Date: Thu Aug 19 23:35:59 2010
New Revision: 84215
Log:
Merged revisions 84214 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r84214 | amaury.forgeotdarc | 2010-08-19 23:32:38 +0200 (jeu., 19 août 2010) | 3 lines
Add tests for r84209 (crashes in the Ast builder)
Also remove one tab, and move a check closer to the possible failure.
........
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Lib/test/test_syntax.py
python/branches/release31-maint/Python/ast.c
Modified: python/branches/release31-maint/Lib/test/test_syntax.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_syntax.py (original)
+++ python/branches/release31-maint/Lib/test/test_syntax.py Thu Aug 19 23:35:59 2010
@@ -476,6 +476,34 @@
...
SyntaxError: keyword argument repeated
+Corner-cases that used to fail to raise the correct error:
+
+ >>> def f(*, x=lambda __debug__:0): pass
+ Traceback (most recent call last):
+ SyntaxError: assignment to keyword
+
+ >>> def f(*args:(lambda __debug__:0)): pass
+ Traceback (most recent call last):
+ SyntaxError: assignment to keyword
+
+ >>> def f(**kwargs:(lambda __debug__:0)): pass
+ Traceback (most recent call last):
+ SyntaxError: assignment to keyword
+
+ >>> with (lambda *:0): pass
+ Traceback (most recent call last):
+ SyntaxError: named arguments must follow bare *
+
+Corner-cases that used to crash:
+
+ >>> def f(**__debug__): pass
+ Traceback (most recent call last):
+ SyntaxError: assignment to keyword
+
+ >>> def f(*xx, __debug__): pass
+ Traceback (most recent call last):
+ SyntaxError: assignment to keyword
+
"""
import re
Modified: python/branches/release31-maint/Python/ast.c
==============================================================================
--- python/branches/release31-maint/Python/ast.c (original)
+++ python/branches/release31-maint/Python/ast.c Thu Aug 19 23:35:59 2010
@@ -674,7 +674,7 @@
if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {
expression = ast_for_expr(c, CHILD(n, i + 2));
if (!expression)
- goto error;
+ goto error;
asdl_seq_SET(kwdefaults, j, expression);
i += 2; /* '=' and test */
}
@@ -873,14 +873,14 @@
ch = CHILD(n, i+1); /* tfpdef */
assert(TYPE(ch) == tfpdef || TYPE(ch) == vfpdef);
kwarg = NEW_IDENTIFIER(CHILD(ch, 0));
+ if (!kwarg)
+ return NULL;
if (NCH(ch) > 1) {
/* there is an annotation on the kwarg */
kwargannotation = ast_for_expr(c, CHILD(ch, 2));
if (!kwargannotation)
return NULL;
}
- if (!kwarg)
- return NULL;
i += 3;
break;
default:
More information about the Python-checkins
mailing list