Mercurial > cpython-lru_cache-weakref
diff Python/ast.c @ 49696:2e0857b0fc67 legacy-trunk
check for assignment to __debug__ during AST generation
Also, give assignment to None a better error message
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 08 Nov 2008 18:38:54 +0000 |
| parents | 6634530a04e0 |
| children | b64d053afd84 |
line wrap: on
line diff
--- a/Python/ast.c Sat Nov 08 17:07:06 2008 +0000 +++ b/Python/ast.c Sat Nov 08 18:38:54 2008 +0000 @@ -130,7 +130,9 @@ forbidden_check(struct compiling *c, const node *n, const char *x) { if (!strcmp(x, "None")) - return ast_error(n, "assignment to None"); + return ast_error(n, "cannot assign to None"); + if (!strcmp(x, "__debug__")) + return ast_error(n, "cannot assign to __debug__"); if (Py_Py3kWarningFlag) { if (!(strcmp(x, "True") && strcmp(x, "False")) && !ast_warn(c, n, "assignment to True or False is forbidden in 3.x"))
