@@ -637,12 +637,21 @@ def _safe_repr(self, object, context, maxlevels, level):
637637 else :
638638 return repr (object ), True , False
639639
640- if issubclass (typ , dict ) and r is dict .__repr__ :
640+ if ((issubclass (typ , dict ) and r is dict .__repr__ )
641+ or (issubclass (typ , frozendict ) and r is frozendict .__repr__ )):
642+ is_frozendict = issubclass (typ , frozendict )
641643 if not object :
642- return "{}" , True , False
644+ if is_frozendict :
645+ rep = f"{ object .__class__ .__name__ } ()"
646+ else :
647+ rep = "{}"
648+ return rep , True , False
643649 objid = id (object )
644650 if maxlevels and level >= maxlevels :
645- return "{...}" , False , objid in context
651+ rep = "{...}"
652+ if is_frozendict :
653+ rep = f"{ object .__class__ .__name__ } ({ rep } )"
654+ return rep , False , objid in context
646655 if objid in context :
647656 return _recursion (object ), False , True
648657 context [objid ] = 1
@@ -665,7 +674,10 @@ def _safe_repr(self, object, context, maxlevels, level):
665674 if krecur or vrecur :
666675 recursive = True
667676 del context [objid ]
668- return "{%s}" % ", " .join (components ), readable , recursive
677+ rep = "{%s}" % ", " .join (components )
678+ if is_frozendict :
679+ rep = f"{ object .__class__ .__name__ } ({ rep } )"
680+ return rep , readable , recursive
669681
670682 if (issubclass (typ , list ) and r is list .__repr__ ) or \
671683 (issubclass (typ , tuple ) and r is tuple .__repr__ ):
0 commit comments