diff --git a/test/bytecode_3.5/07_if_return_bug.pyc b/test/bytecode_3.5/07_if_return_bug.pyc new file mode 100644 index 00000000..62725093 Binary files /dev/null and b/test/bytecode_3.5/07_if_return_bug.pyc differ diff --git a/test/simple_source/branching/07_if_return_bug.py b/test/simple_source/branching/07_if_return_bug.py new file mode 100644 index 00000000..6ca84a74 --- /dev/null +++ b/test/simple_source/branching/07_if_return_bug.py @@ -0,0 +1,31 @@ +# From 3.5.1 bdb +# +# RETURN_VALUES can get turned in RETURN_END_IF +# scanner3's detect_structure sometimes can't +# fully handle Python 3.5's jump optimization +# So in 3.5, for now, we allow: +# +# return_stmt ::= ret_expr RETURN_END_IF +# and you see that in the grammar rules for below. + +# For other pythons the RETURN_END_IF may be a +# RETURN_VALUE. +# Or it may be that we may want to add that +# additional return_stmt grammar rule for Pythons +# before 3.5 which currently isn't needed. + +def effective(line): + for b in line: + if not b.cond: + return + else: + try: + val = 5 + if val: + if b.ignore: + b.ignore -= 1 + else: + return (b, True) + except: + return (b, False) + return diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 038f4cab..510e02a7 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -594,6 +594,11 @@ class Python35onParser(Python3Parser): WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY + # Python 3.5+_ does jump optimization that scanner3.py's detect + # structure can't fully work out. So for now let's allow + # RETURN_END_IF the same as RETURN_VAL + return_stmt ::= ret_expr RETURN_END_IF + # Python 3.3+ also has yield from. 3.5 does it # differently than 3.3, 3.4