mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
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:
parent
c19bb3279c
commit
c3f417dc47
3 changed files with 20 additions and 1 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue