2.5/2.6 RETURN_VALUE bug

This commit is contained in:
rocky 2016-07-08 12:02:28 -04:00
parent b640d42113
commit e020f8f9a9
5 changed files with 15 additions and 4 deletions

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,13 @@
# 2.5.6 decimal.py
# Bug on 2.5 and 2.6 by incorrectly changing opcode to
# RETURN_VALUE to psuedo op: RETURN_END_IF
def _formatparam(param, value=None, quote=True):
if value is not None and len(value) > 0:
if isinstance(value, tuple):
value = 'a'
if quote or param:
pass
else:
return '%s=%s' % (param, value)
else:
return param

View File

@ -720,7 +720,8 @@ class Scanner2(scan.Scanner):
self.structs.append({'type': 'if-then',
'start': start,
'end': rtarget})
self.return_end_ifs.add(pre_rtarget)
if self.version == 2.7 or code[pre_rtarget+1] != self.opc.JUMP_FORWARD:
self.return_end_ifs.add(pre_rtarget)
elif op in self.pop_jump_if_or_pop:
target = self.get_target(pos, op)

View File

@ -219,9 +219,6 @@ class Scanner26(scan.Scanner2):
pattr = repr(offset + 3 + oparg)
if op == self.opc.JUMP_FORWARD:
target = self.get_target(offset)
if target > offset and self.code[target] == self.opc.RETURN_VALUE:
# Python 2.5 sometimes has this
op_name = 'JUMP_RETURN'
# FIXME: this is a hack to catch stuff like:
# if x: continue
# the "continue" is not on a new line.