bpo-36052: Raise a SyntaxError when assigning a value to __debug__ with := (GH-11958)

Trying to assign a value to __debug__ using the assignment operator is supposed to fail, but
a missing check for forbidden names when setting the context in the ast was preventing this behaviour.
This commit is contained in:
Stéphane Wirtel 2019-02-21 11:11:53 +01:00 committed by Pablo Galindo
parent ea6207d593
commit 3ad9167305
3 changed files with 7 additions and 1 deletions

View file

@ -51,6 +51,10 @@ SyntaxError: cannot assign to __debug__
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__
>>> (__debug__ := 1)
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__
>>> f() = 1
Traceback (most recent call last):
SyntaxError: cannot assign to function call