Skip to content

Commit e84ef57

Browse files
committed
Call object's __pprint__() function if it has one
1 parent 722a72b commit e84ef57

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Lib/pprint.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,9 @@ def _safe_repr(self, object, context, maxlevels, level):
615615
if typ in _builtin_scalars:
616616
return repr(object), True, False
617617

618+
if (p := getattr(typ, "__pprint__", None)):
619+
return p(object, context, maxlevels, level), True, False
620+
618621
r = getattr(typ, "__repr__", None)
619622

620623
if issubclass(typ, int) and r is int.__repr__:

0 commit comments

Comments
 (0)