From: Benjamin Peterson Date: Tue, 12 Apr 2011 23:33:28 +0000 (-0500) Subject: make assigning to a bytes literal a syntax error (closes #11506) X-Git-Tag: v3.2.1b1~142^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd3e362089c9fab1028a1bf58b4e762851a32244;p=python make assigning to a bytes literal a syntax error (closes #11506) --- diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 202770afa6..7faab911a7 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -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 diff --git a/Misc/NEWS b/Misc/NEWS index a90aee9896..b80bd5268a 100644 --- 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 ------- diff --git a/Python/ast.c b/Python/ast.c index 590bc90dab..d97e9518ce 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -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: