Skip to content

Commit

Permalink
Merge pull request #236 from x0ret/master
Browse files Browse the repository at this point in the history
Python 3.7 decompiling full 3.7.3 library without error #235
  • Loading branch information
rocky authored May 13, 2019
2 parents 251eb6d + 3d732db commit ce9270d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
Binary file added test/bytecode_3.7/01_chained_compare.pyc
Binary file not shown.
7 changes: 7 additions & 0 deletions test/simple_source/bug37/01_chained_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ def chained_compare_b(a, obj):
if -0x80000000 <= obj <= 0x7fffffff:
return 5

def chained_compare_c(a, d):
for i in len(d):
if a == d[i] != 2:
return 5

chained_compare_a(3)
try:
chained_compare_a(8)
except ValueError:
pass
chained_compare_b(True, 0x0)

chained_compare_c(3, [3])
3 changes: 3 additions & 0 deletions uncompyle6/parsers/parse37.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def p_37misc(self, args):
compare_chained37 ::= expr compare_chained1a_37
compare_chained37 ::= expr compare_chained1b_37
compare_chained37_false ::= expr compare_chained1_false_37
compare_chained37_false ::= expr compare_chained2_false_37
compare_chained1a_37 ::= expr DUP_TOP ROT_THREE COMPARE_OP POP_JUMP_IF_FALSE
compare_chained1a_37 ::= expr DUP_TOP ROT_THREE COMPARE_OP POP_JUMP_IF_FALSE
Expand All @@ -98,6 +99,8 @@ def p_37misc(self, args):
compare_chained1_false_37 ::= expr DUP_TOP ROT_THREE COMPARE_OP POP_JUMP_IF_FALSE
compare_chained2c_37 POP_TOP JUMP_FORWARD COME_FROM
compare_chained2_false_37 ::= expr DUP_TOP ROT_THREE COMPARE_OP POP_JUMP_IF_FALSE
compare_chained2a_false_37 ELSE POP_TOP JUMP_BACK COME_FROM
compare_chained2a_37 ::= expr COMPARE_OP POP_JUMP_IF_TRUE JUMP_FORWARD
compare_chained2a_false_37 ::= expr COMPARE_OP POP_JUMP_IF_FALSE JUMP_FORWARD
Expand Down
3 changes: 3 additions & 0 deletions uncompyle6/semantics/customize37.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def customize_for_version37(self, version):
'compare_chained1_false_37': (
' %[3]{pattr.replace("-", " ")} %p %p',
(0, 19), (-4, 19)),
'compare_chained2_false_37': (
' %[3]{pattr.replace("-", " ")} %p %p',
(0, 19), (-5, 19)),
'compare_chained1b_37': (
' %[3]{pattr.replace("-", " ")} %p %p',
(0, 19), (-4, 19)),
Expand Down
2 changes: 1 addition & 1 deletion uncompyle6/semantics/pysource.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ def print_super_classes3(self, node):
i = n - (len(kwargs)+1)
j = 1 + n - node[n].attr
else:
start = n-2
i = start = n-2
for i in range(start, 0, -1):
if not node[i].kind in ['expr', 'call', 'LOAD_CLASSNAME']:
break
Expand Down

0 comments on commit ce9270d

Please sign in to comment.