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
Display error accessing __notes__ along with the traceback
  • Loading branch information
perrinjerome committed Jan 15, 2024
commit 8651d3eb58b2f47d8688854cb3c2020cf46fd1ef
4 changes: 3 additions & 1 deletion Lib/test/test_traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,9 @@ def __getattr__(self, name):
e = BrokenException(123)
vanilla = self.get_report(e)
e.broken = True
self.assertEqual(self.get_report(e), vanilla)
self.assertEqual(
self.get_report(e),
vanilla + "Ignored exception getting __notes__: ValueError('no __notes__')\n")
Comment thread
perrinjerome marked this conversation as resolved.
Outdated

def test_exception_with_multiple_notes(self):
for e in [ValueError(42), SyntaxError('bad syntax')]:
Expand Down
8 changes: 4 additions & 4 deletions Lib/traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,10 +1053,10 @@ def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
self._str = _safe_string(exc_value, 'exception')
notes = None
try:
notes = getattr(exc_value, '__notes__', None)
except Exception:
pass
self.__notes__ = notes
self.__notes__ = getattr(exc_value, '__notes__', None)
except Exception as e:
self.__notes__ = [
f'Ignored exception getting __notes__: {_safe_string(e, '__notes__', repr)}']
Comment thread
perrinjerome marked this conversation as resolved.
Outdated

self._is_syntax_error = False
self._have_exc_type = exc_type is not None
Expand Down