| 1 | #! /usr/bin/env python
|
|---|
| 2 | """Find the maximum recursion limit that prevents core dumps
|
|---|
| 3 |
|
|---|
| 4 | This script finds the maximum safe recursion limit on a particular
|
|---|
| 5 | platform. If you need to change the recursion limit on your system,
|
|---|
| 6 | this script will tell you a safe upper bound. To use the new limit,
|
|---|
| 7 | call sys.setrecursionlimit.
|
|---|
| 8 |
|
|---|
| 9 | This module implements several ways to create infinite recursion in
|
|---|
| 10 | Python. Different implementations end up pushing different numbers of
|
|---|
| 11 | C stack frames, depending on how many calls through Python's abstract
|
|---|
| 12 | C API occur.
|
|---|
| 13 |
|
|---|
| 14 | After each round of tests, it prints a message
|
|---|
| 15 | Limit of NNNN is fine.
|
|---|
| 16 |
|
|---|
| 17 | It ends when Python causes a segmentation fault because the limit is
|
|---|
| 18 | too high. On platforms like Mac and Windows, it should exit with a
|
|---|
| 19 | MemoryError.
|
|---|
| 20 |
|
|---|
| 21 | NB: A program that does not use __methods__ can set a higher limit.
|
|---|
| 22 | """
|
|---|
| 23 |
|
|---|
| 24 | import sys
|
|---|
| 25 |
|
|---|
| 26 | class RecursiveBlowup1:
|
|---|
| 27 | def __init__(self):
|
|---|
| 28 | self.__init__()
|
|---|
| 29 |
|
|---|
| 30 | def test_init():
|
|---|
| 31 | return RecursiveBlowup1()
|
|---|
| 32 |
|
|---|
|
|---|