check for assignment to __debug__ during AST generation

Also, give assignment to None a better error message
This commit is contained in:
Benjamin Peterson 2008-11-08 18:38:54 +00:00
parent 942e4779b0
commit 2c98faada6
3 changed files with 11 additions and 17 deletions

View file

@ -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;