Show More
@@ -273,15 +273,6 b' def _fixed_getinnerframes(etb, context=1, tb_offset=0):' | |||||
273 | except IndexError: |
|
273 | except IndexError: | |
274 | pass |
|
274 | pass | |
275 |
|
275 | |||
276 | # we don't want to truncate too much |
|
|||
277 | # when normal exception occurs there are two records usually |
|
|||
278 | # first is from ipython and has pre_hooks information and so on |
|
|||
279 | # however sometimes we have tracebacks without additional ipython information |
|
|||
280 | # for example from nested traceback (python3 exceptions have __context__ which |
|
|||
281 | # stores information about previous exceptions) |
|
|||
282 | if tb_offset >= len(records): |
|
|||
283 | tb_offset = len(records) - 2 |
|
|||
284 |
|
||||
285 | aux = traceback.extract_tb(etb) |
|
276 | aux = traceback.extract_tb(etb) | |
286 | assert len(records) == len(aux) |
|
277 | assert len(records) == len(aux) | |
287 | for i, (file, lnum, _, _) in zip(range(len(records)), aux): |
|
278 | for i, (file, lnum, _, _) in zip(range(len(records)), aux): | |
@@ -995,13 +986,24 b' class VerboseTB(TBTools):' | |||||
995 | def structured_traceback(self, etype, evalue, etb, tb_offset=None, |
|
986 | def structured_traceback(self, etype, evalue, etb, tb_offset=None, | |
996 | number_of_lines_of_context=5): |
|
987 | number_of_lines_of_context=5): | |
997 | """Return a nice text document describing the traceback.""" |
|
988 | """Return a nice text document describing the traceback.""" | |
998 | structured_traceback_parts = [] |
|
989 | ||
|
990 | formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context, | |||
|
991 | tb_offset) | |||
999 |
|
992 | |||
1000 | if py3compat.PY3: |
|
993 | if py3compat.PY3: | |
1001 |
|
|
994 | chained_exceptions_tb_offset = 0 | |
|
995 | lines_of_context = 3 | |||
|
996 | formatted_exceptions = formatted_exception | |||
|
997 | structured_traceback_parts = [] | |||
|
998 | exception = self.get_exception_from_context(evalue) | |||
|
999 | if exception: | |||
|
1000 | formatted_exceptions += self.prepare_chained_exception_message(evalue.__cause__) | |||
|
1001 | etype, evalue, etb = exception | |||
|
1002 | else: | |||
|
1003 | evalue = None | |||
1002 | while evalue: |
|
1004 | while evalue: | |
1003 |
formatted_exceptions += self.format_exception_as_a_whole(etype, evalue, etb, |
|
1005 | formatted_exceptions += self.format_exception_as_a_whole(etype, evalue, etb, lines_of_context, | |
1004 | tb_offset) |
|
1006 | chained_exceptions_tb_offset) | |
1005 | exception = self.get_exception_from_context(evalue) |
|
1007 | exception = self.get_exception_from_context(evalue) | |
1006 | if exception: |
|
1008 | if exception: | |
1007 | formatted_exceptions += self.prepare_chained_exception_message(evalue.__cause__) |
|
1009 | formatted_exceptions += self.prepare_chained_exception_message(evalue.__cause__) | |
@@ -1014,9 +1016,8 b' class VerboseTB(TBTools):' | |||||
1014 | for formatted_exception in reversed(formatted_exceptions): |
|
1016 | for formatted_exception in reversed(formatted_exceptions): | |
1015 | structured_traceback_parts += formatted_exception |
|
1017 | structured_traceback_parts += formatted_exception | |
1016 | else: |
|
1018 | else: | |
1017 | formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context, |
|
|||
1018 | tb_offset) |
|
|||
1019 | structured_traceback_parts = formatted_exception[0] |
|
1019 | structured_traceback_parts = formatted_exception[0] | |
|
1020 | ||||
1020 | return structured_traceback_parts |
|
1021 | return structured_traceback_parts | |
1021 |
|
1022 | |||
1022 | def debugger(self, force=False): |
|
1023 | def debugger(self, force=False): |
General Comments 0
You need to be logged in to leave comments.
Login now