Mercurial > cpython-lru_cache-weakref
diff Python/compile.c @ 17185:f9a30015e8b0 legacy-trunk
Make it illegal to assign to __debug__ as per Guido's request.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Fri, 23 Mar 2001 14:08:38 +0000 |
| parents | 55218e0495bc |
| children | 4468a8da67ca |
line wrap: on
line diff
--- a/Python/compile.c Fri Mar 23 14:05:53 2001 +0000 +++ b/Python/compile.c Fri Mar 23 14:08:38 2001 +0000 @@ -66,6 +66,9 @@ #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 @@ 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)
