You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Bug in 3.5+ generator detection...
Also bug in 3.5 code detection for async attribute
This commit is contained in:
BIN
test/bytecode_3.5/02_async.pyc
Normal file
BIN
test/bytecode_3.5/02_async.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.7/02_async.pyc
Normal file
BIN
test/bytecode_3.7/02_async.pyc
Normal file
Binary file not shown.
17
test/simple_source/bug35/02_async.py
Normal file
17
test/simple_source/bug35/02_async.py
Normal 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
|
@@ -597,16 +597,9 @@ class Python3Parser(PythonParser):
|
|||||||
|
|
||||||
# Determine if we have an iteration CALL_FUNCTION_1.
|
# Determine if we have an iteration CALL_FUNCTION_1.
|
||||||
has_get_iter_call_function1 = False
|
has_get_iter_call_function1 = False
|
||||||
max_branches = 0
|
|
||||||
for i, token in enumerate(tokens):
|
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':
|
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
|
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):
|
for i, token in enumerate(tokens):
|
||||||
opname = token.kind
|
opname = token.kind
|
||||||
|
@@ -117,18 +117,14 @@ def customize_for_version35(self, version):
|
|||||||
self.n_call = n_call
|
self.n_call = n_call
|
||||||
|
|
||||||
def n_function_def(node):
|
def n_function_def(node):
|
||||||
if self.version >= 3.6:
|
n0 = node[0]
|
||||||
code_node = node[0][0]
|
is_code = False
|
||||||
for n in node[0]:
|
for i in list(range(len(n0)-2, -1, -1)):
|
||||||
if hasattr(n, 'attr') and iscode(n.attr):
|
code_node = n0[i]
|
||||||
code_node = n
|
if hasattr(code_node, 'attr') and iscode(code_node.attr):
|
||||||
break
|
is_code = True
|
||||||
pass
|
break
|
||||||
pass
|
|
||||||
else:
|
|
||||||
code_node = node[0][1]
|
|
||||||
|
|
||||||
is_code = hasattr(code_node, 'attr') and iscode(code_node.attr)
|
|
||||||
if (is_code and
|
if (is_code and
|
||||||
(code_node.attr.co_flags & COMPILER_FLAG_BIT['COROUTINE'])):
|
(code_node.attr.co_flags & COMPILER_FLAG_BIT['COROUTINE'])):
|
||||||
self.template_engine(('\n\n%|async def %c\n',
|
self.template_engine(('\n\n%|async def %c\n',
|
||||||
|
Reference in New Issue
Block a user