Issue #24695: Fix a regression in traceback.print_exception()

If exc_traceback is None we shouldn't print a traceback header
like described in the documentation.
This commit is contained in:
Berker Peksag 2015-07-24 17:36:21 +03:00
parent c19bb3279c
commit c3f417dc47
3 changed files with 20 additions and 1 deletions

View file

@ -453,6 +453,7 @@ class TracebackException:
_seen=_seen)
else:
context = None
self.exc_traceback = exc_traceback
self.__cause__ = cause
self.__context__ = context
self.__suppress_context__ = \
@ -561,6 +562,7 @@ class TracebackException:
not self.__suppress_context__):
yield from self.__context__.format(chain=chain)
yield _context_message
yield 'Traceback (most recent call last):\n'
if self.exc_traceback is not None:
yield 'Traceback (most recent call last):\n'
yield from self.stack.format()
yield from self.format_exception_only()