From 452d17a6c3accfaf5e0277de68786dfc298b3851 Mon Sep 17 00:00:00 2001 From: rocky Date: Thu, 1 Mar 2018 18:56:08 -0500 Subject: [PATCH] 3.4 while1 bug fix --- test/bytecode_3.3/10_while1_popblock.pyc | Bin 0 -> 577 bytes test/bytecode_3.4/10_while1_popblock.pyc | Bin 0 -> 453 bytes .../simple_source/bug33/10_while1_popblock.py | 17 +++++++++++++ uncompyle6/parsers/parse34.py | 23 +++++++++++++++--- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 test/bytecode_3.3/10_while1_popblock.pyc create mode 100644 test/bytecode_3.4/10_while1_popblock.pyc create mode 100644 test/simple_source/bug33/10_while1_popblock.py 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 0000000000000000000000000000000000000000..1dd6eb6d74914ce3eebd64c0f4c8f526afb2f9a2 GIT binary patch literal 577 zcmbVHze~eF82v73qezQ_4%$(dxL8YZE28LJ1P7rYB~8wHZJJzjJ*-ftIyyOsi~foJ z4ZiOp=+Mc#+~a*e-k0xv*6JJK>wE7@5XJQ8c;IJvW($zu6ZA~f1M%oO^pT7qafe&0 zco%r)12BK11!$eFGGYep9%N&WjL-3iXo;-Pnc{?|K9zmu{D;p&nh8oOv=nrC+n^`G zvIWMJ(lY2wyL6LOxik)_cyYg~qQ|2oV5z`lFx1i2;efFF8aC`I09kf$V3{g*(%ghR;9V?=2C~bgTq_xbFke%BKAXS-kx>1OT9N0rJqb53)eUsZFmd$}3w%g6t zasT07rLxu6xgMl>JU-Hob`#x&jFL&D(m2w0XyD1F0U+UvfGT2N1nzE&T~QM|UR|t` bbwl>Gs`9(se>Pml)XpSNY${LPYP{JuAe?M_ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..e8eb908d544dac1d6ae45f0310ba2d6909dbc623 GIT binary patch literal 453 zcmYjNF;Buk6n?MQR$~B7bWlcJ=pqv0MvO*hV!}W|Vo2$oSSamrClM2zaCCCf$=$zn zs}l=9z{z*51J`@6-+SNpy}Nc@D(}?ZKYMEg_<@b(5Wb|)dz3hBgjawb0S7t(i%6d@ zt8*!?DfAbm`3EcrmfduuffdV9 z-C!6n2CN(qpm4=x^~pFjI}h$TF5DyS;Nwu9oG VAGndq#F_2ZB;&J0T;$X2us=cQS^EG0 literal 0 HcmV?d00001 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