diff --git a/test/bytecode_3.5/03_async_await.pyc b/test/bytecode_3.5/03_async_await.pyc index cc528841..291b14e3 100644 Binary files a/test/bytecode_3.5/03_async_await.pyc and b/test/bytecode_3.5/03_async_await.pyc differ diff --git a/test/bytecode_3.6/03_async_await.pyc b/test/bytecode_3.6/03_async_await.pyc index 0d50fe37..97f7ae15 100644 Binary files a/test/bytecode_3.6/03_async_await.pyc and b/test/bytecode_3.6/03_async_await.pyc differ diff --git a/test/simple_source/bug35/03_async_await.py b/test/simple_source/bug35/03_async_await.py index 7dec4df4..19d7ca95 100644 --- a/test/simple_source/bug35/03_async_await.py +++ b/test/simple_source/bug35/03_async_await.py @@ -1,8 +1,8 @@ # Python 3.5+ async and await -async def await_test(): +async def await_test(asyncio): + reader, writer = await asyncio.open_connection(80) await bar() - async def afor_test(): async for i in [1,2,3]: diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 7e122fef..4c421935 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -453,6 +453,15 @@ class Python3Parser(PythonParser): ('kwarg ' * args_kw) + 'expr ' * nak + token.type) self.add_unique_rule(rule, token.type, args_pos, customize) + if self.version >= 3.5: + rule = ('async_call_function ::= expr ' + + ('pos_arg ' * args_pos) + + ('kwarg ' * args_kw) + + 'expr ' * nak + token.type + + ' GET_AWAITABLE LOAD_CONST YIELD_FROM') + self.add_unique_rule(rule, token.type, args_pos, customize) + self.add_unique_rule('expr ::= async_call_function', token.type, args_pos, customize) + rule = ('classdefdeco2 ::= LOAD_BUILD_CLASS mkfunc %s%s_%d' % (('expr ' * (args_pos-1)), opname, args_pos)) self.add_unique_rule(rule, token.type, args_pos, customize) diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 57d80f08..03722cdd 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -332,6 +332,16 @@ class SourceWalker(GenericASTTraversal, object): '%|async with %c as %c:\n%+%c%-', 0, 6, 7), }) + def n_async_call_function(node): + self.f.write('async ') + node.type == 'call_function' + p = self.prec + self.prec = 80 + self.engine(('%c(%P)', 0, (1, -4, ', ', 100)), node) + self.prec = p + self.prune() + self.n_async_call_function = n_async_call_function + def n_funcdef(node): code_node = node[0][1] if (code_node == 'LOAD_CONST' and iscode(code_node.attr) @@ -1589,7 +1599,7 @@ class SourceWalker(GenericASTTraversal, object): beginning of this module for the how we interpret format specifications such as %c, %C, and so on. """ - # self.println("----> ", startnode.type) + # self.println("----> ", startnode.type, ', ', entry[0]) fmt = entry[0] arg = 1 i = 0