diff -r d84f697a7ee6 Misc/find_recursionlimit.py --- a/Misc/find_recursionlimit.py Fri Aug 22 10:03:43 2008 +0200 +++ b/Misc/find_recursionlimit.py Fri Aug 22 20:10:57 2008 +0200 @@ -22,6 +22,7 @@ NB: A program that does not use __method """ import sys +import itertools class RecursiveBlowup1: def __init__(self): @@ -61,6 +62,23 @@ def test_recurse(): 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