[issue4176] segfault with pickle if 4th or 5th item of tuple returned by __reduce__ is not an iterator
report at bugs.python.org
Fri Oct 31 21:47:32 CET 2008
Alexandre Vassalotti <alexandre at peadrop.com> added the comment:
Hirokazu Yamamoto wrote
> Hmm, but python document says,
> >The iterator objects themselves are required to support the
> >following two methods, which together form the iterator protocol:
> Is this false information?
Oh, you are right. I got confused by looking at the implementation of
PyIter_Check(), which only verifies that tp_next is not NULL. Anyway,
_batch_appends() and _batch_setitems() in pickle.py calls iter() on the
iterators; so, the iterators must provide __iter__ too.
Personally, I wouldn't bother about checking for __iter__ to avoid
adding a new method to Pickler and also to save a few hasattr() calls.
But I have to admit, it is really just nitpicking at this point.
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list