2.6 and before COME_FROM handling...

also, add in some of the test bytecode from the python-2.4 branch
This commit is contained in:
rocky
2018-03-04 21:42:59 -05:00
parent def9e1676b
commit 9e815d8d79
8 changed files with 21 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,13 @@
# From 2.3 Queue.py
# Bug was adding COME_FROM from while
# confusing the else
def put(item, block=True, timeout=None):
if block:
if timeout:
while True:
if item:
block = 1
else:
block = 5
elif item:
block = False

View File

@@ -115,8 +115,7 @@ class Python26Parser(Python2Parser):
# Semantic actions want else_suitel to be at index 3
ifelsestmtl ::= testexpr c_stmts_opt cf_jb_cf_pop else_suitel
ifelsestmtc ::= testexpr c_stmts_opt ja_cf_pop else_suitec
ifelsestmtc ::= testexpr c_stmts_opt ja_cf_pop else_suitec
# Semantic actions want suite_stmts_opt to be at index 3
withstmt ::= expr setupwith SETUP_FINALLY suite_stmts_opt

View File

@@ -1127,7 +1127,13 @@ class Scanner2(Scanner):
source = self.setup_loops[label]
else:
source = offset
targets[label] = targets.get(label, []) + [source]
# FIXME: The grammar for 2.6 and before doesn't
# handle COME_FROM's from a loop inside if's
# It probably should.
if (self.version > 2.6 or
self.code[source] != self.opc.SETUP_LOOP or
self.code[label] != self.opc.JUMP_FORWARD):
targets[label] = targets.get(label, []) + [source]
pass
pass
pass