Kaydet (Commit) bd3e3620 authored tarafından Benjamin Peterson's avatar Benjamin Peterson

make assigning to a bytes literal a syntax error (closes #11506)

üst 37805420
...@@ -67,6 +67,10 @@ SyntaxError: can't assign to literal ...@@ -67,6 +67,10 @@ SyntaxError: can't assign to literal
Traceback (most recent call last): Traceback (most recent call last):
SyntaxError: can't assign to literal SyntaxError: can't assign to literal
>>> b"" = 1
Traceback (most recent call last):
SyntaxError: can't assign to literal
>>> `1` = 1 >>> `1` = 1
Traceback (most recent call last): Traceback (most recent call last):
SyntaxError: invalid syntax SyntaxError: invalid syntax
......
...@@ -45,6 +45,9 @@ Core and Builtins ...@@ -45,6 +45,9 @@ Core and Builtins
- Issue #5587: add a repr to dict_proxy objects. Patch by David Stanek and - Issue #5587: add a repr to dict_proxy objects. Patch by David Stanek and
Daniel Urban. Daniel Urban.
- Issue #11506: Trying to assign to a bytes literal should result in a
SyntaxError.
Library Library
------- -------
......
...@@ -469,6 +469,7 @@ set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n) ...@@ -469,6 +469,7 @@ set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n)
case Set_kind: case Set_kind:
case Num_kind: case Num_kind:
case Str_kind: case Str_kind:
case Bytes_kind:
expr_name = "literal"; expr_name = "literal";
break; break;
case Ellipsis_kind: case Ellipsis_kind:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment