summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-03-06 12:02:26 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-03-06 12:02:26 (GMT)
commit5608411a964f7fd5a35eda04b297e0d77de9958d (patch)
treeb7dd9121e58f5660b8684477ee78377b6dc986cc /Lib
parentb6bfce6c0b4721700241b550e31ae3aeabcb6f41 (diff)
parentd55162517da38138fed130607b311ed4cc62ec77 (diff)
downloadcpython-5608411a964f7fd5a35eda04b297e0d77de9958d.zip
cpython-5608411a964f7fd5a35eda04b297e0d77de9958d.tar.gz
cpython-5608411a964f7fd5a35eda04b297e0d77de9958d.tar.bz2
Issue #25718: Fixed pickling and copying the accumulate() iterator with total is None.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_itertools.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 9e55b2a..fab9b31 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -1448,6 +1448,16 @@ class TestExamples(unittest.TestCase):
self.assertEqual(list(copy.deepcopy(it)), accumulated[1:])
self.assertEqual(list(copy.copy(it)), accumulated[1:])
+ def test_accumulate_reducible_none(self):
+ # Issue #25718: total is None
+ it = accumulate([None, None, None], operator.is_)
+ self.assertEqual(next(it), None)
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ it_copy = pickle.loads(pickle.dumps(it, proto))
+ self.assertEqual(list(it_copy), [True, False])
+ self.assertEqual(list(copy.deepcopy(it)), [True, False])
+ self.assertEqual(list(copy.copy(it)), [True, False])
+
def test_chain(self):
self.assertEqual(''.join(chain('ABC', 'DEF')), 'ABCDEF')