| 1 | n/a | # The following example may crash or not depending on the platform. |
|---|
| 2 | n/a | # E.g. on 32-bit Intel Linux in a "standard" configuration it seems to |
|---|
| 3 | n/a | # crash on Python 2.5 (but not 2.4 nor 2.3). On Windows the import |
|---|
| 4 | n/a | # eventually fails to find the module, possibly because we run out of |
|---|
| 5 | n/a | # file handles. |
|---|
| 6 | n/a | |
|---|
| 7 | n/a | # The point of this example is to show that sys.setrecursionlimit() is a |
|---|
| 8 | n/a | # hack, and not a robust solution. This example simply exercises a path |
|---|
| 9 | n/a | # where it takes many C-level recursions, consuming a lot of stack |
|---|
| 10 | n/a | # space, for each Python-level recursion. So 1000 times this amount of |
|---|
| 11 | n/a | # stack space may be too much for standard platforms already. |
|---|
| 12 | n/a | |
|---|
| 13 | n/a | import sys |
|---|
| 14 | n/a | if 'recursion_limit_too_high' in sys.modules: |
|---|
| 15 | n/a | del sys.modules['recursion_limit_too_high'] |
|---|
| 16 | n/a | import recursion_limit_too_high |
|---|