You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Python 2.2..2.6 bug in a == b == c == d
Fix was to remove some come froms. Feels a little hacky though.
This commit is contained in:
BIN
test/bytecode_2.6/08_triple_equals.pyc
Normal file
BIN
test/bytecode_2.6/08_triple_equals.pyc
Normal file
Binary file not shown.
7
test/simple_source/bug26/08_triple_equals.py
Normal file
7
test/simple_source/bug26/08_triple_equals.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# From Python 2.6 aifc.py
|
||||||
|
# Bug was handling triple ==
|
||||||
|
# Fixed by removing some COME_FROMs inside
|
||||||
|
if expon == himant == lomant == 0:
|
||||||
|
f = 0.0
|
||||||
|
else:
|
||||||
|
f = 1.1
|
@@ -642,16 +642,17 @@ class Scanner2(scan.Scanner):
|
|||||||
self.fixed_jumps[i] = i+1
|
self.fixed_jumps[i] = i+1
|
||||||
|
|
||||||
elif op in self.pop_jump_if:
|
elif op in self.pop_jump_if:
|
||||||
start = pos+3
|
|
||||||
target = self.get_target(pos, op)
|
target = self.get_target(pos, op)
|
||||||
rtarget = self.restrict_to_parent(target, parent)
|
rtarget = self.restrict_to_parent(target, parent)
|
||||||
pre = self.prev
|
|
||||||
|
|
||||||
# Do not let jump to go out of parent struct bounds
|
# Do not let jump to go out of parent struct bounds
|
||||||
if target != rtarget and parent['type'] == 'and/or':
|
if target != rtarget and parent['type'] == 'and/or':
|
||||||
self.fixed_jumps[pos] = rtarget
|
self.fixed_jumps[pos] = rtarget
|
||||||
return
|
return
|
||||||
|
|
||||||
|
start = pos+3
|
||||||
|
pre = self.prev
|
||||||
|
|
||||||
# Does this jump to right after another conditional jump that is
|
# Does this jump to right after another conditional jump that is
|
||||||
# not myself? If so, it's part of a larger conditional.
|
# not myself? If so, it's part of a larger conditional.
|
||||||
# rocky: if we have a conditional jump to the next instruction, then
|
# rocky: if we have a conditional jump to the next instruction, then
|
||||||
@@ -673,13 +674,11 @@ class Scanner2(scan.Scanner):
|
|||||||
|
|
||||||
# Is it an "and" inside an "if" or "while" block
|
# Is it an "and" inside an "if" or "while" block
|
||||||
if op == self.opc.PJIF:
|
if op == self.opc.PJIF:
|
||||||
|
|
||||||
# Search for other POP_JUMP_IF_FALSE targetting the same op,
|
# Search for other POP_JUMP_IF_FALSE targetting the same op,
|
||||||
# in current statement, starting from current offset, and filter
|
# in current statement, starting from current offset, and filter
|
||||||
# everything inside inner 'or' jumps and midline ifs
|
# everything inside inner 'or' jumps and midline ifs
|
||||||
match = self.rem_or(start, self.next_stmt[pos], self.opc.PJIF, target)
|
match = self.rem_or(start, self.next_stmt[pos], self.opc.PJIF, target)
|
||||||
## We can't remove mid-line ifs because line structures have changed
|
|
||||||
## from restructBytecode().
|
|
||||||
## match = self.remove_mid_line_ifs(match)
|
|
||||||
|
|
||||||
# If we still have any offsets in set, start working on it
|
# If we still have any offsets in set, start working on it
|
||||||
if match:
|
if match:
|
||||||
@@ -714,9 +713,12 @@ class Scanner2(scan.Scanner):
|
|||||||
self.fixed_jumps[pos] = fix or match[-1]
|
self.fixed_jumps[pos] = fix or match[-1]
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.fixed_jumps[pos] = match[-1]
|
if self.version < 2.7 and parent['type'] == 'root':
|
||||||
|
self.fixed_jumps[pos] = rtarget
|
||||||
|
else:
|
||||||
|
self.fixed_jumps[pos] = match[-1]
|
||||||
return
|
return
|
||||||
else: # op == self.opc.PJIT
|
else: # op != self.opc.PJIT
|
||||||
if self.version < 2.7 and code[pos+3] == self.opc.POP_TOP:
|
if self.version < 2.7 and code[pos+3] == self.opc.POP_TOP:
|
||||||
assert_pos = pos + 4
|
assert_pos = pos + 4
|
||||||
else:
|
else:
|
||||||
@@ -835,6 +837,8 @@ class Scanner2(scan.Scanner):
|
|||||||
self.opc.JUMP_IF_TRUE_OR_POP):
|
self.opc.JUMP_IF_TRUE_OR_POP):
|
||||||
if (oparg > offset):
|
if (oparg > offset):
|
||||||
label = oparg
|
label = oparg
|
||||||
|
pass
|
||||||
|
pass
|
||||||
|
|
||||||
if label is not None and label != -1:
|
if label is not None and label != -1:
|
||||||
# In Python <= 2.6, the POP_TOP in:
|
# In Python <= 2.6, the POP_TOP in:
|
||||||
|
Reference in New Issue
Block a user