You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
fixes 151
This commit is contained in:
BIN
test/bytecode_2.7/05_while_if_continue.pyc
Normal file
BIN
test/bytecode_2.7/05_while_if_continue.pyc
Normal file
Binary file not shown.
11
test/simple_source/bug27+/05_while_if_continue.py
Normal file
11
test/simple_source/bug27+/05_while_if_continue.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Issue 151 for Python 2.7
|
||||||
|
# Bug was two-fold. Not having a rile for a while loop with an ending return statement
|
||||||
|
# and allowing iflastsmtl to have an optional c_stmt which allowed the "if" to get
|
||||||
|
# comined into the "while". A separate analysis for control flow should make this
|
||||||
|
# simpiler.
|
||||||
|
def func(a, b, c):
|
||||||
|
while a:
|
||||||
|
if b:
|
||||||
|
continue
|
||||||
|
return False
|
||||||
|
return True
|
@@ -323,7 +323,7 @@ class PythonParser(GenericASTBuilder):
|
|||||||
stmt ::= return
|
stmt ::= return
|
||||||
return ::= ret_expr RETURN_VALUE
|
return ::= ret_expr RETURN_VALUE
|
||||||
|
|
||||||
# returns are a sequence of statements that ends in a RETURN statement.
|
# "returns" nonterminal is a sequence of statements that ends in a RETURN statement.
|
||||||
# In later Python versions with jump optimization, this can cause JUMPs
|
# In later Python versions with jump optimization, this can cause JUMPs
|
||||||
# that would normally appear to be omitted.
|
# that would normally appear to be omitted.
|
||||||
|
|
||||||
|
@@ -64,9 +64,9 @@ class Python27Parser(Python2Parser):
|
|||||||
|
|
||||||
def p_jump27(self, args):
|
def p_jump27(self, args):
|
||||||
"""
|
"""
|
||||||
iflaststmtl ::= testexpr c_stmts_opt
|
iflaststmtl ::= testexpr c_stmts
|
||||||
|
|
||||||
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD come_froms
|
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD come_froms
|
||||||
bp_come_from ::= POP_BLOCK COME_FROM
|
bp_come_from ::= POP_BLOCK COME_FROM
|
||||||
|
|
||||||
# FIXME: Common with 3.0+
|
# FIXME: Common with 3.0+
|
||||||
@@ -119,6 +119,8 @@ class Python27Parser(Python2Parser):
|
|||||||
POP_BLOCK LOAD_CONST COME_FROM_WITH
|
POP_BLOCK LOAD_CONST COME_FROM_WITH
|
||||||
WITH_CLEANUP END_FINALLY
|
WITH_CLEANUP END_FINALLY
|
||||||
|
|
||||||
|
whilestmt ::= SETUP_LOOP testexpr returns POP_BLOCK COME_FROM
|
||||||
|
|
||||||
while1stmt ::= SETUP_LOOP returns bp_come_from
|
while1stmt ::= SETUP_LOOP returns bp_come_from
|
||||||
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
|
||||||
|
Reference in New Issue
Block a user