From 32c1caa87f68a650f2d009a589a1db30484499cb Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Thu, 26 Aug 2021 09:52:21 +0000 Subject: bpo-45000: Raise SyntaxError when try to delete __debug__ (GH-27947) (GH-27957) (cherry picked from commit 551da597a0996b0fb3af425f48aa5bc63ea6b963) --- Python/compile.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Python') diff --git a/Python/compile.c b/Python/compile.c index a2378992fd..d55b0beaec 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2264,6 +2264,10 @@ forbidden_name(struct compiler *c, identifier name, expr_context_ty ctx) compiler_error(c, "cannot assign to __debug__"); return 1; } + if (ctx == Del && _PyUnicode_EqualToASCIIString(name, "__debug__")) { + compiler_error(c, "cannot delete __debug__"); + return 1; + } return 0; } -- cgit v1.2.1