[issue14350] Strange Exception from copying an iterator

2015-11-12 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
dependencies:  -Restrict default pickleability
resolution:  -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder:  -> Restrict default pickleability

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14350] Strange Exception from copying an iterator

2015-09-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Actually the tp_new field of list iterator class is NULL. Unpickler raises 
other error in such case (see issue24900 for example).

UnpicklingError: NEWOBJ class argument has NULL tp_new

Backported to 2.7 the part of the patch for issue22995 fixes this issue.

>>> copy.copy(iter([]))
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/serhiy/py/cpython-2.7/Lib/copy.py", line 88, in copy
rv = reductor(2)
TypeError: can't pickle listiterator objects

--
dependencies: +Restrict default pickleability
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14350] Strange Exception from copying an iterator

2012-03-25 Thread Jakob Bowyer

Jakob Bowyer jkb...@gmail.com added the comment:

Before anyone else rushes of to do this, can I? I really want to break into 
python-dev and this might be my chance.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14350
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14350] Strange Exception from copying an iterator

2012-03-25 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Please, give it a try.  But also be prepared for it being harder than it looks; 
the problem is that there may be very limited knowledge available where the 
error is generated. (I don't know; I haven't looked at the code and am not 
likely to...I usually leave reviews of C code to our C experts.)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14350
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14350] Strange Exception from copying an iterator

2012-03-24 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

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.

--
nosy: +alexandre.vassalotti, rhettinger, terry.reedy
stage:  - needs patch
title: Strange Exception from copying an iterable - Strange Exception from 
copying an iterator

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14350
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com