Skip to content
Snippets Groups Projects
Commit f5718e4b authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

extended Traceback to fetch current stack frame if no exception is in progress...

extended Traceback to fetch current stack frame if no exception is in progress and no stack frame is given
parent 0d35b0f0
No related branches found
No related tags found
No related merge requests found
# v2.11.26
* fix exception hierarchy in futures
* extended Traceback to fetch current stack frame if no exception is in progress and no stack frame is given
......@@ -33,6 +33,8 @@ Usage:
Traceback should be created in the exception it is supposed to capture,
as it captures exception info from _sys.exc_info()_.
If no exception is in progress, current stack frame will be fetched
from `inspect.currentframe()`.
Alternatively, you can pass a `<frame>` object to Traceback, in order to serialize it, for example:
......
__version__ = '2.11.26_a3'
__version__ = '2.11.26_a4'
......@@ -42,16 +42,16 @@ class Traceback(JSONAble):
else:
value_pickling_policy = policy
tb = sys.exc_info()[2]
self.frames = [] # type: tp.List[StackFrame]
if starting_frame is None:
if tb is None:
raise ValueError('No traceback')
while tb.tb_next:
tb = tb.tb_next
f = tb.tb_frame
tb = sys.exc_info()[2]
if tb is not None:
while tb.tb_next:
tb = tb.tb_next
f = tb.tb_frame
else:
f = inspect.currentframe()
else:
f = starting_frame
......
......@@ -7,7 +7,7 @@ from satella.instrumentation import Traceback
class TestTraceback(unittest.TestCase):
def test_no_exc(self):
self.assertRaises(ValueError, Traceback)
Traceback()
def test_json(self):
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment