Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/_pytest/_io/saferepr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from itertools import islice
import pprint
import reprlib
import sys


def _try_repr_or_str(obj: object) -> str:
Expand Down Expand Up @@ -112,6 +113,9 @@ def safeformat(obj: object) -> str:
with a short exception info.
"""
try:
# Python 3.15+ supports expand=True for better nested reprs
if sys.version_info >= (3, 15):
return pprint.pformat(obj, expand=True)
return pprint.pformat(obj)
except Exception as exc:
return _format_repr_exception(exc, obj)
Expand Down