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:
rocky 2016-09-03 09:56:41 -04:00
parent b6fd9088b8
commit 75c718bc5c
3 changed files with 18 additions and 7 deletions

Binary file not shown.

View 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

View File

@ -642,16 +642,17 @@ class Scanner2(scan.Scanner):
self.fixed_jumps[i] = i+1
elif op in self.pop_jump_if:
start = pos+3
target = self.get_target(pos, op)
rtarget = self.restrict_to_parent(target, parent)
pre = self.prev
# Do not let jump to go out of parent struct bounds
if target != rtarget and parent['type'] == 'and/or':
self.fixed_jumps[pos] = rtarget
return
start = pos+3
pre = self.prev
# Does this jump to right after another conditional jump that is
# not myself? If so, it's part of a larger conditional.
# 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
if op == self.opc.PJIF:
# Search for other POP_JUMP_IF_FALSE targetting the same op,
# in current statement, starting from current offset, and filter
# everything inside inner 'or' jumps and midline ifs
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 match:
@ -714,9 +713,12 @@ class Scanner2(scan.Scanner):
self.fixed_jumps[pos] = fix or match[-1]
return
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
else: # op == self.opc.PJIT
else: # op != self.opc.PJIT
if self.version < 2.7 and code[pos+3] == self.opc.POP_TOP:
assert_pos = pos + 4
else:
@ -835,6 +837,8 @@ class Scanner2(scan.Scanner):
self.opc.JUMP_IF_TRUE_OR_POP):
if (oparg > offset):
label = oparg
pass
pass
if label is not None and label != -1:
# In Python <= 2.6, the POP_TOP in: