]> granicus.if.org Git - python/commitdiff
make assigning to a bytes literal a syntax error (closes #11506)
authorBenjamin Peterson <benjamin@python.org>
Tue, 12 Apr 2011 23:33:28 +0000 (18:33 -0500)
committerBenjamin Peterson <benjamin@python.org>
Tue, 12 Apr 2011 23:33:28 +0000 (18:33 -0500)
Lib/test/test_syntax.py
Misc/NEWS
Python/ast.c

index 202770afa6d8b68281e44cfbac7cbb4e3573cd03..7faab911a7afc679edb904ee7c4f73684c5b78d4 100644 (file)
@@ -67,6 +67,10 @@ SyntaxError: can't assign to literal
 Traceback (most recent call last):
 SyntaxError: can't assign to literal
 
+>>> b"" = 1
+Traceback (most recent call last):
+SyntaxError: can't assign to literal
+
 >>> `1` = 1
 Traceback (most recent call last):
 SyntaxError: invalid syntax
index a90aee9896352683b62b20d912c061832eab8195..b80bd5268add35ae8f35cac1f94ccaf48d5bfd7d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -45,6 +45,9 @@ Core and Builtins
 - Issue #5587: add a repr to dict_proxy objects.  Patch by David Stanek and
   Daniel Urban.
 
+- Issue #11506: Trying to assign to a bytes literal should result in a
+  SyntaxError.
+
 Library
 -------
 
index 590bc90dabf35f7021d4a6ba1e46dd42e284bf54..d97e9518ce539b9e634dc9b37ec5c20c21e1e9bf 100644 (file)
@@ -469,6 +469,7 @@ set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n)
         case Set_kind:
         case Num_kind:
         case Str_kind:
+        case Bytes_kind:
             expr_name = "literal";
             break;
         case Ellipsis_kind: