Mercurial > cpython-lru_cache-weakref
diff Python/compile.c @ 20939:13df8b6c2b80 legacy-trunk
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.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Fri, 09 Nov 2001 19:50:08 +0000 |
| parents | 40a88989d6cb |
| children | c555f1e7c4be |
line wrap: on
line diff
--- a/Python/compile.c Fri Nov 09 19:34:43 2001 +0000 +++ b/Python/compile.c Fri Nov 09 19:50:08 2001 +0000 @@ -5459,8 +5459,13 @@ 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;
