You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Less dishonest COME_FROMs
Addresses all of the problems seen in 3.7 datetime.py. However we limit COME_FROMs only to forward jumps, not back (which in the case of Python code right now means looping) jumps.
This commit is contained in:
@@ -33,6 +33,10 @@ class Python36Parser(Python35Parser):
|
|||||||
"""
|
"""
|
||||||
sstmt ::= sstmt RETURN_LAST
|
sstmt ::= sstmt RETURN_LAST
|
||||||
|
|
||||||
|
cf_for_iter ::= _come_froms FOR_ITER
|
||||||
|
list_for ::= expr cf_for_iter store list_iter jb_or_c
|
||||||
|
genexpr_func ::= LOAD_FAST cf_for_iter store comp_iter JUMP_BACK
|
||||||
|
|
||||||
# 3.6 redoes how return_closure works. FIXME: Isolate to LOAD_CLOSURE
|
# 3.6 redoes how return_closure works. FIXME: Isolate to LOAD_CLOSURE
|
||||||
return_closure ::= LOAD_CLOSURE DUP_TOP STORE_NAME RETURN_VALUE RETURN_LAST
|
return_closure ::= LOAD_CLOSURE DUP_TOP STORE_NAME RETURN_VALUE RETURN_LAST
|
||||||
|
|
||||||
|
@@ -811,7 +811,13 @@ class Scanner3(Scanner):
|
|||||||
self.fixed_jumps[offset] = fix or match[-1]
|
self.fixed_jumps[offset] = fix or match[-1]
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
if self.version < 3.6:
|
||||||
|
# FIXME: this is putting in COME_FROMs in the wrong place.
|
||||||
|
# Fix up grammar so we don't need to do this.
|
||||||
|
# See cf_for_iter use in parser36.py
|
||||||
self.fixed_jumps[offset] = match[-1]
|
self.fixed_jumps[offset] = match[-1]
|
||||||
|
else:
|
||||||
|
self.fixed_jumps[offset] = target
|
||||||
return
|
return
|
||||||
# op == POP_JUMP_IF_TRUE
|
# op == POP_JUMP_IF_TRUE
|
||||||
else:
|
else:
|
||||||
|
@@ -1433,7 +1433,7 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
assert node[n].kind.startswith('CALL_FUNCTION')
|
assert node[n].kind.startswith('CALL_FUNCTION')
|
||||||
|
|
||||||
if node[n].kind.startswith('CALL_FUNCTION_KW'):
|
if node[n].kind.startswith('CALL_FUNCTION_KW'):
|
||||||
# 3.6+ starts does this
|
# 3.6+ starts doing this
|
||||||
kwargs = node[n-1].attr
|
kwargs = node[n-1].attr
|
||||||
assert isinstance(kwargs, tuple)
|
assert isinstance(kwargs, tuple)
|
||||||
i = n - (len(kwargs)+1)
|
i = n - (len(kwargs)+1)
|
||||||
|
Reference in New Issue
Block a user