[issue34574] OrderedDict iterators are exhausted during pickling

Sergey Fedoseev report at bugs.python.org
Thu Sep 6 02:40:38 EDT 2018


Sergey Fedoseev <fedoseev.sergey at gmail.com> added the comment:

Other iterators either don't support pickling or aren't mutated during pickling:

In [10]: it = iter({1})

In [11]: pickle.dumps(it)
Out[11]: b'\x80\x04\x95\x1e\x00\x00\x00\x00\x00\x00\x00\x8c\x08builtins\x94\x8c\x04iter\x94\x93\x94]\x94K\x01a\x85\x94R\x94.'

In [12]: list(it)
Out[12]: [1]

In [13]: it = (x for x in {1})

In [14]: pickle.dumps(it)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-14-7e86a183a31c> in <module>()
----> 1 pickle.dumps(it)

TypeError: can't pickle generator objects

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34574>
_______________________________________


More information about the Python-bugs-list mailing list