diff --git a/uncompyle6/parsers/parse37base.py b/uncompyle6/parsers/parse37base.py index de54f05a..94d75dae 100644 --- a/uncompyle6/parsers/parse37base.py +++ b/uncompyle6/parsers/parse37base.py @@ -584,6 +584,21 @@ class Python37BaseParser(PythonParser): """ self.add_unique_doc_rules(rules_str, customize) + elif opname == "GET_ANEXT": + self.addRule( + """ + func_async_prefix ::= _come_froms SETUP_FINALLY GET_ANEXT LOAD_CONST YIELD_FROM POP_BLOCK + func_async_middle ::= JUMP_FORWARD COME_FROM_EXCEPT + DUP_TOP LOAD_GLOBAL COMPARE_OP POP_JUMP_IF_TRUE + list_afor2 ::= func_async_prefix + store list_iter + JUMP_BACK COME_FROM_FINALLY + END_ASYNC_FOR + """, + nop_func, + ) + custom_ops_processed.add(opname) + elif opname == "FORMAT_VALUE_ATTR": rules_str = """ expr ::= formatted_value2 diff --git a/uncompyle6/parsers/parse38.py b/uncompyle6/parsers/parse38.py index 5c179870..5cd8bc56 100644 --- a/uncompyle6/parsers/parse38.py +++ b/uncompyle6/parsers/parse38.py @@ -75,6 +75,11 @@ class Python38Parser(Python37Parser): COME_FROM_FINALLY END_ASYNC_FOR + genexpr_func_async ::= LOAD_FAST func_async_prefix + store comp_iter + JUMP_BACK COME_FROM_FINALLY + END_ASYNC_FOR + # FIXME: come froms after the else_suite or END_ASYNC_FOR distinguish which of # for / forelse is used. Add come froms and check of add up control-flow detection phase. async_forelse_stmt38 ::= expr diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index e5ccc619..632e2070 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1179,10 +1179,22 @@ class SourceWalker(GenericASTTraversal, object): code_index = -6 if self.version > (3, 6): # Python 3.7+ adds optional "come_froms" at node[0] - iter_index = 4 + if node[0].kind in ("load_closure", "load_genexpr") and self.version >= (3, 8): + is_lambda = self.is_lambda + if node[0].kind == "load_genexpr": + self.is_lambda = False + self.closure_walk(node, collection_index=4) + self.closure_walk(node, collection_index=4) + self.is_lambda = is_lambda + else: + code_index = -6 + iter_index = 4 if self.version < (3, 8) else 3 + self.comprehension_walk(node, iter_index=iter_index, code_index=code_index) + pass + pass else: code_index = -5 - self.comprehension_walk(node, iter_index=iter_index, code_index=code_index) + self.comprehension_walk(node, iter_index=iter_index, code_index=code_index) self.write(")") self.prune() @@ -1421,7 +1433,8 @@ class SourceWalker(GenericASTTraversal, object): store = ast[3] collection = node[collection_index] - n = ast[4] + iter_index = 3 if ast == "genexpr_func_async" else 4 + n = ast[iter_index] list_if = None assert n == "comp_iter"