Python 2.1-2.6 bug in list comprehension

This commit is contained in:
rocky
2016-10-08 19:51:17 -04:00
parent 8916447adb
commit 22dee55ff7
5 changed files with 16 additions and 0 deletions

Binary file not shown.

View File

@@ -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 ]

View File

@@ -14,6 +14,10 @@ class Python22Parser(Python23Parser):
def p_misc22(self, args): def p_misc22(self, args):
''' '''
_for ::= LOAD_CONST FOR_LOOP _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): class Python22ParserSingle(Python23Parser, PythonParserSingle):

View File

@@ -170,6 +170,7 @@ class Python26Parser(Python2Parser):
list_for ::= expr _for designator list_iter jb_cont list_for ::= expr _for designator list_iter jb_cont
list_iter ::= list_if JUMP_BACK list_iter ::= list_if JUMP_BACK
list_iter ::= list_if JUMP_BACK COME_FROM POP_TOP
list_compr ::= BUILD_LIST_0 DUP_TOP list_compr ::= BUILD_LIST_0 DUP_TOP
designator list_iter del_stmt designator list_iter del_stmt
list_compr ::= BUILD_LIST_0 DUP_TOP list_compr ::= BUILD_LIST_0 DUP_TOP