Show More
@@ -3036,7 +3036,6 b' class IPCompleter(Completer):' | |||
|
3036 | 3036 | skip_matchers: Set[str], |
|
3037 | 3037 | abort_if_offset_changes: bool, |
|
3038 | 3038 | ): |
|
3039 | ||
|
3040 | 3039 | sortable: List[AnyMatcherCompletion] = [] |
|
3041 | 3040 | ordered: List[AnyMatcherCompletion] = [] |
|
3042 | 3041 | most_recent_fragment = None |
@@ -591,7 +591,7 b' class Pdb(OldPdb):' | |||
|
591 | 591 | """ |
|
592 | 592 | if not args.strip(): |
|
593 | 593 | print("current predicates:") |
|
594 |
for |
|
|
594 | for p, v in self._predicates.items(): | |
|
595 | 595 | print(" ", p, ":", v) |
|
596 | 596 | return |
|
597 | 597 | type_value = args.strip().split(" ") |
@@ -838,7 +838,6 b' class Pdb(OldPdb):' | |||
|
838 | 838 | return False |
|
839 | 839 | |
|
840 | 840 | def stop_here(self, frame): |
|
841 | ||
|
842 | 841 | if self._is_in_decorator_internal_and_should_skip(frame) is True: |
|
843 | 842 | return False |
|
844 | 843 |
@@ -471,7 +471,6 b' def test_decorator_skip_with_breakpoint():' | |||
|
471 | 471 | |
|
472 | 472 | ### we need a filename, so we need to exec the full block with a filename |
|
473 | 473 | with NamedTemporaryFile(suffix=".py", dir=".", delete=True) as tf: |
|
474 | ||
|
475 | 474 | name = tf.name[:-3].split("/")[-1] |
|
476 | 475 | tf.write("\n".join([dedent(x) for x in skip_decorators_blocks[:-1]]).encode()) |
|
477 | 476 | tf.flush() |
@@ -1094,7 +1094,6 b' def test_script_err():' | |||
|
1094 | 1094 | |
|
1095 | 1095 | |
|
1096 | 1096 | def test_script_out_err(): |
|
1097 | ||
|
1098 | 1097 | ip = get_ipython() |
|
1099 | 1098 | ip.run_cell_magic( |
|
1100 | 1099 | "script", |
@@ -193,7 +193,6 b' class TestPylabSwitch(object):' | |||
|
193 | 193 | matplotlib.rcParamsOrig = self._saved_rcParamsOrig |
|
194 | 194 | |
|
195 | 195 | def test_qt(self): |
|
196 | ||
|
197 | 196 | s = self.Shell() |
|
198 | 197 | gui, backend = s.enable_matplotlib(None) |
|
199 | 198 | assert gui == "qt" |
@@ -195,29 +195,34 b' def _simple_format_traceback_lines(lnum, index, lines, Colors, lvals, _line_form' | |||
|
195 | 195 | numbers_width = INDENT_SIZE - 1 |
|
196 | 196 | res = [] |
|
197 | 197 | |
|
198 | for i,line in enumerate(lines, lnum-index): | |
|
198 | for i, line in enumerate(lines, lnum - index): | |
|
199 | 199 | line = py3compat.cast_unicode(line) |
|
200 | 200 | |
|
201 |
new_line, err = _line_format(line, |
|
|
201 | new_line, err = _line_format(line, "str") | |
|
202 | 202 | if not err: |
|
203 | 203 | line = new_line |
|
204 | 204 | |
|
205 | 205 | if i == lnum: |
|
206 | 206 | # This is the line with the error |
|
207 | 207 | pad = numbers_width - len(str(i)) |
|
208 |
num = |
|
|
209 |
line = |
|
|
210 | Colors.line, line, Colors.Normal) | |
|
208 | num = "%s%s" % (debugger.make_arrow(pad), str(lnum)) | |
|
209 | line = "%s%s%s %s%s" % ( | |
|
210 | Colors.linenoEm, | |
|
211 | num, | |
|
212 | Colors.line, | |
|
213 | line, | |
|
214 | Colors.Normal, | |
|
215 | ) | |
|
211 | 216 | else: |
|
212 |
num = |
|
|
213 |
line = |
|
|
214 | Colors.Normal, line) | |
|
217 | num = "%*s" % (numbers_width, i) | |
|
218 | line = "%s%s%s %s" % (Colors.lineno, num, Colors.Normal, line) | |
|
215 | 219 | |
|
216 | 220 | res.append(line) |
|
217 | 221 | if lvals and i == lnum: |
|
218 |
res.append(lvals + |
|
|
222 | res.append(lvals + "\n") | |
|
219 | 223 | return res |
|
220 | 224 | |
|
225 | ||
|
221 | 226 | def _format_filename(file, ColorFilename, ColorNormal, *, lineno=None): |
|
222 | 227 | """ |
|
223 | 228 | Format filename lines with custom formatting from caching compiler or `File *.py` by default |
@@ -330,7 +335,6 b' class TBTools(colorable.Colorable):' | |||
|
330 | 335 | def get_parts_of_chained_exception( |
|
331 | 336 | self, evalue |
|
332 | 337 | ) -> Optional[Tuple[type, BaseException, TracebackType]]: |
|
333 | ||
|
334 | 338 | chained_evalue = self._get_chained_exception(evalue) |
|
335 | 339 | |
|
336 | 340 | if chained_evalue: |
@@ -660,9 +664,9 b' class FrameInfo:' | |||
|
660 | 664 | really long frames. |
|
661 | 665 | """ |
|
662 | 666 | |
|
663 |
description |
|
|
664 |
filename |
|
|
665 |
lineno |
|
|
667 | description: Optional[str] | |
|
668 | filename: str | |
|
669 | lineno: int | |
|
666 | 670 | |
|
667 | 671 | @classmethod |
|
668 | 672 | def _from_stack_data_FrameInfo(cls, frame_info): |
@@ -707,9 +711,7 b' class FrameInfo:' | |||
|
707 | 711 | return None |
|
708 | 712 | |
|
709 | 713 | |
|
710 | ||
|
711 | ||
|
712 | #---------------------------------------------------------------------------- | |
|
714 | # ---------------------------------------------------------------------------- | |
|
713 | 715 | class VerboseTB(TBTools): |
|
714 | 716 | """A port of Ka-Ping Yee's cgitb.py module that outputs color text instead |
|
715 | 717 | of HTML. Requires inspect and pydoc. Crazy, man. |
@@ -760,7 +762,7 b' class VerboseTB(TBTools):' | |||
|
760 | 762 | |
|
761 | 763 | self.skip_hidden = True |
|
762 | 764 | |
|
763 | def format_record(self, frame_info:FrameInfo): | |
|
765 | def format_record(self, frame_info: FrameInfo): | |
|
764 | 766 | """Format a single stack frame""" |
|
765 | 767 | assert isinstance(frame_info, FrameInfo) |
|
766 | 768 | Colors = self.Colors # just a shorthand + quicker name lookup |
@@ -787,10 +789,10 b' class VerboseTB(TBTools):' | |||
|
787 | 789 | lineno=frame_info.lineno, |
|
788 | 790 | ) |
|
789 | 791 | args, varargs, varkw, locals_ = inspect.getargvalues(frame_info.frame) |
|
790 |
if frame_info.executing is not None: |
|
|
792 | if frame_info.executing is not None: | |
|
791 | 793 | func = frame_info.executing.code_qualname() |
|
792 | 794 | else: |
|
793 |
func = |
|
|
795 | func = "?" | |
|
794 | 796 | if func == "<module>": |
|
795 | 797 | call = "" |
|
796 | 798 | else: |
@@ -840,16 +842,28 b' class VerboseTB(TBTools):' | |||
|
840 | 842 | if frame_info._sd is None: |
|
841 | 843 | assert False |
|
842 | 844 | # fast fallback if file is too long |
|
843 |
tpl_link = |
|
|
845 | tpl_link = "%s%%s%s" % (Colors.filenameEm, ColorsNormal) | |
|
844 | 846 | link = tpl_link % util_path.compress_user(frame_info.filename) |
|
845 |
level = |
|
|
846 | _line_format = PyColorize.Parser(style=self.color_scheme_table.active_scheme_name, parent=self).format2 | |
|
847 | level = "%s %s\n" % (link, call) | |
|
848 | _line_format = PyColorize.Parser( | |
|
849 | style=self.color_scheme_table.active_scheme_name, parent=self | |
|
850 | ).format2 | |
|
847 | 851 | first_line = frame_info.code.co_firstlineno |
|
848 | 852 | current_line = frame_info.lineno[0] |
|
849 |
return |
|
|
850 | _simple_format_traceback_lines(current_line, current_line-first_line, frame_info.raw_lines, Colors, lvals, | |
|
851 | _line_format))) | |
|
852 | #result += "\n".join(frame_info.raw_lines) | |
|
853 | return "%s%s" % ( | |
|
854 | level, | |
|
855 | "".join( | |
|
856 | _simple_format_traceback_lines( | |
|
857 | current_line, | |
|
858 | current_line - first_line, | |
|
859 | frame_info.raw_lines, | |
|
860 | Colors, | |
|
861 | lvals, | |
|
862 | _line_format, | |
|
863 | ) | |
|
864 | ), | |
|
865 | ) | |
|
866 | # result += "\n".join(frame_info.raw_lines) | |
|
853 | 867 | else: |
|
854 | 868 | result += "".join( |
|
855 | 869 | _format_traceback_lines( |
@@ -925,8 +939,14 b' class VerboseTB(TBTools):' | |||
|
925 | 939 | skipped = 0 |
|
926 | 940 | lastrecord = len(records) - 1 |
|
927 | 941 | for i, record in enumerate(records): |
|
928 | if not isinstance(record._sd, stack_data.RepeatedFrames) and self.skip_hidden: | |
|
929 | if record.frame.f_locals.get("__tracebackhide__", 0) and i != lastrecord: | |
|
942 | if ( | |
|
943 | not isinstance(record._sd, stack_data.RepeatedFrames) | |
|
944 | and self.skip_hidden | |
|
945 | ): | |
|
946 | if ( | |
|
947 | record.frame.f_locals.get("__tracebackhide__", 0) | |
|
948 | and i != lastrecord | |
|
949 | ): | |
|
930 | 950 | skipped += 1 |
|
931 | 951 | continue |
|
932 | 952 | if skipped: |
@@ -981,20 +1001,18 b' class VerboseTB(TBTools):' | |||
|
981 | 1001 | while cf is not None: |
|
982 | 1002 | source_file = inspect.getsourcefile(etb.tb_frame) |
|
983 | 1003 | lines, first = inspect.getsourcelines(etb.tb_frame) |
|
984 |
max_len = max(max_len, |
|
|
1004 | max_len = max(max_len, first + len(lines)) | |
|
985 | 1005 | tbs.append(cf) |
|
986 | 1006 | cf = cf.tb_next |
|
987 | 1007 | |
|
988 | ||
|
989 | ||
|
990 | 1008 | if max_len > FAST_THRESHOLD: |
|
991 | 1009 | FIs = [] |
|
992 | 1010 | for tb in tbs: |
|
993 | 1011 | frame = tb.tb_frame |
|
994 | lineno = frame.f_lineno, | |
|
1012 | lineno = (frame.f_lineno,) | |
|
995 | 1013 | code = frame.f_code |
|
996 | 1014 | filename = code.co_filename |
|
997 |
FIs.append( |
|
|
1015 | FIs.append(FrameInfo("Raw frame", filename, lineno, frame, code)) | |
|
998 | 1016 | return FIs |
|
999 | 1017 | res = list(stack_data.FrameInfo.stack_data(etb, options=options))[tb_offset:] |
|
1000 | 1018 | res = [FrameInfo._from_stack_data_FrameInfo(r) for r in res] |
@@ -1249,9 +1267,14 b' class AutoFormattedTB(FormattedTB):' | |||
|
1249 | 1267 | except KeyboardInterrupt: |
|
1250 | 1268 | print("\nKeyboardInterrupt") |
|
1251 | 1269 | |
|
1252 |
def structured_traceback( |
|
|
1253 | tb_offset=None, number_of_lines_of_context=5): | |
|
1254 | ||
|
1270 | def structured_traceback( | |
|
1271 | self, | |
|
1272 | etype=None, | |
|
1273 | value=None, | |
|
1274 | tb=None, | |
|
1275 | tb_offset=None, | |
|
1276 | number_of_lines_of_context=5, | |
|
1277 | ): | |
|
1255 | 1278 | etype: type |
|
1256 | 1279 | value: BaseException |
|
1257 | 1280 | # tb: TracebackType or tupleof tb types ? |
@@ -66,7 +66,6 b' class TerminalPdb(Pdb):' | |||
|
66 | 66 | # setup history only when we start pdb |
|
67 | 67 | if self.shell.debugger_history is None: |
|
68 | 68 | if self.shell.debugger_history_file is not None: |
|
69 | ||
|
70 | 69 | p = Path(self.shell.debugger_history_file).expanduser() |
|
71 | 70 | if not p.exists(): |
|
72 | 71 | p.touch() |
@@ -626,7 +626,6 b' class IPDoctestModule(pytest.Module):' | |||
|
626 | 626 | if _is_mocked(obj): |
|
627 | 627 | return |
|
628 | 628 | with _patch_unwrap_mock_aware(): |
|
629 | ||
|
630 | 629 | # Type ignored because this is a private function. |
|
631 | 630 | super()._find( # type:ignore[misc] |
|
632 | 631 | tests, obj, name, module, source_lines, globs, seen |
General Comments 0
You need to be logged in to leave comments.
Login now