Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Chnge color to CYAN, refactor coloring
  • Loading branch information
StanFromIreland committed Mar 21, 2026
commit 47f74a21441f7f9f231a52a7a52b1faa0892e00d
2 changes: 1 addition & 1 deletion Lib/_colorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class Syntax(ThemeSection):
class Traceback(ThemeSection):
type: str = ANSIColors.BOLD_MAGENTA
message: str = ANSIColors.MAGENTA
note: str = ANSIColors.MAGENTA
note: str = ANSIColors.CYAN
filename: str = ANSIColors.MAGENTA
line_no: str = ANSIColors.MAGENTA
frame: str = ANSIColors.MAGENTA
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -5318,10 +5318,10 @@ def foo():
exc = traceback.TracebackException.from_exception(e)

lines = "".join(exc.format(colorize=True))
magenta = colors["m"]
note = colors["n"]
reset = colors["z"]
self.assertIn(magenta + "First note" + reset, lines)
self.assertIn(magenta + "Second note" + reset, lines)
self.assertIn(note + "First note" + reset, lines)
self.assertIn(note + "Second note" + reset, lines)

def test_colorized_syntax_error(self):
try:
Expand Down
10 changes: 8 additions & 2 deletions Lib/traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,11 @@ def _display_width(line, offset=None):
)


def _format_note(note, indent, theme):
for l in note.split('\n'):
Comment thread
hugovk marked this conversation as resolved.
Outdated
yield f"{indent}{theme.note}{l}{theme.reset}\n"



class _ExceptionPrintContext:
def __init__(self):
Expand Down Expand Up @@ -1323,9 +1328,10 @@ def format_exception_only(self, *, show_group=False, _depth=0, **kwargs):
):
for note in self.__notes__:
note = _safe_string(note, 'note')
yield from [indent + theme.note + l + theme.reset + '\n' for l in note.split('\n')]
yield from _format_note(note, indent, theme)
elif self.__notes__ is not None:
yield indent + theme.note + "{}".format(_safe_string(self.__notes__, '__notes__', func=repr)) + theme.reset + "\n"
note = _safe_string(self.__notes__, '__notes__', func=repr)
yield from _format_note(note, indent, theme)

if self.exceptions and show_group:
for ex in self.exceptions:
Expand Down
Loading