From 5d2fb53a34d4400a0599dd54f07482422d06f854 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sun, 15 Mar 2015 09:35:30 -0700 Subject: [PATCH] Attempt to extract traceback from exception In py3.x and newer a exception has an attached traceback so in the `from_exception` class method we should try to extract that traceback if we are able to. Change-Id: Ia1c5cfddc259bd9de7cff1b672354670c2f4f839 --- taskflow/types/failure.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/taskflow/types/failure.py b/taskflow/types/failure.py index 406dd4f8..d713098d 100644 --- a/taskflow/types/failure.py +++ b/taskflow/types/failure.py @@ -209,7 +209,12 @@ class Failure(object): @classmethod def from_exception(cls, exception): """Creates a failure object from a exception instance.""" - return cls((type(exception), exception, None)) + exc_info = ( + type(exception), + exception, + getattr(exception, '__traceback__', None) + ) + return cls(exc_info=exc_info) @classmethod def validate(cls, data):