2.6 POP_TOP and POP_JUMP_IF bugs

This commit is contained in:
rocky
2016-07-07 06:45:04 -04:00
parent 72c781258f
commit 8b305f78f4
3 changed files with 13 additions and 4 deletions

View File

@@ -27,7 +27,7 @@ from fnmatch import fnmatch
#----- configure this for your needs
TEST_VERSIONS=('2.3.7', '2.6.9', '2.7.10', '2.7.11', '3.2.6', '3.3.5', '3.4.2', '3.5.1')
TEST_VERSIONS=('2.3.7', '2.5.6', '2.6.9', '2.7.10', '2.7.11', '3.2.6', '3.3.5', '3.4.2', '3.5.1')
target_base = '/tmp/py-dis/'
lib_prefix = os.path.join(os.environ['HOME'], '.pyenv/versions')

View File

@@ -69,8 +69,12 @@ class Python26Parser(Python2Parser):
# after one of these jumps
def p_jumps26(self, args):
"""
# The are the equivalents of Python 2.7+'s
# POP_JUMP_IF_TRUE and POP_JUMP_IF_FALSE
jmp_true ::= JUMP_IF_TRUE POP_TOP
jmp_false ::= JUMP_IF_FALSE POP_TOP
jf_pop ::= JUMP_FORWARD come_from_pop
jf_pop ::= JUMP_ABSOLUTE come_from_pop
jb_pop ::= JUMP_BACK come_from_pop
@@ -194,7 +198,7 @@ class Python26Parser(Python2Parser):
'''
conditional ::= expr jmp_false expr jf_cf_pop expr come_from_opt
and ::= expr JUMP_IF_FALSE POP_TOP expr JUMP_IF_FALSE POP_TOP
cmp_list ::= expr cmp_list1 ROT_TWO COME_FROM POP_TOP _come_from
'''
class Python26ParserSingle(Python2Parser, PythonParserSingle):

View File

@@ -438,7 +438,7 @@ class Scanner2(scan.Scanner):
if_offset = None
if self.version < 2.7:
# Look for JUMP_IF... POP_TOP
# Look for JUMP_IF POP_TOP ...
if (code[self.prev[next_line_byte]] == self.opc.POP_TOP
and (code[self.prev[self.prev[next_line_byte]]]
in self.pop_jump_if)):
@@ -476,7 +476,12 @@ class Scanner2(scan.Scanner):
loop_type = 'for'
else:
loop_type = 'while'
test = self.prev[next_line_byte]
if (self.version < 2.7
and self.code[self.prev[next_line_byte]] == self.opc.POP_TOP):
test = self.prev[self.prev[next_line_byte]]
else:
test = self.prev[next_line_byte]
if test == pos:
loop_type = 'while 1'
elif self.code[test] in self.opc.hasjabs + self.opc.hasjrel: