[Python-checkins] r82189 - in python/trunk: Lib/test/test_syntax.py Misc/NEWS Python/ast.c

benjamin.peterson python-checkins at python.org
Thu Jun 24 02:12:40 CEST 2010


Author: benjamin.peterson
Date: Thu Jun 24 02:12:40 2010
New Revision: 82189

Log:
prevent assignment to set literals

Modified:
   python/trunk/Lib/test/test_syntax.py
   python/trunk/Misc/NEWS
   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	Thu Jun 24 02:12:40 2010
@@ -468,6 +468,12 @@
   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

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Thu Jun 24 02:12:40 2010
@@ -12,6 +12,8 @@
 Core and Builtins
 -----------------
 
+- Prevent assignment to set literals.
+
 Library
 -------
 

Modified: python/trunk/Python/ast.c
==============================================================================
--- python/trunk/Python/ast.c	(original)
+++ python/trunk/Python/ast.c	Thu Jun 24 02:12:40 2010
@@ -440,6 +440,7 @@
             expr_name = "dict comprehension";
             break;
         case Dict_kind:
+        case Set_kind:
         case Num_kind:
         case Str_kind:
             expr_name = "literal";


More information about the Python-checkins mailing list