summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-11-08 18:38:54 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-11-08 18:38:54 (GMT)
commit2c98faada6f268d32c4031f7d09d9d5e6a2f46e3 (patch)
treeb5555e4413d2df2147f15a12e563e83261564926 /Python
parent942e4779b05dbf382e9b59a56a31ba311fa6e4d5 (diff)
downloadcpython-2c98faada6f268d32c4031f7d09d9d5e6a2f46e3.zip
cpython-2c98faada6f268d32c4031f7d09d9d5e6a2f46e3.tar.gz
cpython-2c98faada6f268d32c4031f7d09d9d5e6a2f46e3.tar.bz2
check for assignment to __debug__ during AST generation
Also, give assignment to None a better error message
Diffstat (limited to 'Python')
-rw-r--r--Python/ast.c4
-rw-r--r--Python/compile.c6
2 files changed, 3 insertions, 7 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 29b0e82..6eb3aa4 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -130,7 +130,9 @@ static int
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"))
diff --git a/Python/compile.c b/Python/compile.c
index 264fdcd..88d54ab 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -2344,12 +2344,6 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
PyObject *mangled;
/* XXX AugStore isn't used anywhere! */
- /* First check for assignment to __debug__. Param? */
- if ((ctx == Store || ctx == AugStore || ctx == Del)
- && !strcmp(PyString_AS_STRING(name), "__debug__")) {
- return compiler_error(c, "can not assign to __debug__");
- }
-
mangled = _Py_Mangle(c->u->u_private, name);
if (!mangled)
return 0;