diff --git a/test/bytecode_3.3/10_while1_popblock.pyc b/test/bytecode_3.3/10_while1_popblock.pyc new file mode 100644 index 00000000..1dd6eb6d Binary files /dev/null and b/test/bytecode_3.3/10_while1_popblock.pyc differ diff --git a/test/bytecode_3.4/10_while1_popblock.pyc b/test/bytecode_3.4/10_while1_popblock.pyc new file mode 100644 index 00000000..e8eb908d Binary files /dev/null and b/test/bytecode_3.4/10_while1_popblock.pyc differ diff --git a/test/simple_source/bug33/10_while1_popblock.py b/test/simple_source/bug33/10_while1_popblock.py new file mode 100644 index 00000000..3219141b --- /dev/null +++ b/test/simple_source/bug33/10_while1_popblock.py @@ -0,0 +1,17 @@ +# From 3.4.4 mailcap.py +# Bug was needing a grammar rule to add POP_BLOCK before the end of the while1. +# 3.3 apparently doesn't add this. +def readmailcapfile(line): + while 1: + if not line: break + if line[0] == '#' or line.strip() == '': + continue + if not line: + continue + for j in range(3): + line[j] = line[j].strip() + if '/' in line: + line['/'].append('a') + else: + line['/'] = 'a' + return diff --git a/uncompyle6/parsers/parse34.py b/uncompyle6/parsers/parse34.py index e1259a9a..6ec70252 100644 --- a/uncompyle6/parsers/parse34.py +++ b/uncompyle6/parsers/parse34.py @@ -1,4 +1,17 @@ -# Copyright (c) 2017 Rocky Bernstein +# Copyright (c) 2017-2018 Rocky Bernstein + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . """ spark grammar differences over Python 3.3 for Python 3.4 """ @@ -18,6 +31,9 @@ class Python34Parser(Python33Parser): expr ::= LOAD_ASSERT + while1stmt ::= SETUP_LOOP l_stmts + COME_FROM JUMP_BACK POP_BLOCK COME_FROM_LOOP + # FIXME the below masks a bug in not detecting COME_FROM_LOOP # grammar rules with COME_FROM -> COME_FROM_LOOP already exist whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK @@ -30,8 +46,9 @@ class Python34Parser(Python33Parser): """ def customize_grammar_rules(self, tokens, customize): - # self.remove_rules(""" - # """) + self.remove_rules(""" + while1stmt ::= SETUP_LOOP l_stmts COME_FROM JUMP_BACK COME_FROM_LOOP + """) super(Python34Parser, self).customize_grammar_rules(tokens, customize) return