@@ -635,6 +635,7 @@ def getrepr(
635635 ] = True ,
636636 funcargs : bool = False ,
637637 truncate_locals : bool = True ,
638+ truncate_args : bool = True ,
638639 chain : bool = True ,
639640 ) -> Union ["ReprExceptionInfo" , "ExceptionChainRepr" ]:
640641 """Return str()able representation of this exception info.
@@ -665,6 +666,9 @@ def getrepr(
665666 :param bool truncate_locals:
666667 With ``showlocals==True``, make sure locals can be safely represented as strings.
667668
669+ :param bool truncate_args:
670+ With ``showargs==True``, make sure args can be safely represented as strings.
671+
668672 :param bool chain:
669673 If chained exceptions in Python 3 should be shown.
670674
@@ -691,6 +695,7 @@ def getrepr(
691695 tbfilter = tbfilter ,
692696 funcargs = funcargs ,
693697 truncate_locals = truncate_locals ,
698+ truncate_args = truncate_args ,
694699 chain = chain ,
695700 )
696701 return fmt .repr_excinfo (self )
@@ -809,6 +814,7 @@ class FormattedExcinfo:
809814 tbfilter : Union [bool , Callable [[ExceptionInfo [BaseException ]], Traceback ]] = True
810815 funcargs : bool = False
811816 truncate_locals : bool = True
817+ truncate_args : bool = True
812818 chain : bool = True
813819 astcache : Dict [Union [str , Path ], ast .AST ] = dataclasses .field (
814820 default_factory = dict , init = False , repr = False
@@ -839,7 +845,11 @@ def repr_args(self, entry: TracebackEntry) -> Optional["ReprFuncArgs"]:
839845 if self .funcargs :
840846 args = []
841847 for argname , argvalue in entry .frame .getargs (var = True ):
842- args .append ((argname , saferepr (argvalue )))
848+ if self .truncate_args :
849+ str_repr = saferepr (argvalue )
850+ else :
851+ str_repr = saferepr (argvalue , maxsize = None )
852+ args .append ((argname , str_repr ))
843853 return ReprFuncArgs (args )
844854 return None
845855
0 commit comments