diff --git a/test/bytecode_3.6_run/05_try_whiletrue.pyc b/test/bytecode_3.6_run/05_try_whiletrue.pyc new file mode 100644 index 00000000..d4cb224d Binary files /dev/null and b/test/bytecode_3.6_run/05_try_whiletrue.pyc differ diff --git a/test/simple_source/bug36/05_try_whiletrue.py b/test/simple_source/bug36/05_try_whiletrue.py new file mode 100644 index 00000000..faff860e --- /dev/null +++ b/test/simple_source/bug36/05_try_whiletrue.py @@ -0,0 +1,19 @@ +# From 3.6 _collections.abc.py +# Bug was try/execpt parsing detection since 3.6 removes +# a JUMP_FORWARD from earlier 3.xs. +# This could also get confused with try/else. + +# RUNNABLE! +def iter(self): + i = 0 + try: + while True: + v = self[i] + yield v + i += 1 + except IndexError: + return + + +A = [10, 20, 30] +assert list(iter(A)) == A diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 2d8d3f5d..c8eb80df 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -1155,7 +1155,9 @@ class Python3Parser(PythonParser): self.check_reduce['ifelsestmt'] = 'AST' self.check_reduce['annotate_tuple'] = 'noAST' self.check_reduce['kwarg'] = 'noAST' - self.check_reduce['try_except'] = 'AST' + if self.version < 3.6: + # 3.6+ can remove a JUMP_FORWARD which messes up our testing here + self.check_reduce['try_except'] = 'AST' # FIXME: remove parser errors caused by the below # self.check_reduce['while1elsestmt'] = 'noAST'