summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na@python.org>2021-08-26 09:52:21 (GMT)
committerGitHub <noreply@github.com>2021-08-26 09:52:21 (GMT)
commit32c1caa87f68a650f2d009a589a1db30484499cb (patch)
treeca601bc57044aee865699b6a6c2879df46d1cac6 /Python
parent6ea6cf22e9d084c27a4fffbbd298098a6ad5b776 (diff)
downloadcpython-32c1caa87f68a650f2d009a589a1db30484499cb.zip
cpython-32c1caa87f68a650f2d009a589a1db30484499cb.tar.gz
cpython-32c1caa87f68a650f2d009a589a1db30484499cb.tar.bz2
bpo-45000: Raise SyntaxError when try to delete __debug__ (GH-27947) (GH-27957)
(cherry picked from commit 551da597a0996b0fb3af425f48aa5bc63ea6b963)
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/compile.c b/Python/compile.c
index a237899..d55b0be 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;
}