From 22dee55ff7fb363d372efe2053b1d069e8ac86eb Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 8 Oct 2016 19:51:17 -0400 Subject: [PATCH] Python 2.1-2.6 bug in list comprehension --- ...ons.pyc-notyet => test_listComprehensions.pyc} | Bin test/bytecode_2.6/06_list_comprehension_x2_if.pyc | Bin 0 -> 297 bytes .../bug22/06_list_comprehension_x2_if.py | 11 +++++++++++ uncompyle6/parsers/parse22.py | 4 ++++ uncompyle6/parsers/parse26.py | 1 + 5 files changed, 16 insertions(+) rename test/bytecode_2.1/{test_listComprehensions.pyc-notyet => test_listComprehensions.pyc} (100%) create mode 100644 test/bytecode_2.6/06_list_comprehension_x2_if.pyc create mode 100644 test/simple_source/bug22/06_list_comprehension_x2_if.py diff --git a/test/bytecode_2.1/test_listComprehensions.pyc-notyet b/test/bytecode_2.1/test_listComprehensions.pyc similarity index 100% rename from test/bytecode_2.1/test_listComprehensions.pyc-notyet rename to test/bytecode_2.1/test_listComprehensions.pyc diff --git a/test/bytecode_2.6/06_list_comprehension_x2_if.pyc b/test/bytecode_2.6/06_list_comprehension_x2_if.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bbc7a50764392ff2b432d339e39f68313b32c078 GIT binary patch literal 297 zcmYL_!Arw16vn@#RfjNiGTgt=Q>Q(6QN)9wr@`Eb;85msvJFyHJ(&K^3lUJM&^1Z(XC_GG(9B Y_B{;f*j4RxUzuz6o_}K^hT>TK0uT{42mk;8 literal 0 HcmV?d00001 diff --git a/test/simple_source/bug22/06_list_comprehension_x2_if.py b/test/simple_source/bug22/06_list_comprehension_x2_if.py new file mode 100644 index 00000000..3e45e3cc --- /dev/null +++ b/test/simple_source/bug22/06_list_comprehension_x2_if.py @@ -0,0 +1,11 @@ +# listComprehensions.py -- source test pattern for list comprehensions +# +# This simple program is part of the decompyle test suite. +# +# decompyle is a Python byte-code decompiler +# See http://www.goebel-consult.de/decompyle/ for further information + +print [i*j for i in range(4) + if i == 2 + for j in range(7) + if (i+i % 2) == 0 ] diff --git a/uncompyle6/parsers/parse22.py b/uncompyle6/parsers/parse22.py index ffa9e53f..4ea7039e 100644 --- a/uncompyle6/parsers/parse22.py +++ b/uncompyle6/parsers/parse22.py @@ -14,6 +14,10 @@ class Python22Parser(Python23Parser): def p_misc22(self, args): ''' _for ::= LOAD_CONST FOR_LOOP + list_iter ::= list_if JUMP_FORWARD + COME_FROM POP_TOP COME_FROM + list_for ::= expr _for designator list_iter CONTINUE JUMP_FORWARD + COME_FROM POP_TOP COME_FROM ''' class Python22ParserSingle(Python23Parser, PythonParserSingle): diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index c6bd47b4..0f975d66 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -170,6 +170,7 @@ class Python26Parser(Python2Parser): list_for ::= expr _for designator list_iter jb_cont list_iter ::= list_if JUMP_BACK + list_iter ::= list_if JUMP_BACK COME_FROM POP_TOP list_compr ::= BUILD_LIST_0 DUP_TOP designator list_iter del_stmt list_compr ::= BUILD_LIST_0 DUP_TOP