mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #14288: Serialization support for builtin iterators.
This commit is contained in:
parent
283b96b6bd
commit
31668b8f7a
28 changed files with 2190 additions and 104 deletions
|
@ -471,6 +471,19 @@ class TestBasic(unittest.TestCase):
|
|||
## self.assertNotEqual(id(d), id(e))
|
||||
## self.assertEqual(id(e), id(e[-1]))
|
||||
|
||||
def test_iterator_pickle(self):
|
||||
data = deque(range(200))
|
||||
it = itorg = iter(data)
|
||||
d = pickle.dumps(it)
|
||||
it = pickle.loads(d)
|
||||
self.assertEqual(type(itorg), type(it))
|
||||
self.assertEqual(list(it), list(data))
|
||||
|
||||
it = pickle.loads(d)
|
||||
next(it)
|
||||
d = pickle.dumps(it)
|
||||
self.assertEqual(list(it), list(data)[1:])
|
||||
|
||||
def test_deepcopy(self):
|
||||
mut = [10]
|
||||
d = deque([mut])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue