Python 2.2 doesn't have opcode LIST_APPEND

This commit is contained in:
rocky 2016-08-16 12:45:43 -04:00
parent 98a6f47ad6
commit 31413be7a1
3 changed files with 26 additions and 1 deletions

Binary file not shown.

View File

@ -0,0 +1,24 @@
# From decompyle
# In Python 2.2 we don't have op LIST_APPEND while in > 2.3 we do.
from __future__ import generators
def inorder(t):
if t:
for x in inorder(t.left):
yield x
yield t.label
for x in inorder(t.right):
yield x
def generate_ints(n):
for i in range(n):
yield i * 2
for i in generate_ints(5):
print i,
print
gen = generate_ints(3)
print gen.next(), gen.next(), gen.next(), gen.next()

View File

@ -381,7 +381,8 @@ class Scanner2(scan.Scanner):
j = self.prev[s]
while code[j] == self.opc.JUMP_ABSOLUTE:
j = self.prev[j]
if code[j] == self.opc.LIST_APPEND: # list comprehension
if (self.version >= 2.3 and
code[j] == self.opc.LIST_APPEND): # list comprehension
stmts.remove(s)
continue
elif code[s] == self.opc.POP_TOP and code[self.prev[s]] == self.opc.ROT_TWO: