diff --git a/test/bytecode_3.5/02_async.pyc b/test/bytecode_3.5/02_async.pyc new file mode 100644 index 00000000..2fcaa036 Binary files /dev/null and b/test/bytecode_3.5/02_async.pyc differ diff --git a/test/bytecode_3.7/02_async.pyc b/test/bytecode_3.7/02_async.pyc new file mode 100644 index 00000000..aedaf5df Binary files /dev/null and b/test/bytecode_3.7/02_async.pyc differ diff --git a/test/simple_source/bug35/02_async.py b/test/simple_source/bug35/02_async.py new file mode 100644 index 00000000..11612686 --- /dev/null +++ b/test/simple_source/bug35/02_async.py @@ -0,0 +1,17 @@ +# From 3.7.3 asyncio/base_events.py +# We had (still have) screwy logic. Python 3.5 code node detection was off too. + +async def create_connection(self): + infos = await self._ensure_resolved() + + laddr_infos = await self._ensure_resolved() + for family in infos: + for laddr in laddr_infos: + family = 1 + else: + continue + await self.sock_connect() + else: + raise OSError('Multiple exceptions: {}' for exc in family) + + return diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 96fac197..24eac0ab 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -597,16 +597,9 @@ class Python3Parser(PythonParser): # Determine if we have an iteration CALL_FUNCTION_1. has_get_iter_call_function1 = False - max_branches = 0 for i, token in enumerate(tokens): if token == 'GET_ITER' and i < n-2 and self.call_fn_name(tokens[i+1]) == 'CALL_FUNCTION_1': has_get_iter_call_function1 = True - max_branches += 1 - elif (token == 'GET_AWAITABLE' and i < n-3 - and tokens[i+1] == 'LOAD_CONST' and tokens[i+2] == 'YIELD_FROM'): - max_branches += 1 - if max_branches > 2: - break for i, token in enumerate(tokens): opname = token.kind diff --git a/uncompyle6/semantics/customize35.py b/uncompyle6/semantics/customize35.py index 05639d5c..165bcfa1 100644 --- a/uncompyle6/semantics/customize35.py +++ b/uncompyle6/semantics/customize35.py @@ -117,18 +117,14 @@ def customize_for_version35(self, version): self.n_call = n_call def n_function_def(node): - if self.version >= 3.6: - code_node = node[0][0] - for n in node[0]: - if hasattr(n, 'attr') and iscode(n.attr): - code_node = n - break - pass - pass - else: - code_node = node[0][1] + n0 = node[0] + is_code = False + for i in list(range(len(n0)-2, -1, -1)): + code_node = n0[i] + if hasattr(code_node, 'attr') and iscode(code_node.attr): + is_code = True + break - is_code = hasattr(code_node, 'attr') and iscode(code_node.attr) if (is_code and (code_node.attr.co_flags & COMPILER_FLAG_BIT['COROUTINE'])): self.template_engine(('\n\n%|async def %c\n',