Message7530

Author zzzeek
Recipients zzzeek
Date 2012-11-19.17:47:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1353347245.59.0.874810035256.issue1991@psf.upfronthosting.co.za>
In-reply-to
Content
This might be limited to the itertools library, as I was not able to reproduce this using freeform iterator objects...nonetheless this is pretty core.

Propagation of iterator objects, at least in the case of itertools.chain(), appears to be broken:

from itertools import chain

class MyClass(object):
    def __iter__(self):
        return chain([1, 2, 3])


my_obj = MyClass()

print list(my_obj)  # python prints [1,2,3], jython prints []

chain_obj = my_obj.__iter__()

assert list(chain_obj) == list(my_obj)


Above, the "chain()" object returned by my_obj.__iter__() works fine and yields [1,2,3], however when my_obj itself is called in an iterator context, the iterator yields nothing.  The assertion at the end fails on Jython and passes on cPython.
History
Date User Action Args
2012-11-19 17:47:25zzzeeksetrecipients: + zzzeek
2012-11-19 17:47:25zzzeeksetmessageid: <1353347245.59.0.874810035256.issue1991@psf.upfronthosting.co.za>
2012-11-19 17:47:25zzzeeklinkissue1991 messages
2012-11-19 17:47:25zzzeekcreate