bpo-45000: Raise SyntaxError when try to delete __debug__ (GH-27947)

Automerge-Triggered-By: GH:pablogsal
This commit is contained in:
Dong-hee Na 2021-08-25 17:54:20 +00:00 committed by GitHub
parent 24da544014
commit 551da597a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 0 deletions

View file

@ -2343,6 +2343,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;
}