Skip to content
Snippets Groups Projects
Commit d1e338cb authored by Maciej Malochleb's avatar Maciej Malochleb 👽
Browse files

2.26.7

parents d6d07de5 9645152c
Branches master
No related tags found
No related merge requests found
Pipeline #64745 failed with stages
in 4 minutes and 28 seconds
# v2.26.7
* fixed `__str__` method of `CustomException`
# v2.26.6
* Traceback() may accept an Exception instance
# v2.26.5
* added `get_current_traceback` and fixed `RunActionAfterGeneratorCompletes` and `run_when_iterator_completes` default
......
__version__ = '2.26.5'
__version__ = '2.26.7a1'
......@@ -29,7 +29,7 @@ class CustomException(Exception):
a = '%s(%s' % (self.__class__.__qualname__.split('.')[-1], ', '.join(map(repr, self.args)))
try:
if self.kwargs:
a += ', ' + ', '.join(map(lambda k, v: '%s=%s' % (k, repr(v)), self.kwargs.items()))
a += ', ' + ', '.join('%s=%s' % (k, repr(v)) for k, v in self.kwargs.items())
except AttributeError:
pass
a += ')'
......@@ -42,8 +42,7 @@ class CustomException(Exception):
', '.join(map(repr, self.args)))
try:
if self.kwargs:
a += ', ' + (', '.join(map(lambda kv: '%s=%s' % (kv[0], repr(kv[1])),
self.kwargs.items())))
a += ', ' + ', '.join('%s=%s' % (k, repr(v)) for k, v in self.kwargs.items())
except AttributeError:
pass
a += ')'
......
......@@ -53,7 +53,7 @@ class Traceback(JSONAble):
out.append(str(frame))
return ''.join(out)
def __init__(self, starting_frame: tp.Optional[types.FrameType] = None,
def __init__(self, starting_frame: tp.Optional[tp.Union[Exception, types.FrameType]] = None,
policy=GenerationPolicy):
if inspect.isclass(policy):
value_pickling_policy = policy()
......@@ -69,7 +69,10 @@ class Traceback(JSONAble):
else:
f = inspect.currentframe()
else:
f = starting_frame
if isinstance(starting_frame, Exception):
f = starting_frame.__traceback__.tb_frame
else:
f = starting_frame
while f:
self.frames.append(StackFrame(f, value_pickling_policy))
......
......@@ -7,6 +7,14 @@ from satella.instrumentation import Traceback, get_current_traceback
class TestTraceback(unittest.TestCase):
def test_traceback_from_exception(self):
try:
a = 1 / 0
except ZeroDivisionError as e:
tb = Traceback(e)
self.assertIn('ZeroDivisionError', tb.pretty_format())
def test_get_current_traceback(self):
try:
a = 1 / 0
......
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