diff --git a/test/bytecode_2.2/05_test_yield.pyc b/test/bytecode_2.2/05_test_yield.pyc new file mode 100644 index 00000000..8395d44b Binary files /dev/null and b/test/bytecode_2.2/05_test_yield.pyc differ diff --git a/test/simple_source/bug22/05_test_yield.py b/test/simple_source/bug22/05_test_yield.py new file mode 100644 index 00000000..4bdc5b94 --- /dev/null +++ b/test/simple_source/bug22/05_test_yield.py @@ -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() diff --git a/uncompyle6/scanners/scanner2.py b/uncompyle6/scanners/scanner2.py index 0d7c7645..c14f51c2 100755 --- a/uncompyle6/scanners/scanner2.py +++ b/uncompyle6/scanners/scanner2.py @@ -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: