mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Fix SF buf #480096: Assign to __debug__ still allowed
Easy enough to catch assignment in the compiler. The perverse user can still change the value of __debug__, but that may be the least he can do.
This commit is contained in:
parent
734c7fb131
commit
778e265462
2 changed files with 20 additions and 3 deletions
|
@ -5459,8 +5459,13 @@ symtable_assign(struct symtable *st, node *n, int def_flag)
|
|||
n = CHILD(n, 1);
|
||||
goto loop;
|
||||
} else if (TYPE(tmp) == NAME) {
|
||||
if (strcmp(STR(tmp), "__debug__") == 0)
|
||||
symtable_warn(st, ASSIGN_DEBUG);
|
||||
if (strcmp(STR(tmp), "__debug__") == 0) {
|
||||
PyErr_SetString(PyExc_SyntaxError,
|
||||
ASSIGN_DEBUG);
|
||||
PyErr_SyntaxLocation(st->st_filename,
|
||||
st->st_cur->ste_opt_lineno);
|
||||
st->st_errors++;
|
||||
}
|
||||
symtable_add_def(st, STR(tmp), DEF_LOCAL | def_flag);
|
||||
}
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue