diff --git a/test/bytecode_2.5/01_inplace_true_divide.pyc b/test/bytecode_2.5/01_inplace_true_divide.pyc new file mode 100644 index 00000000..ce7c8daa Binary files /dev/null and b/test/bytecode_2.5/01_inplace_true_divide.pyc differ diff --git a/test/bytecode_2.5/01_ops.pyc b/test/bytecode_2.5/01_ops.pyc new file mode 100644 index 00000000..569dc0eb Binary files /dev/null and b/test/bytecode_2.5/01_ops.pyc differ diff --git a/test/bytecode_2.5/02_true_divide.pyc b/test/bytecode_2.5/02_true_divide.pyc new file mode 100644 index 00000000..f0dacfe6 Binary files /dev/null and b/test/bytecode_2.5/02_true_divide.pyc differ diff --git a/test/bytecode_2.5/08_if_while_else.pyc b/test/bytecode_2.5/08_if_while_else.pyc new file mode 100644 index 00000000..ef12ea3d Binary files /dev/null and b/test/bytecode_2.5/08_if_while_else.pyc differ diff --git a/test/bytecode_2.5/10_del.pyc b/test/bytecode_2.5/10_del.pyc new file mode 100644 index 00000000..d7edcefa Binary files /dev/null and b/test/bytecode_2.5/10_del.pyc differ diff --git a/test/simple_source/bug25/08_if_while_else.py b/test/simple_source/bug25/08_if_while_else.py new file mode 100644 index 00000000..df65657c --- /dev/null +++ b/test/simple_source/bug25/08_if_while_else.py @@ -0,0 +1,13 @@ +# From 2.3 Queue.py +# Bug was adding COME_FROM from while +# confusing the else +def put(item, block=True, timeout=None): + if block: + if timeout: + while True: + if item: + block = 1 + else: + block = 5 + elif item: + block = False diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index 945aeab8..8af0bb0d 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -115,8 +115,7 @@ class Python26Parser(Python2Parser): # Semantic actions want else_suitel to be at index 3 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 withstmt ::= expr setupwith SETUP_FINALLY suite_stmts_opt diff --git a/uncompyle6/scanners/scanner2.py b/uncompyle6/scanners/scanner2.py index 2fb6f207..7616d9a9 100644 --- a/uncompyle6/scanners/scanner2.py +++ b/uncompyle6/scanners/scanner2.py @@ -1127,7 +1127,13 @@ class Scanner2(Scanner): source = self.setup_loops[label] else: source = offset - targets[label] = targets.get(label, []) + [source] + # FIXME: The grammar for 2.6 and before doesn't + # handle COME_FROM's from a loop inside if's + # It probably should. + if (self.version > 2.6 or + self.code[source] != self.opc.SETUP_LOOP or + self.code[label] != self.opc.JUMP_FORWARD): + targets[label] = targets.get(label, []) + [source] pass pass pass