@@ -241,7 +241,7 @@ def format(self, *, chain=True, _ctx=None, **kwargs):
241241 for msg , exc in reversed (output ):
242242 if msg is not None :
243243 yield from _ctx .emit (msg )
244- if exc . exceptions is None :
244+ if getattr ( exc , " exceptions" , None ) is None :
245245 if exc .stack :
246246 yield from _ctx .emit ("Traceback (most recent call last):\n " )
247247 yield from _ctx .emit (exc .stack .format ())
@@ -332,12 +332,13 @@ def format_exception_only(self, **kwargs):
332332 else :
333333 yield from traceback_exception_original_format_exception_only (self )
334334
335- if isinstance (self .__notes__ , collections .abc .Sequence ):
336- for note in self .__notes__ :
335+ notes = getattr (self , "__notes__" , None )
336+ if isinstance (notes , collections .abc .Sequence ):
337+ for note in notes :
337338 note = _safe_string (note , "note" )
338339 yield from [line + "\n " for line in note .split ("\n " )]
339- elif self . __notes__ is not None :
340- yield _safe_string (self . __notes__ , "__notes__" , func = repr )
340+ elif notes is not None :
341+ yield _safe_string (notes , "__notes__" , func = repr )
341342
342343
343344traceback_exception_original_format = traceback .TracebackException .format
0 commit comments