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.4+ while handling with returns ...
these while loops don't have a JUMP_BACK in them
This commit is contained in:
Binary file not shown.
BIN
test/bytecode_3.4_run/06_while_return.pyc
Normal file
BIN
test/bytecode_3.4_run/06_while_return.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.5_run/06_while_return.pyc
Normal file
BIN
test/bytecode_3.5_run/06_while_return.pyc
Normal file
Binary file not shown.
@@ -1,28 +1,32 @@
|
||||
# From Python 3.4 asynchat.py
|
||||
# Tests presence or absense of
|
||||
# SETUP_LOOP testexpr return_stmts POP_BLOCK COME_FROM_LOOP
|
||||
# Note: that there is no JUMP_BACK because of the return_stmts.
|
||||
|
||||
def initiate_send(self, num_sent, first):
|
||||
while self.producer_fifo and self.connected:
|
||||
def initiate_send(a, b, c, num_sent):
|
||||
while a and b:
|
||||
try:
|
||||
5
|
||||
except OSError:
|
||||
return
|
||||
1 / (b - 1)
|
||||
except ZeroDivisionError:
|
||||
return 1
|
||||
|
||||
if num_sent:
|
||||
if first:
|
||||
self.producer_fifo = '6'
|
||||
else:
|
||||
del self.producer_fifo[0]
|
||||
return
|
||||
c = 2
|
||||
return c
|
||||
|
||||
|
||||
# FIXME: this causes a parse error:
|
||||
# def initiate_send(self):
|
||||
# while self.producer_fifo and self.connected:
|
||||
# try:
|
||||
# 6
|
||||
# except OSError:
|
||||
# return
|
||||
def initiate_send2(a, b):
|
||||
while a and b:
|
||||
try:
|
||||
1 / (b - 1)
|
||||
except ZeroDivisionError:
|
||||
return 1
|
||||
|
||||
# return
|
||||
return 2
|
||||
|
||||
assert initiate_send(1, 1, 2, False) == 1
|
||||
assert initiate_send(1, 2, 3, False) == 3
|
||||
assert initiate_send(1, 2, 3, True) == 2
|
||||
|
||||
assert initiate_send2(1, 1) == 1
|
||||
assert initiate_send2(1, 2) == 2
|
||||
|
@@ -99,7 +99,8 @@ class Python3Parser(PythonParser):
|
||||
|
||||
return_if_stmts ::= return_if_stmt come_from_opt
|
||||
return_if_stmts ::= _stmts return_if_stmt
|
||||
return_if_stmt ::= ret_expr RETURN_END_IF
|
||||
return_if_stmt ::= ret_expr RETURN_END_IF
|
||||
returns ::= _stmts return_if_stmt
|
||||
|
||||
stmt ::= break
|
||||
break ::= BREAK_LOOP
|
||||
|
@@ -34,6 +34,8 @@ class Python34Parser(Python33Parser):
|
||||
# passtmt is needed for semantic actions to add "pass"
|
||||
suite_stmts_opt ::= pass
|
||||
|
||||
whilestmt ::= SETUP_LOOP testexpr returns come_froms POP_BLOCK COME_FROM_LOOP
|
||||
|
||||
# Seems to be needed starting 3.4.4 or so
|
||||
while1stmt ::= SETUP_LOOP l_stmts
|
||||
COME_FROM JUMP_BACK POP_BLOCK COME_FROM_LOOP
|
||||
|
@@ -28,7 +28,6 @@ class Python35Parser(Python34Parser):
|
||||
while1stmt ::= SETUP_LOOP l_stmts POP_BLOCK COME_FROM_LOOP
|
||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK
|
||||
POP_BLOCK else_suite COME_FROM_LOOP
|
||||
whilestmt ::= SETUP_LOOP testexpr returns POP_BLOCK COME_FROM_LOOP
|
||||
|
||||
# The following rule is for Python 3.5+ where we can have stuff like
|
||||
# while ..
|
||||
@@ -106,7 +105,6 @@ class Python35Parser(Python34Parser):
|
||||
return_if_stmt ::= ret_expr RETURN_END_IF POP_BLOCK
|
||||
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM
|
||||
|
||||
|
||||
jb_else ::= JUMP_BACK ELSE
|
||||
ifelsestmtc ::= testexpr c_stmts_opt JUMP_FORWARD else_suitec
|
||||
ifelsestmtl ::= testexpr c_stmts_opt jb_else else_suitel
|
||||
|
Reference in New Issue
Block a user