diff options
| author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-09-11 20:56:13 +0000 |
|---|---|---|
| committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-09-11 20:56:13 +0000 |
| commit | 24cb382455a0701b33926c134803a39f13e29bd1 (patch) | |
| tree | 9c99aba4406b65ae0fe19bd38dac101ed7e21c30 /Misc/find_recursionlimit.py | |
| parent | d2e09383624944add0e670b857c572129d56988e (diff) | |
| download | cpython-git-24cb382455a0701b33926c134803a39f13e29bd1.tar.gz | |
#3640: Correct a crash in cPickle on 64bit platforms, in the case of deeply nested lists or dicts.
Reviewed by Martin von Loewis.
Diffstat (limited to 'Misc/find_recursionlimit.py')
| -rw-r--r-- | Misc/find_recursionlimit.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Misc/find_recursionlimit.py b/Misc/find_recursionlimit.py index e6454c9c30..398abebc16 100644 --- a/Misc/find_recursionlimit.py +++ b/Misc/find_recursionlimit.py @@ -22,6 +22,7 @@ NB: A program that does not use __methods__ can set a higher limit. """ import sys +import itertools class RecursiveBlowup1: def __init__(self): @@ -61,6 +62,23 @@ def test_getitem(): def test_recurse(): return test_recurse() +def test_cpickle(_cache={}): + try: + import cPickle + except ImportError: + print "cannot import cPickle, skipped!" + return + l = None + for n in itertools.count(): + try: + l = _cache[n] + continue # Already tried and it works, let's save some time + except KeyError: + for i in range(100): + l = [l] + cPickle.dumps(l, protocol=-1) + _cache[n] = l + def check_limit(n, test_func_name): sys.setrecursionlimit(n) if test_func_name.startswith("test_"): @@ -83,5 +101,6 @@ while 1: check_limit(limit, "test_init") check_limit(limit, "test_getattr") check_limit(limit, "test_getitem") + check_limit(limit, "test_cpickle") print "Limit of %d is fine" % limit limit = limit + 100 |
