# RecursionError: maximum recursion depth exceeded while calling a Python object
(during assertion introspection of a self-referential object)

- **ID:** `python/pytest-assertion-repr-recursion`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

An object compared in an assert has a __repr__ that recurses infinitely (e.g., a tree node whose children include itself), and pytest's assertion rewriting calls repr for the diff.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   class Node:
    def __repr__(self):
        return f"Node(id={id(self)}, value={self.value!r})"
   ```
2. **** (90% success)
   ```
   assert node.value == expected.value
assert node.parent_id == expected.parent_id
   ```

## Dead Ends

- **** — May segfault the interpreter and doesn't fix the cyclic repr. (90% fail)
- **** — Silently passes tests; hides real failures. (95% fail)
- **** — Loses all diff quality; the repr still recurses when printed. (70% fail)
