This commit is contained in:
Cheukting 2022-06-23 15:48:21 +08:00
parent 39339b991d
commit be502f9329
1 changed files with 6 additions and 7 deletions

View File

@ -56,9 +56,9 @@ if TYPE_CHECKING:
_TracebackStyle = Literal["long", "short", "line", "no", "native", "value", "auto"] _TracebackStyle = Literal["long", "short", "line", "no", "native", "value", "auto"]
ExceptionGroupTypes: tuple = () ExceptionGroupTypes: tuple = () # type: ignore
try: try:
ExceptionGroupTypes += (ExceptionGroup,) ExceptionGroupTypes += (ExceptionGroup,) # type: ignore
except NameError: except NameError:
pass # Is missing for `python<3.10` pass # Is missing for `python<3.10`
try: try:
@ -68,7 +68,6 @@ try:
except ModuleNotFoundError: except ModuleNotFoundError:
pass # No backport is installed pass # No backport is installed
class Code: class Code:
"""Wrapper around Python code objects.""" """Wrapper around Python code objects."""
@ -936,15 +935,15 @@ class FormattedExcinfo:
while e is not None and id(e) not in seen: while e is not None and id(e) not in seen:
seen.add(id(e)) seen.add(id(e))
if isinstance(e, ExceptionGroupTypes): if isinstance(e, ExceptionGroupTypes):
reprtraceback = ReprTracebackNative( reprtraceback: Union[ReprTracebackNative, ReprTraceback] = ReprTracebackNative(
traceback.format_exception( traceback.format_exception(
type(e), e, excinfo.traceback[0]._rawentry type(excinfo.value), excinfo.value, excinfo.traceback[0]._rawentry
) )
) )
reprcrash = None reprcrash: Optional[ReprFileLocation] = None
elif excinfo_: elif excinfo_:
reprtraceback = self.repr_traceback(excinfo_) reprtraceback = self.repr_traceback(excinfo_)
reprcrash: Optional[ReprFileLocation] = ( reprcrash = (
excinfo_._getreprcrash() if self.style != "value" else None excinfo_._getreprcrash() if self.style != "value" else None
) )
else: else: