Improve ExceptionInfo.__repr__

This commit is contained in:
Daniel Hahler
2019-10-09 05:16:27 +02:00
parent 5c92a0f695
commit 2a2fe7d3db
3 changed files with 17 additions and 3 deletions

View File

@@ -507,7 +507,9 @@ class ExceptionInfo(Generic[_E]):
def __repr__(self) -> str:
if self._excinfo is None:
return "<ExceptionInfo for raises contextmanager>"
return "<ExceptionInfo %s tblen=%d>" % (self.typename, len(self.traceback))
return "<{} {} tblen={}>".format(
self.__class__.__name__, saferepr(self._excinfo[1]), len(self.traceback)
)
def exconly(self, tryshort: bool = False) -> str:
""" return the exception as a string