[Python-checkins] r73420 - in python/trunk: Lib/test/test_syntax.py Python/ast.c
benjamin.peterson
python-checkins at python.org
Sat Jun 13 19:08:54 CEST 2009
Author: benjamin.peterson
Date: Sat Jun 13 19:08:53 2009
New Revision: 73420
Log:
give a better error message when deleting ()
Modified:
python/trunk/Lib/test/test_syntax.py
python/trunk/Python/ast.c
Modified: python/trunk/Lib/test/test_syntax.py
==============================================================================
--- python/trunk/Lib/test/test_syntax.py (original)
+++ python/trunk/Lib/test/test_syntax.py Sat Jun 13 19:08:53 2009
@@ -462,6 +462,12 @@
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
Modified: python/trunk/Python/ast.c
==============================================================================
--- python/trunk/Python/ast.c (original)
+++ python/trunk/Python/ast.c Sat Jun 13 19:08:53 2009
@@ -402,10 +402,13 @@
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";
More information about the Python-checkins
mailing list