mirror of https://github.com/python/cpython
give a better error message when deleting ()
This commit is contained in:
parent
5d1ff94b9e
commit
52c4bec76b
|
@ -462,6 +462,12 @@ Traceback (most recent call last):
|
|||
File "<doctest test.test_syntax[49]>", line 1
|
||||
SyntaxError: keyword argument repeated
|
||||
|
||||
>>> del ()
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
File "<doctest test.test_syntax[50]>", line 1
|
||||
SyntaxError: can't delete ()
|
||||
|
||||
"""
|
||||
|
||||
import re
|
||||
|
|
|
@ -402,10 +402,13 @@ set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n)
|
|||
s = e->v.List.elts;
|
||||
break;
|
||||
case Tuple_kind:
|
||||
if (asdl_seq_LEN(e->v.Tuple.elts) == 0)
|
||||
return ast_error(n, "can't assign to ()");
|
||||
if (asdl_seq_LEN(e->v.Tuple.elts)) {
|
||||
e->v.Tuple.ctx = ctx;
|
||||
s = e->v.Tuple.elts;
|
||||
}
|
||||
else {
|
||||
expr_name = "()";
|
||||
}
|
||||
break;
|
||||
case Lambda_kind:
|
||||
expr_name = "lambda";
|
||||
|
|
Loading…
Reference in New Issue