Fix brownbag in issue 17911 commit
This commit is contained in:
parent
1f22df9651
commit
4330215880
|
@ -445,7 +445,10 @@ class TracebackException:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_exception(self, exc, *args, **kwargs):
|
def from_exception(self, exc, *args, **kwargs):
|
||||||
"""Create a TracebackException from an exception."""
|
"""Create a TracebackException from an exception.
|
||||||
|
|
||||||
|
Only useful in Python 3 specific code.
|
||||||
|
"""
|
||||||
return TracebackException(
|
return TracebackException(
|
||||||
type(exc), exc, exc.__traceback__, *args, **kwargs)
|
type(exc), exc, exc.__traceback__, *args, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -616,6 +616,7 @@ class TestTracebackException(unittest.TestCase):
|
||||||
self.assertEqual(exc_info[0], exc.exc_type)
|
self.assertEqual(exc_info[0], exc.exc_type)
|
||||||
self.assertEqual(str(exc_info[1]), str(exc))
|
self.assertEqual(str(exc_info[1]), str(exc))
|
||||||
|
|
||||||
|
@unittest.skipIf(sys.version_info[:2] < (3, 0), "Only applies to 3+")
|
||||||
def test_from_exception(self):
|
def test_from_exception(self):
|
||||||
# Check all the parameters are accepted.
|
# Check all the parameters are accepted.
|
||||||
def foo():
|
def foo():
|
||||||
|
@ -625,10 +626,9 @@ class TestTracebackException(unittest.TestCase):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exc_info = sys.exc_info()
|
exc_info = sys.exc_info()
|
||||||
self.expected_stack = traceback.StackSummary.extract(
|
self.expected_stack = traceback.StackSummary.extract(
|
||||||
traceback.walk_tb(exc_info[2]), limit=1, lookup_lines=False,
|
traceback.walk_tb(exc_info[2]), limit=1, lookup_lines=False)
|
||||||
capture_locals=True)
|
|
||||||
self.exc = traceback.TracebackException.from_exception(
|
self.exc = traceback.TracebackException.from_exception(
|
||||||
e, limit=1, lookup_lines=False, capture_locals=True)
|
e, limit=1, lookup_lines=False)
|
||||||
expected_stack = self.expected_stack
|
expected_stack = self.expected_stack
|
||||||
exc = self.exc
|
exc = self.exc
|
||||||
self.assertEqual(None, exc.__cause__)
|
self.assertEqual(None, exc.__cause__)
|
||||||
|
|
Loading…
Reference in New Issue