diff --git a/test/bytecode_2.6/03_loop_if_cf.pyc b/test/bytecode_2.6/03_loop_if_cf.pyc new file mode 100644 index 00000000..880855af Binary files /dev/null and b/test/bytecode_2.6/03_loop_if_cf.pyc differ diff --git a/test/simple_source/bug26/03_loop_if_cf.py b/test/simple_source/bug26/03_loop_if_cf.py new file mode 100644 index 00000000..b4f85870 --- /dev/null +++ b/test/simple_source/bug26/03_loop_if_cf.py @@ -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) diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index 70611f0d..c8561d59 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -84,6 +84,12 @@ class Python26Parser(Python2Parser): ja_cf_pop ::= JUMP_ABSOLUTE 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 jb_bp_come_from ::= JUMP_BACK bp_come_from @@ -111,7 +117,8 @@ class Python26Parser(Python2Parser): break_stmt ::= BREAK_LOOP JUMP_BACK # 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 # Semantic actions want suite_stmts_opt to be at index 3