diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-06-13 17:08:53 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-06-13 17:08:53 (GMT) |
commit | 52c4bec76bdcb962e883eac1e55f98df488b558c (patch) | |
tree | 2e9aa28b526bc958a3c65099975f79cc59221ba7 | |
parent | 5d1ff94b9ef3052b4938c55b196c3594369e252a (diff) | |
download | cpython-52c4bec76bdcb962e883eac1e55f98df488b558c.zip cpython-52c4bec76bdcb962e883eac1e55f98df488b558c.tar.gz cpython-52c4bec76bdcb962e883eac1e55f98df488b558c.tar.bz2 |
give a better error message when deleting ()
-rw-r--r-- | Lib/test/test_syntax.py | 6 | ||||
-rw-r--r-- | Python/ast.c | 11 |
2 files changed, 13 insertions, 4 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index c1027b1..26d78ad 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -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 diff --git a/Python/ast.c b/Python/ast.c index a415495..4a85164 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -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 ()"); - e->v.Tuple.ctx = ctx; - s = e->v.Tuple.elts; + 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"; |