diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-10-30 20:58:42 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-10-30 20:58:42 (GMT) |
commit | f43ee81ef211d9c79f8bbaa3ab369d387c2dfeb6 (patch) | |
tree | c8b3b606b8b14db6d8e10d9ef76751703b58ae87 /Lib/test/test_defaultdict.py | |
parent | 73b90a8d61898ccde2c083a6e51af6624ec52fc3 (diff) | |
download | cpython-f43ee81ef211d9c79f8bbaa3ab369d387c2dfeb6.zip cpython-f43ee81ef211d9c79f8bbaa3ab369d387c2dfeb6.tar.gz cpython-f43ee81ef211d9c79f8bbaa3ab369d387c2dfeb6.tar.bz2 |
#4170: Fix segfault when pickling a defauldict object.
The 2.x dict.iteritems() returns an iterator,
whereas the 3.0 dict.items() returns a "view",
which is iterable, but not an iterator with its __next__ method.
Patch by Hirokazu Yamamoto.
Diffstat (limited to 'Lib/test/test_defaultdict.py')
-rw-r--r-- | Lib/test/test_defaultdict.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_defaultdict.py b/Lib/test/test_defaultdict.py index 49519ab..00bd9dc 100644 --- a/Lib/test/test_defaultdict.py +++ b/Lib/test/test_defaultdict.py @@ -2,6 +2,7 @@ import os import copy +import pickle import tempfile import unittest from test import support @@ -164,6 +165,13 @@ class TestDefaultDict(unittest.TestCase): finally: os.remove(tfn) + def test_pickleing(self): + d = defaultdict(int) + d[1] + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + s = pickle.dumps(d, proto) + o = pickle.loads(s) + self.assertEqual(d, o) def test_main(): support.run_unittest(TestDefaultDict) |