Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less dishonest COME_FROMs in 3.6+ code #237

Merged
merged 4 commits into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions uncompyle6/parsers/parse36.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def p_36misc(self, args):
"""
sstmt ::= sstmt RETURN_LAST

cf_for_iter ::= _come_froms FOR_ITER
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops - this isn't needed (or used) anymore. The decision (for now) is not to add COME_FROMS to backward (in current Python code generation that means looping) jumps.

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
return_closure ::= LOAD_CLOSURE DUP_TOP STORE_NAME RETURN_VALUE RETURN_LAST

Expand Down
8 changes: 7 additions & 1 deletion uncompyle6/scanners/scanner3.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,13 @@ def detect_control_flow(self, offset, targets, inst_index):
self.fixed_jumps[offset] = fix or match[-1]
return
else:
self.fixed_jumps[offset] = match[-1]
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]
else:
self.fixed_jumps[offset] = target
return
# op == POP_JUMP_IF_TRUE
else:
Expand Down
2 changes: 1 addition & 1 deletion uncompyle6/semantics/pysource.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ def print_super_classes3(self, node):
assert node[n].kind.startswith('CALL_FUNCTION')

if node[n].kind.startswith('CALL_FUNCTION_KW'):
# 3.6+ starts does this
# 3.6+ starts doing this
kwargs = node[n-1].attr
assert isinstance(kwargs, tuple)
i = n - (len(kwargs)+1)
Expand Down