@@ -1580,6 +1580,7 @@ def format(self, *, chain=True, _ctx=None, **kwargs):
15801580 string in the output.
15811581 """
15821582 colorize = kwargs .get ("colorize" , False )
1583+ exception_target = kwargs .get ("exception_target" , True )
15831584 if _ctx is None :
15841585 _ctx = _ExceptionPrintContext ()
15851586
@@ -1610,7 +1611,7 @@ def format(self, *, chain=True, _ctx=None, **kwargs):
16101611 if exc .stack :
16111612 yield from _ctx .emit ('Traceback (most recent call last):\n ' )
16121613 yield from _ctx .emit (exc .stack .format (colorize = colorize ))
1613- yield from _ctx .emit (exc .format_exception_only (colorize = colorize ))
1614+ yield from _ctx .emit (exc .format_exception_only (colorize = colorize , exception_target = exception_target ))
16141615 elif _ctx .exception_group_depth > self .max_group_depth :
16151616 # exception group, but depth exceeds limit
16161617 yield from _ctx .emit (
@@ -1627,7 +1628,7 @@ def format(self, *, chain=True, _ctx=None, **kwargs):
16271628 margin_char = '+' if is_toplevel else None )
16281629 yield from _ctx .emit (exc .stack .format (colorize = colorize ))
16291630
1630- yield from _ctx .emit (exc .format_exception_only (colorize = colorize ))
1631+ yield from _ctx .emit (exc .format_exception_only (colorize = colorize , exception_target = exception_target ))
16311632 num_excs = len (exc .exceptions )
16321633 if num_excs <= self .max_group_width :
16331634 n = num_excs
@@ -1650,7 +1651,7 @@ def format(self, *, chain=True, _ctx=None, **kwargs):
16501651 f'+---------------- { title } ----------------\n ' )
16511652 _ctx .exception_group_depth += 1
16521653 if not truncated :
1653- yield from exc .exceptions [i ].format (chain = chain , _ctx = _ctx , colorize = colorize )
1654+ yield from exc .exceptions [i ].format (chain = chain , _ctx = _ctx , colorize = colorize , exception_target = exception_target )
16541655 else :
16551656 remaining = num_excs - self .max_group_width
16561657 plural = 's' if remaining > 1 else ''
0 commit comments