You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Loops in Python 2.4-2.6 loop come_from
Looks like Python 2.4-2.6 may have a COME_FROM(_LOOP) before the jump_back. Fixes Issue #123
This commit is contained in:
BIN
test/bytecode_2.6/03_loop_if_cf.pyc
Normal file
BIN
test/bytecode_2.6/03_loop_if_cf.pyc
Normal file
Binary file not shown.
19
test/simple_source/bug26/03_loop_if_cf.py
Normal file
19
test/simple_source/bug26/03_loop_if_cf.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Bug in < 2.6 is having a COME_FROM_LOOP (but we
|
||||||
|
# don't tag that so it is just COME_FROM *before*
|
||||||
|
# a jump back to the loop.
|
||||||
|
def pickup(self, open_players, open_buf, wrap_buf):
|
||||||
|
for aplayer in self._game.active_players:
|
||||||
|
|
||||||
|
if aplayer in open_players:
|
||||||
|
aplayer.send(open_players)
|
||||||
|
|
||||||
|
if self == aplayer:
|
||||||
|
for awatcher in self._watchers:
|
||||||
|
if awatcher._can_see_detail:
|
||||||
|
awatcher.send(open_buf)
|
||||||
|
else:
|
||||||
|
awatcher.send(wrap_buf)
|
||||||
|
else:
|
||||||
|
self._game.send(aplayer.side)
|
||||||
|
else:
|
||||||
|
self._game.send(aplayer.side, wrap_buf)
|
@@ -84,6 +84,12 @@ class Python26Parser(Python2Parser):
|
|||||||
ja_cf_pop ::= JUMP_ABSOLUTE come_froms POP_TOP
|
ja_cf_pop ::= JUMP_ABSOLUTE come_froms POP_TOP
|
||||||
jf_cf_pop ::= JUMP_FORWARD come_froms POP_TOP
|
jf_cf_pop ::= JUMP_FORWARD come_froms POP_TOP
|
||||||
|
|
||||||
|
# The first optional COME_FROM when it appears is really
|
||||||
|
# COME_FROM_LOOP, but in <= 2.6 we don't distinguish
|
||||||
|
# this
|
||||||
|
|
||||||
|
cf_jb_cf_pop ::= _come_from JUMP_BACK come_froms POP_TOP
|
||||||
|
|
||||||
bp_come_from ::= POP_BLOCK COME_FROM
|
bp_come_from ::= POP_BLOCK COME_FROM
|
||||||
jb_bp_come_from ::= JUMP_BACK bp_come_from
|
jb_bp_come_from ::= JUMP_BACK bp_come_from
|
||||||
|
|
||||||
@@ -111,7 +117,8 @@ class Python26Parser(Python2Parser):
|
|||||||
break_stmt ::= BREAK_LOOP JUMP_BACK
|
break_stmt ::= BREAK_LOOP JUMP_BACK
|
||||||
|
|
||||||
# Semantic actions want else_suitel to be at index 3
|
# Semantic actions want else_suitel to be at index 3
|
||||||
ifelsestmtl ::= testexpr c_stmts_opt jb_cf_pop else_suitel
|
ifelsestmtl ::= testexpr c_stmts_opt cf_jb_cf_pop else_suitel
|
||||||
|
|
||||||
ifelsestmtc ::= testexpr c_stmts_opt ja_cf_pop else_suitec
|
ifelsestmtc ::= testexpr c_stmts_opt ja_cf_pop else_suitec
|
||||||
|
|
||||||
# Semantic actions want suite_stmts_opt to be at index 3
|
# Semantic actions want suite_stmts_opt to be at index 3
|
||||||
|
Reference in New Issue
Block a user