X Tutup
Skip to content

Commit 22dee55

Browse files
committed
Python 2.1-2.6 bug in list comprehension
1 parent 8916447 commit 22dee55

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed
File renamed without changes.
297 Bytes
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# listComprehensions.py -- source test pattern for list comprehensions
2+
#
3+
# This simple program is part of the decompyle test suite.
4+
#
5+
# decompyle is a Python byte-code decompiler
6+
# See http://www.goebel-consult.de/decompyle/ for further information
7+
8+
print [i*j for i in range(4)
9+
if i == 2
10+
for j in range(7)
11+
if (i+i % 2) == 0 ]

uncompyle6/parsers/parse22.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
1414
def p_misc22(self, args):
1515
'''
1616
_for ::= LOAD_CONST FOR_LOOP
17+
list_iter ::= list_if JUMP_FORWARD
18+
COME_FROM POP_TOP COME_FROM
19+
list_for ::= expr _for designator list_iter CONTINUE JUMP_FORWARD
20+
COME_FROM POP_TOP COME_FROM
1721
'''
1822

1923
class Python22ParserSingle(Python23Parser, PythonParserSingle):

uncompyle6/parsers/parse26.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def p_comp26(self, args):
170170
list_for ::= expr _for designator list_iter jb_cont
171171
172172
list_iter ::= list_if JUMP_BACK
173+
list_iter ::= list_if JUMP_BACK COME_FROM POP_TOP
173174
list_compr ::= BUILD_LIST_0 DUP_TOP
174175
designator list_iter del_stmt
175176
list_compr ::= BUILD_LIST_0 DUP_TOP

0 commit comments

Comments
 (0)
X Tutup