summaryrefslogtreecommitdiff
path: root/Python/compile.c
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-11-09 19:50:08 +0000
committerJeremy Hylton <jeremy@alum.mit.edu>2001-11-09 19:50:08 +0000
commit336e935d57f79a810c9d4b3de06caeae9d3d5ead (patch)
tree8d95cc681509bf8bcb38305e639088481b0f857b /Python/compile.c
parentd149f4357f9bcb57791121a1f44105a57f9bc9ac (diff)
downloadcpython-336e935d57f79a810c9d4b3de06caeae9d3d5ead.tar.gz
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.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index c8a56699bc..1a46064dd4 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -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;