]> granicus.if.org Git - python/commitdiff
prevent assignment to set literals
authorBenjamin Peterson <benjamin@python.org>
Thu, 24 Jun 2010 00:12:40 +0000 (00:12 +0000)
committerBenjamin Peterson <benjamin@python.org>
Thu, 24 Jun 2010 00:12:40 +0000 (00:12 +0000)
Lib/test/test_syntax.py
Misc/NEWS
Python/ast.c

index 899db61d17a8722e0db0d60f1a170ac9c07b0d4c..4992a32a8e002e3b80c463696f76aace782f9121 100644 (file)
@@ -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
index cb602391382a84b5445b2b6571a3d26e04609752..70ce171577e7cba04a8d64c566b5a9f2930364e5 100644 (file)
--- 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
 -------
 
index 41c0d28e1b5c0ae9b419765d5573f89d689f4225..f8c83d934c6ee409fe62e692cdc0b63b7d7759d0 100644 (file)
@@ -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";