summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-06-24 00:12:40 +0000
committerBenjamin Peterson <benjamin@python.org>2010-06-24 00:12:40 +0000
commit947ce58a9018d23cb1e5e8de550f2ba0e542248e (patch)
tree3832acdc851f879c0d8a3705d3500cb4205e5bf6
parent5c995c10d45a7915b5ea0bb02d114b2579eef04e (diff)
downloadcpython-git-947ce58a9018d23cb1e5e8de550f2ba0e542248e.tar.gz
prevent assignment to set literals
-rw-r--r--Lib/test/test_syntax.py6
-rw-r--r--Misc/NEWS2
-rw-r--r--Python/ast.c1
3 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 899db61d17..4992a32a8e 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -468,6 +468,12 @@ Traceback (most recent call last):
File "<doctest test.test_syntax[50]>", line 1
SyntaxError: can't delete ()
+>>> {1, 2, 3} = 42
+Traceback (most recent call last):
+ ...
+ File "<doctest test.test_syntax[50]>", line 1
+SyntaxError: can't assign to literal
+
"""
import re
diff --git a/Misc/NEWS b/Misc/NEWS
index cb60239138..70ce171577 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.7?
Core and Builtins
-----------------
+- Prevent assignment to set literals.
+
Library
-------
diff --git a/Python/ast.c b/Python/ast.c
index 41c0d28e1b..f8c83d934c 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -440,6 +440,7 @@ set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n)
expr_name = "dict comprehension";
break;
case Dict_kind:
+ case Set_kind:
case Num_kind:
case Str_kind:
expr_name = "literal";