This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients Jakob.Bowyer, Ramchandra Apte, alexandre.vassalotti, r.david.murray, rhettinger, terry.reedy
Date 2012-03-24.23:23:26
SpamBayes Score 2.1503132e-07
Marked as misclassified No
Message-id <1332631407.41.0.314452603948.issue14350@psf.upfronthosting.co.za>
In-reply-to
Content
Title corrected. Non-iterator iterables are usually easy to copy.
I think this is in the category of "don't do that" ;-)

I believe the idea of making iterators copyable has been rejected on one of the lists because it is probably not possible in general.
Tee consumes indefinite and unbounded space. Its use should be explicit. If a function needs to iterate more than once with an input iterable, it should explicitly do list(iterator) for iterator inputs.
See Raymond's comments, such as msg156720 in #14288.

So I suspect that raising an error for copy.copy(iter([])) is correct. The error message amounts to saying make a new instance with the class constructor. That is usually correct when copy is not possible, but not in this case. ListIterator.__new__ is the inherited object.__new__. It appears that ListIterators can only be constructed by list.__iter__. But I doubt that the code that raises the error message can know that.
But perhaps the error message can be improved anyway.
History
Date User Action Args
2012-03-24 23:23:27terry.reedysetrecipients: + terry.reedy, rhettinger, alexandre.vassalotti, r.david.murray, Jakob.Bowyer, Ramchandra Apte
2012-03-24 23:23:27terry.reedysetmessageid: <1332631407.41.0.314452603948.issue14350@psf.upfronthosting.co.za>
2012-03-24 23:23:26terry.reedylinkissue14350 messages
2012-03-24 23:23:26terry.reedycreate