Bug in 3.5+ generator detection...

Also bug in 3.5 code detection for async attribute
This commit is contained in:
rocky
2019-06-04 13:38:06 -04:00
parent ad419e0ed9
commit af209dc142
5 changed files with 24 additions and 18 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -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

View File

@@ -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

View File

@@ -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
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
pass
pass
else:
code_node = node[0][1]
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',