Kaydet (Commit) 12844e6d authored tarafından Amaury Forgeot d'Arc's avatar Amaury Forgeot d'Arc

Add tests for r84209 (crashes in the Ast builder)

Also remove one tab, and move a check closer to the possible failure.
üst 8101021e
...@@ -484,6 +484,34 @@ SyntaxError: can't delete () ...@@ -484,6 +484,34 @@ SyntaxError: can't delete ()
Traceback (most recent call last): Traceback (most recent call last):
SyntaxError: can't assign to literal SyntaxError: can't assign to literal
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
......
...@@ -892,14 +892,14 @@ ast_for_arguments(struct compiling *c, const node *n) ...@@ -892,14 +892,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;
if (forbidden_name(kwarg, CHILD(ch, 0), 0)) if (forbidden_name(kwarg, CHILD(ch, 0), 0))
return NULL; return NULL;
i += 3; i += 3;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment