changeset: 96996:e4e01488afff branch: 3.5 parent: 96994:9da080ecadb2 user: Yury Selivanov date: Wed Jul 22 14:48:57 2015 +0300 files: Lib/test/badsyntax_async2.py Lib/test/test_coroutines.py Python/compile.c Python/symtable.c description: Issue #24619: More tests; fix nits in compiler.c diff -r 9da080ecadb2 -r e4e01488afff Lib/test/badsyntax_async2.py --- a/Lib/test/badsyntax_async2.py Wed Jul 22 13:33:45 2015 +0300 +++ b/Lib/test/badsyntax_async2.py Wed Jul 22 14:48:57 2015 +0300 @@ -1,2 +1,2 @@ -async def foo(a:await something()): +async def foo(a=await something()): pass diff -r 9da080ecadb2 -r e4e01488afff Lib/test/test_coroutines.py --- a/Lib/test/test_coroutines.py Wed Jul 22 13:33:45 2015 +0300 +++ b/Lib/test/test_coroutines.py Wed Jul 22 14:48:57 2015 +0300 @@ -205,12 +205,14 @@ return lambda a: await """, - """async def foo(a: await b): + """await a()""", + + """async def foo(a=await b): pass """, """def baz(): - async def foo(a: await b): + async def foo(a=await b): pass """, @@ -271,10 +273,9 @@ pass\nawait a """] - ns = {} for code in samples: with self.subTest(code=code), self.assertRaises(SyntaxError): - exec(code, ns, ns) + compile(code, "", "exec") def test_goodsyntax_1(self): # Tests for issue 24619 diff -r 9da080ecadb2 -r e4e01488afff Python/compile.c --- a/Python/compile.c Wed Jul 22 13:33:45 2015 +0300 +++ b/Python/compile.c Wed Jul 22 14:48:57 2015 +0300 @@ -1749,13 +1749,12 @@ arglength = asdl_seq_LEN(args->defaults); arglength |= kw_default_count << 8; arglength |= num_annotations << 16; + if (is_async) + co->co_flags |= CO_COROUTINE; compiler_make_closure(c, co, arglength, qualname); Py_DECREF(qualname); Py_DECREF(co); - if (is_async) - co->co_flags |= CO_COROUTINE; - /* decorators */ for (i = 0; i < asdl_seq_LEN(decos); i++) { ADDOP_I(c, CALL_FUNCTION, 1); diff -r 9da080ecadb2 -r e4e01488afff Python/symtable.c --- a/Python/symtable.c Wed Jul 22 13:33:45 2015 +0300 +++ b/Python/symtable.c Wed Jul 22 14:48:57 2015 +0300 @@ -1542,7 +1542,7 @@ if (a->kwonlyargs && !symtable_visit_argannotations(st, a->kwonlyargs)) return 0; if (returns) - VISIT(st, expr, s->v.FunctionDef.returns); + VISIT(st, expr, returns); return 1; }