Show More
@@ -763,7 +763,7 b' class VerboseTB(TBTools):' | |||||
763 | self, |
|
763 | self, | |
764 | etype: type, |
|
764 | etype: type, | |
765 | evalue: BaseException, |
|
765 | evalue: BaseException, | |
766 | etb: TracebackType, |
|
766 | etb: Optional[TracebackType], | |
767 | number_of_lines_of_context, |
|
767 | number_of_lines_of_context, | |
768 | tb_offset: Optional[int], |
|
768 | tb_offset: Optional[int], | |
769 | ): |
|
769 | ): | |
@@ -772,7 +772,6 b' class VerboseTB(TBTools):' | |||||
772 | This may be called multiple times by Python 3 exception chaining |
|
772 | This may be called multiple times by Python 3 exception chaining | |
773 | (PEP 3134). |
|
773 | (PEP 3134). | |
774 | """ |
|
774 | """ | |
775 | assert etb is not None |
|
|||
776 | # some locals |
|
775 | # some locals | |
777 | orig_etype = etype |
|
776 | orig_etype = etype | |
778 | try: |
|
777 | try: | |
@@ -783,7 +782,9 b' class VerboseTB(TBTools):' | |||||
783 | tb_offset = self.tb_offset if tb_offset is None else tb_offset |
|
782 | tb_offset = self.tb_offset if tb_offset is None else tb_offset | |
784 | assert isinstance(tb_offset, int) |
|
783 | assert isinstance(tb_offset, int) | |
785 | head = self.prepare_header(etype, self.long_header) |
|
784 | head = self.prepare_header(etype, self.long_header) | |
786 | records = self.get_records(etb, number_of_lines_of_context, tb_offset) |
|
785 | records = ( | |
|
786 | self.get_records(etb, number_of_lines_of_context, tb_offset) if etb else [] | |||
|
787 | ) | |||
787 |
|
788 | |||
788 | frames = [] |
|
789 | frames = [] | |
789 | skipped = 0 |
|
790 | skipped = 0 | |
@@ -822,6 +823,7 b' class VerboseTB(TBTools):' | |||||
822 | def get_records( |
|
823 | def get_records( | |
823 | self, etb: TracebackType, number_of_lines_of_context: int, tb_offset: int |
|
824 | self, etb: TracebackType, number_of_lines_of_context: int, tb_offset: int | |
824 | ): |
|
825 | ): | |
|
826 | assert etb is not None | |||
825 | context = number_of_lines_of_context - 1 |
|
827 | context = number_of_lines_of_context - 1 | |
826 | after = context // 2 |
|
828 | after = context // 2 | |
827 | before = context - after |
|
829 | before = context - after | |
@@ -836,19 +838,17 b' class VerboseTB(TBTools):' | |||||
836 | after=after, |
|
838 | after=after, | |
837 | pygments_formatter=formatter, |
|
839 | pygments_formatter=formatter, | |
838 | ) |
|
840 | ) | |
839 | assert etb is not None |
|
|||
840 | return list(stack_data.FrameInfo.stack_data(etb, options=options))[tb_offset:] |
|
841 | return list(stack_data.FrameInfo.stack_data(etb, options=options))[tb_offset:] | |
841 |
|
842 | |||
842 | def structured_traceback( |
|
843 | def structured_traceback( | |
843 | self, |
|
844 | self, | |
844 | etype: type, |
|
845 | etype: type, | |
845 | evalue: Optional[BaseException], |
|
846 | evalue: Optional[BaseException], | |
846 | etb: TracebackType, |
|
847 | etb: Optional[TracebackType], | |
847 | tb_offset: Optional[int] = None, |
|
848 | tb_offset: Optional[int] = None, | |
848 | number_of_lines_of_context: int = 5, |
|
849 | number_of_lines_of_context: int = 5, | |
849 | ): |
|
850 | ): | |
850 | """Return a nice text document describing the traceback.""" |
|
851 | """Return a nice text document describing the traceback.""" | |
851 | assert etb is not None |
|
|||
852 | formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context, |
|
852 | formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context, | |
853 | tb_offset) |
|
853 | tb_offset) | |
854 |
|
854 |
General Comments 0
You need to be logged in to leave comments.
Login now