diff --git a/test/bytecode_3.5_run/01_loop_if_continue.pyc b/test/bytecode_3.5_run/01_loop_if_continue.pyc new file mode 100644 index 00000000..f699a244 Binary files /dev/null and b/test/bytecode_3.5_run/01_loop_if_continue.pyc differ diff --git a/test/simple_source/bug35/01_loop_if_continue.py b/test/simple_source/bug35/01_loop_if_continue.py new file mode 100644 index 00000000..c6e57b92 --- /dev/null +++ b/test/simple_source/bug35/01_loop_if_continue.py @@ -0,0 +1,13 @@ +# From 3.6.4 pathlib.py +# Bug was handling "continue" as last statement of "if" +# RUNNABLE! +def parse_parts(it, parts): + for part in it: + if not part: + continue + parts = 1 + return parts + +assert parse_parts([], 5) == 5 +assert parse_parts([True], 6) == 1 +assert parse_parts([False], 6) == 6 diff --git a/uncompyle6/parsers/parse35.py b/uncompyle6/parsers/parse35.py index 3e2a1fa6..5358d464 100644 --- a/uncompyle6/parsers/parse35.py +++ b/uncompyle6/parsers/parse35.py @@ -111,6 +111,12 @@ class Python35Parser(Python34Parser): jump_absolute_else ::= jb_else jump_absolute_else ::= CONTINUE ELSE + # Our hacky "ELSE" determination doesn't do a good job and really + # determine the start of an "else". It could also be the end of an + # "if-then" which ends in a "continue". Perhaps with real control-flow + # analysis we'll sort this out. Or call "ELSE" something more appropriate. + _ifstmts_jump ::= c_stmts_opt ELSE + # ifstmt ::= testexpr c_stmts_opt iflaststmt ::= testexpr c_stmts_opt JUMP_FORWARD