You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
3.5+ handle then before "if" jump going to loop
This commit is contained in:
BIN
test/bytecode_3.5/01_while_if_then.pyc
Normal file
BIN
test/bytecode_3.5/01_while_if_then.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.6/01_while_if_then.pyc
Normal file
BIN
test/bytecode_3.6/01_while_if_then.pyc
Normal file
Binary file not shown.
23
test/simple_source/bug35/01_while_if_then.py
Normal file
23
test/simple_source/bug35/01_while_if_then.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# From python 3.5.5 telnetlib
|
||||
# The bug is the end of a "then" jumping
|
||||
# back to the loop which could look like
|
||||
# a "continue" and also not like a then/else
|
||||
# break
|
||||
def process_rawq(self, cmd, cmd2):
|
||||
while self.rawq:
|
||||
if self.iacseq:
|
||||
if cmd:
|
||||
pass
|
||||
elif cmd2:
|
||||
if self.option_callback:
|
||||
self.option = 2
|
||||
else:
|
||||
self.option = 3
|
||||
|
||||
# From python 3.5.5 telnetlib
|
||||
def listener(data):
|
||||
while 1:
|
||||
if data:
|
||||
data = 1
|
||||
else:
|
||||
data = 2
|
@@ -102,7 +102,14 @@ class Python35Parser(Python34Parser):
|
||||
|
||||
return_if_stmt ::= ret_expr RETURN_END_IF POP_BLOCK
|
||||
|
||||
jb_else ::= JUMP_BACK ELSE
|
||||
ifelsestmtc ::= testexpr c_stmts_opt JUMP_FORWARD else_suitec
|
||||
ifelsestmtl ::= testexpr c_stmts_opt jb_else else_suitel
|
||||
|
||||
# 3.5 Has jump optimization which can route the end of an
|
||||
# "if/then" back to to a loop just before an else.
|
||||
jump_absolute_else ::= jb_else
|
||||
jump_absolute_else ::= CONTINUE ELSE
|
||||
|
||||
# ifstmt ::= testexpr c_stmts_opt
|
||||
|
||||
|
@@ -910,7 +910,8 @@ class Scanner3(Scanner):
|
||||
if offset in self.ignore_if:
|
||||
return
|
||||
|
||||
if (code[pre_rtarget] == self.opc.JUMP_ABSOLUTE and
|
||||
rtarget_is_ja = code[pre_rtarget] == self.opc.JUMP_ABSOLUTE
|
||||
if ( rtarget_is_ja and
|
||||
pre_rtarget in self.stmts and
|
||||
pre_rtarget != offset and
|
||||
prev_op[pre_rtarget] != offset and
|
||||
@@ -930,10 +931,13 @@ class Scanner3(Scanner):
|
||||
# or a conditional assignment like:
|
||||
# x = 1 if x else 2
|
||||
#
|
||||
# For 3.5, in addition the JUMP_FORWARD above we could have
|
||||
# JUMP_BACK or CONTINUE
|
||||
#
|
||||
# There are other contexts we may need to consider
|
||||
# like whether the target is "END_FINALLY"
|
||||
# or if the condition jump is to a forward location
|
||||
if self.is_jump_forward(pre_rtarget):
|
||||
if self.is_jump_forward(pre_rtarget) or (rtarget_is_ja and self.version >= 3.5):
|
||||
if_end = self.get_target(pre_rtarget)
|
||||
|
||||
# If the jump target is back, we are looping
|
||||
|
Reference in New Issue
Block a user