You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Fix whileelse bug
This commit is contained in:
BIN
test/bytecode_2.6/03_whileelse_bug.pyc
Normal file
BIN
test/bytecode_2.6/03_whileelse_bug.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_2.7/03_whileelse_bug.pyc
Normal file
BIN
test/bytecode_2.7/03_whileelse_bug.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.3/03_whileelse_bug.pyc
Normal file
BIN
test/bytecode_3.3/03_whileelse_bug.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.4/03_whileelse_bug.pyc
Normal file
BIN
test/bytecode_3.4/03_whileelse_bug.pyc
Normal file
Binary file not shown.
9
test/simple_source/looping/03_whileelse_bug.py
Normal file
9
test/simple_source/looping/03_whileelse_bug.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# From idlelib/PyParse.py
|
||||||
|
# Bug is "if" inside a nested while/else.
|
||||||
|
def _study1(i, n):
|
||||||
|
while i:
|
||||||
|
while i:
|
||||||
|
i = 0
|
||||||
|
else:
|
||||||
|
if i:
|
||||||
|
i = 1
|
@@ -142,8 +142,8 @@ class Python26Parser(Python2Parser):
|
|||||||
whilestmt ::= SETUP_LOOP testexpr returns POP_BLOCK COME_FROM
|
whilestmt ::= SETUP_LOOP testexpr returns POP_BLOCK COME_FROM
|
||||||
|
|
||||||
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_pop POP_BLOCK
|
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_pop POP_BLOCK
|
||||||
else_suite COME_FROM
|
else_suitel COME_FROM
|
||||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM
|
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suitel COME_FROM
|
||||||
|
|
||||||
return ::= ret_expr RETURN_END_IF POP_TOP
|
return ::= ret_expr RETURN_END_IF POP_TOP
|
||||||
return ::= ret_expr RETURN_VALUE POP_TOP
|
return ::= ret_expr RETURN_VALUE POP_TOP
|
||||||
|
@@ -120,9 +120,9 @@ class Python27Parser(Python2Parser):
|
|||||||
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM
|
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM
|
||||||
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK _come_froms
|
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK _come_froms
|
||||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK
|
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK
|
||||||
else_suite COME_FROM
|
else_suitel COME_FROM
|
||||||
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
||||||
else_suite COME_FROM
|
else_suitel COME_FROM
|
||||||
|
|
||||||
ifstmt ::= testexpr return_if_stmts COME_FROM
|
ifstmt ::= testexpr return_if_stmts COME_FROM
|
||||||
ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD else_suite COME_FROM
|
ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD else_suite COME_FROM
|
||||||
|
@@ -347,10 +347,10 @@ class Python3Parser(PythonParser):
|
|||||||
COME_FROM_LOOP
|
COME_FROM_LOOP
|
||||||
|
|
||||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK
|
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK
|
||||||
else_suite
|
else_suitel
|
||||||
|
|
||||||
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
||||||
else_suite COME_FROM_LOOP
|
else_suitel COME_FROM_LOOP
|
||||||
|
|
||||||
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK
|
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK
|
||||||
COME_FROM_LOOP
|
COME_FROM_LOOP
|
||||||
|
@@ -19,9 +19,9 @@ class Python34Parser(Python33Parser):
|
|||||||
|
|
||||||
|
|
||||||
# FIXME the below masks a bug in not detecting COME_FROM_LOOP
|
# FIXME the below masks a bug in not detecting COME_FROM_LOOP
|
||||||
# grammar rules with COME_FROM -> COME_FROM_LOOP alreadly exist
|
# grammar rules with COME_FROM -> COME_FROM_LOOP already exist
|
||||||
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
|
||||||
else_suite COME_FROM
|
else_suitel COME_FROM
|
||||||
|
|
||||||
# Python 3.4+ optimizes the trailing two JUMPS away
|
# Python 3.4+ optimizes the trailing two JUMPS away
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user