RecursionError

The Python exception raised when recursion goes deeper than the interpreter's limit, which is 1,000 frames by default.

In more detail

Python stops runaway recursion with this error rather than letting the process crash when the call stack overflows. sys.getrecursionlimit() shows the limit and sys.setrecursionlimit() changes it, but raising it only postpones the problem. The lasting fix is to rewrite the recursion as a loop.

Related terms

Taught in

References