diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-03-23 14:08:38 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-03-23 14:08:38 (GMT) |
commit | 897b82123d3b446778a1ef7537404cd8df1da9c9 (patch) | |
tree | 19ad4c70e5f300ba24333a4a6a0bf4f884b2d5e1 /Python | |
parent | e280c06d5910eca5bcded37611033bb11bc17110 (diff) | |
download | cpython-897b82123d3b446778a1ef7537404cd8df1da9c9.zip cpython-897b82123d3b446778a1ef7537404cd8df1da9c9.tar.gz cpython-897b82123d3b446778a1ef7537404cd8df1da9c9.tar.bz2 |
Make it illegal to assign to __debug__ as per Guido's request.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/compile.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c index 3e638ca..df514c7 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -66,6 +66,9 @@ int Py_OptimizeFlag = 0; #define LATE_FUTURE \ "from __future__ imports must occur at the beginning of the file" +#define ASSIGN_DEBUG \ +"can not assign to __debug__" + #define MANGLE_LEN 256 #define OFF(x) offsetof(PyCodeObject, x) @@ -5181,8 +5184,16 @@ symtable_assign(struct symtable *st, node *n, int flag) if (TYPE(tmp) == LPAR || TYPE(tmp) == LSQB) { n = CHILD(n, 1); goto loop; - } else if (TYPE(tmp) == NAME) + } else if (TYPE(tmp) == NAME) { + if (strcmp(STR(tmp), "__debug__") == 0) { + PyErr_SetString(PyExc_SyntaxError, + ASSIGN_DEBUG); + PyErr_SyntaxLocation(st->st_filename, + n->n_lineno); + st->st_errors++; + } symtable_add_def(st, STR(tmp), DEF_LOCAL | flag); + } return; case dotted_as_name: if (NCH(n) == 3) |