Towards fixing Python 3.5 return bugs

This commit is contained in:
rocky
2017-01-01 04:56:15 -05:00
parent f6a997befc
commit 874b3c9d31
2 changed files with 9 additions and 5 deletions

View File

@@ -35,13 +35,13 @@ class Python35Parser(Python34Parser):
# Python 3.5+ does jump optimization
# In <.3.5 the below is a JUMP_FORWARD to a JUMP_ABSOLUTE.
# in return_stmt, we will need the semantic actions in pysource.py
# to work out whether to dedent or not based on the presence of
# RETURN_END_IF vs RETURN_VALUE
return_if_stmt ::= ret_expr RETURN_END_IF POP_BLOCK
ifelsestmtc ::= testexpr c_stmts_opt JUMP_FORWARD else_suitec
# ifstmt ::= testexpr c_stmts_opt
# Python 3.3+ also has yield from. 3.5 does it
# differently than 3.3, 3.4

View File

@@ -624,9 +624,13 @@ class Scanner3(Scanner):
self.fixed_jumps[offset] = end
(line_no, next_line_byte) = self.lines[offset]
jump_back = self.last_instr(start, end, self.opc.JUMP_ABSOLUTE,
next_line_byte, False)
next_line_byte, False)
if jump_back:
jump_forward_offset = jump_back+3
else:
jump_forward_offset = None
jump_forward_offset = jump_back+3
return_val_offset1 = self.prev[self.prev[end]]
if (jump_back and jump_back != self.prev_op[end]