Built-in Exceptions

RecursionError — exception class

The interpreter detected excessive recursion depth. Check base cases and whether recursive calls make progress. Raising the recursion limit is not a general solution and can risk the native stack. Catch RecursionError when this category is the recovery boundary; do not rely on the exact human-readable message.

Formal Syntax & Structure

python syntaxpython
RecursionError

Return Value

type

The class object RecursionError; this reference documents the class identity, not a universal constructor signature.

Working Example

Example Snippetpython
def descend(): return descend()try:    descend()except RecursionError as error:    print(type(error).__name__)
Python Reference