allow reprcrash to be none in ReprExceptionInfo

* that this was not possible caused test_config.test_parse_warning_filter_failure to fail
This commit is contained in:
Felix Hofstätter 2023-03-12 18:32:48 +01:00
parent 7f95c9c3d7
commit 7b5bc36eab
1 changed files with 2 additions and 7 deletions

View File

@ -650,18 +650,13 @@ class ExceptionInfo(Generic[E]):
Added the ``chain`` parameter. Added the ``chain`` parameter.
""" """
if style == "native": if style == "native":
r = self._getreprcrash()
if r is None:
raise ValueError(
"There should always be a non-hidden traceback entry for the top level function."
)
return ReprExceptionInfo( return ReprExceptionInfo(
reprtraceback=ReprTracebackNative( reprtraceback=ReprTracebackNative(
traceback.format_exception( traceback.format_exception(
self.type, self.value, self.traceback[0]._rawentry self.type, self.value, self.traceback[0]._rawentry
) )
), ),
reprcrash=r, reprcrash=self._getreprcrash(),
) )
fmt = FormattedExcinfo( fmt = FormattedExcinfo(
@ -1056,7 +1051,7 @@ class ExceptionChainRepr(ExceptionRepr):
@dataclasses.dataclass(eq=False) @dataclasses.dataclass(eq=False)
class ReprExceptionInfo(ExceptionRepr): class ReprExceptionInfo(ExceptionRepr):
reprtraceback: "ReprTraceback" reprtraceback: "ReprTraceback"
reprcrash: "ReprFileLocation" reprcrash: Optional["ReprFileLocation"]
def toterminal(self, tw: TerminalWriter) -> None: def toterminal(self, tw: TerminalWriter) -> None:
self.reprtraceback.toterminal(tw) self.reprtraceback.toterminal(tw)