Skip to content

Commit

Permalink
fix chained compare parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
x0ret committed May 13, 2019
1 parent 009a74d commit 3d732db
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
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

0 comments on commit 3d732db

Please sign in to comment.