diff options
author | Facundo Batista <facundobatista@gmail.com> | 2008-06-22 23:19:14 (GMT) |
---|---|---|
committer | Facundo Batista <facundobatista@gmail.com> | 2008-06-22 23:19:14 (GMT) |
commit | 9da18b313342ec6d81bd5ea5d19c1d05f6a41a08 (patch) | |
tree | 3c706630f29a94fa2b64932dbf8e2a48766112a4 /Lib/test/test_cpickle.py | |
parent | 2694eb021977322eefeb39e71b13eb20085c20a2 (diff) | |
download | cpython-9da18b313342ec6d81bd5ea5d19c1d05f6a41a08.zip cpython-9da18b313342ec6d81bd5ea5d19c1d05f6a41a08.tar.gz cpython-9da18b313342ec6d81bd5ea5d19c1d05f6a41a08.tar.bz2 |
Fixing the problem stated in issue 2702 with the patch submitted
in the issue 3165. Now cPickle does not fails with uncontrolled
behaviour when pickling into a very deep nested structure.
Diffstat (limited to 'Lib/test/test_cpickle.py')
-rw-r--r-- | Lib/test/test_cpickle.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/Lib/test/test_cpickle.py b/Lib/test/test_cpickle.py index d6e703a..7f6c35a 100644 --- a/Lib/test/test_cpickle.py +++ b/Lib/test/test_cpickle.py @@ -1,4 +1,4 @@ -import cPickle +import cPickle, unittest from cStringIO import StringIO from test.pickletester import AbstractPickleTests, AbstractPickleModuleTests from test import test_support @@ -90,12 +90,28 @@ class cPickleFastPicklerTests(AbstractPickleTests): b = self.loads(self.dumps(a)) self.assertEqual(a, b) +class Node(object): + pass + +class cPickleDeepRecursive(unittest.TestCase): + '''Issue 2702. This should raise a RecursionLimit but in some + platforms (FreeBSD, win32) sometimes raises KeyError instead, + or just silently terminates the interpreter (=crashes). + ''' + def test_deep_recursive(self): + nodes = [Node() for i in range(500)] + for n in nodes: + n.connections = list(nodes) + n.connections.remove(n) + self.assertRaises(RuntimeError, cPickle.dumps, n) + def test_main(): test_support.run_unittest( cPickleTests, cPicklePicklerTests, cPickleListPicklerTests, - cPickleFastPicklerTests + cPickleFastPicklerTests, + cPickleDeepRecursive, ) if __name__ == "__main__": |