X Tutup
Skip to content

Commit 31413be

Browse files
committed
Python 2.2 doesn't have opcode LIST_APPEND
1 parent 98a6f47 commit 31413be

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed
924 Bytes
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# From decompyle
2+
# In Python 2.2 we don't have op LIST_APPEND while in > 2.3 we do.
3+
4+
from __future__ import generators
5+
6+
def inorder(t):
7+
if t:
8+
for x in inorder(t.left):
9+
yield x
10+
11+
yield t.label
12+
for x in inorder(t.right):
13+
yield x
14+
15+
def generate_ints(n):
16+
for i in range(n):
17+
yield i * 2
18+
19+
for i in generate_ints(5):
20+
print i,
21+
22+
print
23+
gen = generate_ints(3)
24+
print gen.next(), gen.next(), gen.next(), gen.next()

uncompyle6/scanners/scanner2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ def build_stmt_indices(self):
381381
j = self.prev[s]
382382
while code[j] == self.opc.JUMP_ABSOLUTE:
383383
j = self.prev[j]
384-
if code[j] == self.opc.LIST_APPEND: # list comprehension
384+
if (self.version >= 2.3 and
385+
code[j] == self.opc.LIST_APPEND): # list comprehension
385386
stmts.remove(s)
386387
continue
387388
elif code[s] == self.opc.POP_TOP and code[self.prev[s]] == self.opc.ROT_TWO:

0 commit comments

Comments
 (0)
X Tutup