summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-10-30 22:25:31 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-10-30 22:25:31 (GMT)
commit424b4819bea4b63d9d88fe55812e64a32f3c0e7d (patch)
tree7ca587c1f1e7094505230ab8cd6f5c0f9c8a98da /Lib
parent6a27efa2d321c2b262c0cab3c2d4af3e2e8a9ead (diff)
downloadcpython-424b4819bea4b63d9d88fe55812e64a32f3c0e7d.zip
cpython-424b4819bea4b63d9d88fe55812e64a32f3c0e7d.tar.gz
cpython-424b4819bea4b63d9d88fe55812e64a32f3c0e7d.tar.bz2
Merged revisions 67049 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r67049 | amaury.forgeotdarc | 2008-10-30 22:18:34 +0100 (jeu., 30 oct. 2008) | 8 lines Issue #4176: Pickle would crash the interpreter when a __reduce__ function does not return an iterator for the 4th and 5th items. (sequence-like and mapping-like state) A list is not an iterator... Will backport to 2.6 and 2.5. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/pickletester.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index 4c301ad..21deaff 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -876,6 +876,22 @@ class AbstractPickleTests(unittest.TestCase):
d = self.dumps(x, 2)
self.assertRaises(RuntimeError, self.loads, d)
+ def test_reduce_bad_iterator(self):
+ # Issue4176: crash when 4th and 5th items of __reduce__()
+ # are not iterators
+ class C(object):
+ def __reduce__(self):
+ # 4th item is not an iterator
+ return list, (), None, [], None
+ class D(object):
+ def __reduce__(self):
+ # 5th item is not an iterator
+ return dict, (), None, None, []
+
+ for proto in protocols:
+ self.assertRaises(pickle.PickleError, self.dumps, C(), proto)
+ self.assertRaises(pickle.PickleError, self.dumps, D(), proto)
+
# Test classes for reduce_ex
class REX_one(object):