diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index c1027b1f6ef..26d78adf978 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -462,6 +462,12 @@ Traceback (most recent call last): File "", line 1 SyntaxError: keyword argument repeated +>>> del () +Traceback (most recent call last): + ... + File "", line 1 +SyntaxError: can't delete () + """ import re diff --git a/Python/ast.c b/Python/ast.c index a415495a702..4a85164d8cd 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";