From 87db833f62a958c505e0bd68c732faf18968852b Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 22 Apr 2017 10:34:21 -0400 Subject: [PATCH] Add await expr Fixes #111 --- test/bytecode_3.5/03_async_await.pyc | Bin 1146 -> 1249 bytes test/simple_source/bug35/03_async_await.py | 3 +++ uncompyle6/parsers/parse35.py | 6 +++++- uncompyle6/semantics/pysource.py | 3 ++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/bytecode_3.5/03_async_await.pyc b/test/bytecode_3.5/03_async_await.pyc index 5aeec7a3ac2714c839de5c4e6363d9f625e63fa4..c36dde672b8c4cf1ec6f51a12ec62c19ba3700e3 100644 GIT binary patch delta 132 zcmeyx@sLwljF*?oJo9(ND@F!}#|%h-3CMN;;^K&j%6|MQybLW23{h+hDSQmUn*19} zwlGh=z%0hY2~<(Tz~Gs}z~C|Y8?&NFx;#h^NHYUtktmS#(`28l%_7ezI@ygyO@Id| P!o$MD#=`+5S$LQMhe8#W delta 92 zcmaFJ`HMqYjF*>d+lsFd#~2wH9y1^TCLr4Zh>LwDD*G`9Yw~Vv*uu>0r^zKuoMxT diff --git a/test/simple_source/bug35/03_async_await.py b/test/simple_source/bug35/03_async_await.py index 38ae9da8..96fbb1bc 100644 --- a/test/simple_source/bug35/03_async_await.py +++ b/test/simple_source/bug35/03_async_await.py @@ -27,3 +27,6 @@ async def awith_as_test(): async def f(z): await z + +async def g(z): + return await z diff --git a/uncompyle6/parsers/parse35.py b/uncompyle6/parsers/parse35.py index 0c7cc944..d9271618 100644 --- a/uncompyle6/parsers/parse35.py +++ b/uncompyle6/parsers/parse35.py @@ -27,8 +27,12 @@ class Python35Parser(Python34Parser): POP_BLOCK else_suite COME_FROM_LOOP # Python 3.5+ Await statement + expr ::= await_expr + await_expr ::= expr GET_AWAITABLE LOAD_CONST YIELD_FROM + stmt ::= await_stmt - await_stmt ::= expr GET_AWAITABLE LOAD_CONST YIELD_FROM POP_TOP + await_stmt ::= await_expr POP_TOP + # Python 3.5+ has WITH_CLEANUP_START/FINISH diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 46647873..117cba13 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -335,7 +335,8 @@ class SourceWalker(GenericASTTraversal, object): ####################### if version >= 3.5: TABLE_DIRECT.update({ - 'await_stmt': ( '%|await %c', 0), + 'await_expr': ( 'await %c', 0), + 'await_stmt': ( '%|%c', 0), 'async_for_stmt': ( '%|async for %c in %c:\n%+%c%-\n\n', 9, 1, 25 ), 'async_forelse_stmt': (