ret_cond adjustment for < 2.7 and ...

"<= 2.6" -> "< 2.7" since python 2.6's version is 2.6000001
This commit is contained in:
rocky
2016-09-09 15:55:15 -04:00
parent dd661bc94a
commit 03e8995d18
2 changed files with 10 additions and 10 deletions

View File

@@ -400,7 +400,7 @@ class Scanner2(scan.Scanner):
# beginning of a new statement # beginning of a new statement
prev = code[self.prev[s]] prev = code[self.prev[s]]
if (prev == self.opc.ROT_TWO or if (prev == self.opc.ROT_TWO or
self.version <= 2.6 and prev in self.version < 2.7 and prev in
(self.opc.JUMP_IF_FALSE, self.opc.JUMP_IF_TRUE, (self.opc.JUMP_IF_FALSE, self.opc.JUMP_IF_TRUE,
self.opc.RETURN_VALUE)): self.opc.RETURN_VALUE)):
stmts.remove(s) stmts.remove(s)
@@ -428,8 +428,8 @@ class Scanner2(scan.Scanner):
if except_match: if except_match:
jmp = self.prev[self.get_target(except_match)] jmp = self.prev[self.get_target(except_match)]
# In Python <= 2.6 we may have jumps to jumps # In Python < 2.7 we may have jumps to jumps
if self.version <= 2.6 and self.code[jmp] in self.jump_forward: if self.version < 2.7 and self.code[jmp] in self.jump_forward:
self.not_continue.add(jmp) self.not_continue.add(jmp)
jmp = self.get_target(jmp) jmp = self.get_target(jmp)
if jmp not in self.pop_jump_if | self.jump_forward: if jmp not in self.pop_jump_if | self.jump_forward:
@@ -847,20 +847,20 @@ class Scanner2(scan.Scanner):
pass pass
# FIXME: All the <2.6 conditions are is horrible. We need a better way. # FIXME: All the < 2.7 conditions are is horrible. We need a better way.
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.7, the POP_TOP in:
# RETURN_VALUE, POP_TOP # RETURN_VALUE, POP_TOP
# does now start a new statement # does now start a new statement
# Otherwise, we have want to add a "COME_FROM" # Otherwise, we have want to add a "COME_FROM"
if not (self.version <= 2.6 and if not (self.version < 2.7 and
self.code[label] == self.opc.POP_TOP and self.code[label] == self.opc.POP_TOP and
self.code[self.prev[label]] == self.opc.RETURN_VALUE): self.code[self.prev[label]] == self.opc.RETURN_VALUE):
# In Python <= 2.6, don't add a COME_FROM, for: # In Python < 2.7, don't add a COME_FROM, for:
# JUMP_FORWARD, END_FINALLY # JUMP_FORWARD, END_FINALLY
# or: # or:
# JUMP_FORWARD, POP_TOP, END_FINALLY # JUMP_FORWARD, POP_TOP, END_FINALLY
if not (self.version <= 2.6 and op == self.opc.JUMP_FORWARD if not (self.version < 2.7 and op == self.opc.JUMP_FORWARD
and ((self.code[offset+3] == self.opc.END_FINALLY) and ((self.code[offset+3] == self.opc.END_FINALLY)
or (self.code[offset+3] == self.opc.POP_TOP or (self.code[offset+3] == self.opc.POP_TOP
and self.code[offset+4] == self.opc.END_FINALLY))): and self.code[offset+4] == self.opc.END_FINALLY))):

View File

@@ -240,9 +240,9 @@ TABLE_DIRECT = {
'or': ( '%c or %c', 0, 2 ), 'or': ( '%c or %c', 0, 2 ),
'ret_or': ( '%c or %c', 0, 2 ), 'ret_or': ( '%c or %c', 0, 2 ),
'conditional': ( '%p if %p else %p', (2, 27), (0, 27), (4, 27)), 'conditional': ( '%p if %p else %p', (2, 27), (0, 27), (4, 27)),
'ret_cond': ( '%p if %p else %p', (2, 27), (0, 27), (4, 27)), 'ret_cond': ( '%p if %p else %p', (2, 27), (0, 27), (-1, 27)),
'conditionalnot': ( '%p if not %p else %p', (2, 27), (0, 22), (4, 27)), 'conditionalnot': ( '%p if not %p else %p', (2, 27), (0, 22), (4, 27)),
'ret_cond_not': ( '%p if not %p else %p', (2, 27), (0, 22), (4, 27)), 'ret_cond_not': ( '%p if not %p else %p', (2, 27), (0, 22), (-1, 27)),
'conditional_lambda': ( '(%c if %c else %c)', 2, 0, 3), 'conditional_lambda': ( '(%c if %c else %c)', 2, 0, 3),
'return_lambda': ('%c', 0), 'return_lambda': ('%c', 0),
'compare': ( '%p %[-1]{pattr} %p', (0, 19), (1, 19) ), 'compare': ( '%p %[-1]{pattr} %p', (0, 19), (1, 19) ),