Skip to content

Commit 612a2d2

Browse files
color the exception target
1 parent 51fa996 commit 612a2d2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Lib/_colorize.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ class Traceback(ThemeSection):
333333
frame: str = ANSIColors.MAGENTA
334334
error_highlight: str = ANSIColors.BOLD_RED
335335
error_range: str = ANSIColors.RED
336+
exception_target: str = ANSIColors.YELLOW
336337
reset: str = ANSIColors.RESET
337338

338339

Lib/traceback.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,11 @@ def _format_note(note, indent, theme):
10771077
yield f"{indent}{theme.note}{l}{theme.reset}\n"
10781078

10791079

1080+
def _format_exception_target(note, indent, theme):
1081+
for l in note.split("\n"):
1082+
yield f"{indent}{theme.exception_target}{l}{theme.reset}\n"
1083+
1084+
10801085
class _ExceptionPrintContext:
10811086
def __init__(self):
10821087
self.seen = set()
@@ -1435,7 +1440,7 @@ def format_exception_only(self, *, show_group=False, _depth=0, **kwargs):
14351440
yield from _format_note(note, indent, theme)
14361441
if exception_target:
14371442
for note in self.exception_target:
1438-
yield from [indent + l + '\n' for l in note.split('\n')]
1443+
yield from _format_exception_target(note, indent, theme)
14391444

14401445
if self.exceptions and show_group:
14411446
for ex in self.exceptions:

0 commit comments

Comments
 (0)