Skip to content

Commit

Permalink
ChainedExceptionUtil.set_cause: Add support for missing exc_cause.__t…
Browse files Browse the repository at this point in the history
…raceback__ attributed => Causes raised exception when traceback is formatted (see #506).
  • Loading branch information
jenisys committed Nov 10, 2016
1 parent 0e19c85 commit e383dc2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions behave/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def set_cause(exception, exc_cause):
assert isinstance(exception, Exception)
assert isinstance(exc_cause, Exception) or exc_cause is None
exception.__cause__ = exc_cause
if exc_cause and not hasattr(exc_cause, "__traceback__"):
# -- NEEDED-FOR: Python2
# Otherwise, traceback formatting tries to access missing attribute.
exc_cause.__traceback__ = None

# pylint: disable=arguments-differ
@classmethod
Expand Down

0 comments on commit e383dc2

Please sign in to comment.