diff -r 9c6d11d22801 Lib/traceback.py --- a/Lib/traceback.py Sat Jul 25 12:11:00 2015 +0300 +++ b/Lib/traceback.py Sat Jul 25 22:01:10 2015 +0300 @@ -431,10 +431,8 @@ class TracebackException: # being called with no type or value (None, None, None). if (exc_value and exc_value.__cause__ is not None and exc_value.__cause__ not in _seen): - cause = TracebackException( - type(exc_value.__cause__), + cause = self.from_exception( exc_value.__cause__, - exc_value.__cause__.__traceback__, limit=limit, lookup_lines=False, capture_locals=capture_locals, @@ -443,10 +441,8 @@ class TracebackException: cause = None if (exc_value and exc_value.__context__ is not None and exc_value.__context__ not in _seen): - context = TracebackException( - type(exc_value.__context__), + context = self.from_exception( exc_value.__context__, - exc_value.__context__.__traceback__, limit=limit, lookup_lines=False, capture_locals=capture_locals, @@ -477,10 +473,9 @@ class TracebackException: self._load_lines() @classmethod - def from_exception(self, exc, *args, **kwargs): + def from_exception(cls, exc, *args, **kwargs): """Create a TracebackException from an exception.""" - return TracebackException( - type(exc), exc, exc.__traceback__, *args, **kwargs) + return cls(type(exc), exc, exc.__traceback__, *args, **kwargs) def _load_lines(self): """Private API. force all lines in the stack to be loaded."""