Mercurial > cpython-lru_cache-weakref
comparison Python/compile.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 | 1c964ed35ef9 |
| children | 94e79d78dff0 |
comparison
equal
deleted
inserted
replaced
| 49693:bc4f742e2c1d | 49696:2e0857b0fc67 |
|---|---|
| 2342 | 2342 |
| 2343 PyObject *dict = c->u->u_names; | 2343 PyObject *dict = c->u->u_names; |
| 2344 PyObject *mangled; | 2344 PyObject *mangled; |
| 2345 /* XXX AugStore isn't used anywhere! */ | 2345 /* XXX AugStore isn't used anywhere! */ |
| 2346 | 2346 |
| 2347 /* First check for assignment to __debug__. Param? */ | |
| 2348 if ((ctx == Store || ctx == AugStore || ctx == Del) | |
| 2349 && !strcmp(PyString_AS_STRING(name), "__debug__")) { | |
| 2350 return compiler_error(c, "can not assign to __debug__"); | |
| 2351 } | |
| 2352 | |
| 2353 mangled = _Py_Mangle(c->u->u_private, name); | 2347 mangled = _Py_Mangle(c->u->u_private, name); |
| 2354 if (!mangled) | 2348 if (!mangled) |
| 2355 return 0; | 2349 return 0; |
| 2356 | 2350 |
| 2357 op = 0; | 2351 op = 0; |
