Mercurial > cpython-lru_cache-weakref
diff Python/ast.c @ 41975:c2ac22c6f98d 2.5
Disallow function calls like foo(None=1).
Backport from py3k rev. 55708 by Guido.
(backport from rev. 55802)
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Thu, 07 Jun 2007 13:23:28 +0000 |
| parents | d835809f45ec |
| children | ddefbdbdbcb5 |
line wrap: on
line diff
--- a/Python/ast.c Tue Jun 05 22:06:28 2007 +0000 +++ b/Python/ast.c Thu Jun 07 13:23:28 2007 +0000 @@ -1855,13 +1855,18 @@ * then is very confusing. */ if (e->kind == Lambda_kind) { - ast_error(CHILD(ch, 0), "lambda cannot contain assignment"); - return NULL; + ast_error(CHILD(ch, 0), + "lambda cannot contain assignment"); + return NULL; } else if (e->kind != Name_kind) { - ast_error(CHILD(ch, 0), "keyword can't be an expression"); - return NULL; + ast_error(CHILD(ch, 0), "keyword can't be an expression"); + return NULL; } key = e->v.Name.id; + if (!strcmp(PyString_AS_STRING(key), "None")) { + ast_error(CHILD(ch, 0), "assignment to None"); + return NULL; + } e = ast_for_expr(c, CHILD(ch, 2)); if (!e) return NULL;
