[New-bugs-announce] [issue23915] traceback set with BaseException.with_traceback() overwritten on raise

Travis A. Everett report at bugs.python.org
Sat Apr 11 18:29:20 CEST 2015

New submission from Travis A. Everett:

When BaseException.with_traceback(tb) is used, the __traceback__ property is properly set, but the property gets overwritten when the exception is raised. 

The attached file demonstrates the issue by raising exception a, which doesn't use with_traceback, and exception b, which uses with_traceback(a.__traceback__). It also demonstrates that the exception object can't observe this change. Executing the attached file produces output like:

a.__traceback__ before raise: [None]
a.__traceback__ after raise : [<traceback object at 0x7f95c5a21708>]
b.__traceback__ before raise: [<traceback object at 0x7f95c5a21708>]
b.__traceback__ after raise : [<traceback object at 0x7f95c5a21748>]

files: exctest.py
messages: 240483
nosy: abathur
priority: normal
severity: normal
status: open
title: traceback set with BaseException.with_traceback() overwritten on raise
type: behavior
versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file38898/exctest.py

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list