diff options
-rw-r--r-- | Lib/test/test_compile.py | 3 | ||||
-rw-r--r-- | Python/ast.c | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index d1b6d8c..367a694 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -36,6 +36,9 @@ class TestSpecifics(unittest.TestCase): def test_syntax_error(self): self.assertRaises(SyntaxError, compile, "1+*3", "filename", "exec") + def test_none_keyword_arg(self): + self.assertRaises(SyntaxError, compile, "f(None=1)", "<string>", "exec") + def test_duplicate_global_local(self): try: exec 'def f(a): global a; a = 1' diff --git a/Python/ast.c b/Python/ast.c index 27c3efa..42dcc2d 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -1869,6 +1869,10 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func) 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; |