From 3ad91673057d410bf9f8c53df6bb8aa18c4b68ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Thu, 21 Feb 2019 11:11:53 +0100 Subject: 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. --- Lib/test/test_syntax.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Lib/test/test_syntax.py') diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index ce1de4b319..a0f487d4ed 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -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 -- cgit v1.2.1