diff options
author | Dong-hee Na <donghee.na@python.org> | 2021-08-26 09:52:21 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-26 10:52:21 +0100 |
commit | 32c1caa87f68a650f2d009a589a1db30484499cb (patch) | |
tree | ca601bc57044aee865699b6a6c2879df46d1cac6 /Python | |
parent | 6ea6cf22e9d084c27a4fffbbd298098a6ad5b776 (diff) | |
download | cpython-git-32c1caa87f68a650f2d009a589a1db30484499cb.tar.gz |
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.c | 4 |
1 files changed, 4 insertions, 0 deletions
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; } |