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