]> granicus.if.org Git - python/commitdiff
Issue #24619: More tests; fix nits in compiler.c
authorYury Selivanov <yselivanov@sprymix.com>
Wed, 22 Jul 2015 11:48:57 +0000 (14:48 +0300)
committerYury Selivanov <yselivanov@sprymix.com>
Wed, 22 Jul 2015 11:48:57 +0000 (14:48 +0300)
Lib/test/badsyntax_async2.py
Lib/test/test_coroutines.py
Python/compile.c
Python/symtable.c

index 6f6f4f5dd0bdcdc69a6376961df5967d626366ca..fb85e2905213ce3aec6427e34f46c1b76a343e90 100644 (file)
@@ -1,2 +1,2 @@
-async def foo(a:await something()):
+async def foo(a=await something()):
     pass
index 3ba2f2383c81b46f92e179ef1acdf281c31e8a35..94994e548bd3df3ebd5a7782802615e93c372849 100644 (file)
@@ -205,12 +205,14 @@ class AsyncBadSyntaxTest(unittest.TestCase):
                    return lambda a: await
             """,
 
-            """async def foo(a: await b):
+            """await a()""",
+
+            """async def foo(a=await b):
                    pass
             """,
 
             """def baz():
-                   async def foo(aawait b):
+                   async def foo(a=await b):
                        pass
             """,
 
@@ -271,10 +273,9 @@ class AsyncBadSyntaxTest(unittest.TestCase):
                         pass\nawait a
             """]
 
-        ns = {}
         for code in samples:
             with self.subTest(code=code), self.assertRaises(SyntaxError):
-                exec(code, ns, ns)
+                compile(code, "<test>", "exec")
 
     def test_goodsyntax_1(self):
         # Tests for issue 24619
index 2202e8f3a1cacc9e5b57c4764a55014e2d8a41c7..33cc8c22cb86399415a905cdea4c960e57d39a97 100644 (file)
@@ -1749,13 +1749,12 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async)
     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);
index 354b7996786808b87e0de3d454e22ec12247c53d..64910d8a558b776408b057389ebe4df259ddd8ac 100644 (file)
@@ -1542,7 +1542,7 @@ symtable_visit_annotations(struct symtable *st, stmt_ty s,
     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;
 }