[issue4486] Exception traceback is incorrect for strange exception handling
Nick Coghlan
report at bugs.python.org
Tue Dec 2 22:17:51 CET 2008
Nick Coghlan <ncoghlan at gmail.com> added the comment:
Looks to me like the display code is getting confused by the lack of a
non-None __context__ on the KeyError.
Perhaps the "raise ex from cause" syntax should be setting the
__context__ on the "cause" exception if it isn't already set?
Or else we could just special case this kind of weird programmer
behaviour in the display code.
=======================
>>> try:
... raise IOError
... except Exception as ex:
... ke = KeyError()
... ke.__context__ = ex
... raise AttributeError from ke
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
IOError
During handling of the above exception, another exception occurred:
KeyError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 6, in <module>
AttributeError
=======================
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4486>
_______________________________________
More information about the Python-bugs-list
mailing list