diff --git a/test/bytecode_3.2/11_if_while_bug.pyc b/test/bytecode_3.2/11_if_while_bug.pyc new file mode 100644 index 00000000..719b3b6b Binary files /dev/null and b/test/bytecode_3.2/11_if_while_bug.pyc differ diff --git a/test/simple_source/looping/11_if_while_bug.py b/test/simple_source/looping/11_if_while_bug.py new file mode 100644 index 00000000..f37a599a --- /dev/null +++ b/test/simple_source/looping/11_if_while_bug.py @@ -0,0 +1,9 @@ +# Python < 3.5 bug in not getting jumps with +# end of loop inside the if +def _splitext(p, sep, altsep, extsep): + if p > sep: + while sep < p: + if p[sep:sep+1] != extsep: + return p[:sep], p[sep:] + altsep += 1 + return p, p[:0] diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 801078e0..462f1251 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -182,6 +182,34 @@ class PythonParser(GenericASTBuilder): for_block POP_BLOCK else_suitel _come_from """ + def p_whilestmt(self, args): + """ + whilestmt ::= SETUP_LOOP + testexpr + l_stmts_opt JUMP_BACK + POP_BLOCK _come_from + + whilestmt ::= SETUP_LOOP + testexpr + return_stmts + POP_BLOCK COME_FROM + + while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM + while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM + while1stmt ::= SETUP_LOOP return_stmts COME_FROM + + while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM + whileelsestmt ::= SETUP_LOOP testexpr + l_stmts_opt JUMP_BACK + POP_BLOCK + else_suite COME_FROM + + whileelselaststmt ::= SETUP_LOOP testexpr + l_stmts_opt JUMP_BACK + POP_BLOCK + else_suitec COME_FROM + """ + def p_import20(self, args): ''' stmt ::= importstmt diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index 7f921558..dc8c0d40 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -318,30 +318,6 @@ class Python2Parser(PythonParser): POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY - whilestmt ::= SETUP_LOOP - testexpr - l_stmts_opt JUMP_BACK - POP_BLOCK COME_FROM - - whilestmt ::= SETUP_LOOP - testexpr - return_stmts - POP_BLOCK COME_FROM - - while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM - while1stmt ::= SETUP_LOOP return_stmts COME_FROM - while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM - - while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM - whileelsestmt ::= SETUP_LOOP testexpr - l_stmts_opt JUMP_BACK - POP_BLOCK - else_suite COME_FROM - - whileelselaststmt ::= SETUP_LOOP testexpr - l_stmts_opt JUMP_BACK - POP_BLOCK - else_suitec COME_FROM ''' def p_expr2(self, args): diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 8df27b34..59f5c78b 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -328,29 +328,6 @@ class Python3Parser(PythonParser): POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY - whilestmt ::= SETUP_LOOP - testexpr - l_stmts_opt JUMP_BACK - POP_BLOCK _come_from - - whilestmt ::= SETUP_LOOP - testexpr - return_stmts - POP_BLOCK COME_FROM - - while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM - while1stmt ::= SETUP_LOOP return_stmts COME_FROM - - while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM - whileelsestmt ::= SETUP_LOOP testexpr - l_stmts_opt JUMP_BACK - POP_BLOCK - else_suite COME_FROM - - whileelselaststmt ::= SETUP_LOOP testexpr - l_stmts_opt JUMP_BACK - POP_BLOCK - else_suitec COME_FROM ''' def p_genexpr3(self, args):