From: Benjamin Peterson Date: Thu, 24 Jun 2010 00:12:40 +0000 (+0000) Subject: prevent assignment to set literals X-Git-Tag: v2.7~71 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=947ce58a9018d23cb1e5e8de550f2ba0e542248e;p=thirdparty%2FPython%2Fcpython.git prevent assignment to set literals --- diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 899db61d17a8..4992a32a8e00 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -468,6 +468,12 @@ Traceback (most recent call last): File "", line 1 SyntaxError: can't delete () +>>> {1, 2, 3} = 42 +Traceback (most recent call last): + ... + File "", line 1 +SyntaxError: can't assign to literal + """ import re diff --git a/Misc/NEWS b/Misc/NEWS index cb602391382a..70ce171577e7 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 41c0d28e1b5c..f8c83d934c6e 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";