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.
........
This commit is contained in:
Amaury Forgeot d'Arc 2010-08-19 21:35:59 +00:00
parent fc34ac5fdd
commit a1e5c69d5b
2 changed files with 31 additions and 3 deletions

View File

@ -476,6 +476,34 @@ Traceback (most recent call last):
... ...
SyntaxError: keyword argument repeated 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 import re

View File

@ -873,14 +873,14 @@ ast_for_arguments(struct compiling *c, const node *n)
ch = CHILD(n, i+1); /* tfpdef */ ch = CHILD(n, i+1); /* tfpdef */
assert(TYPE(ch) == tfpdef || TYPE(ch) == vfpdef); assert(TYPE(ch) == tfpdef || TYPE(ch) == vfpdef);
kwarg = NEW_IDENTIFIER(CHILD(ch, 0)); kwarg = NEW_IDENTIFIER(CHILD(ch, 0));
if (!kwarg)
return NULL;
if (NCH(ch) > 1) { if (NCH(ch) > 1) {
/* there is an annotation on the kwarg */ /* there is an annotation on the kwarg */
kwargannotation = ast_for_expr(c, CHILD(ch, 2)); kwargannotation = ast_for_expr(c, CHILD(ch, 2));
if (!kwargannotation) if (!kwargannotation)
return NULL; return NULL;
} }
if (!kwarg)
return NULL;
i += 3; i += 3;
break; break;
default: default: