##// END OF EJS Templates
Cache debugger skip frame predicate (#14386)...
M Bussonnier -
r28709:a3074b8c merge
parent child Browse files
Show More
@@ -1,4 +1,3 b''
1 # -*- coding: utf-8 -*-
2 """
1 """
3 Pdb debugger class.
2 Pdb debugger class.
4
3
@@ -101,17 +100,25 b' All the changes since then are under the same license as IPython.'
101 #
100 #
102 #*****************************************************************************
101 #*****************************************************************************
103
102
103 from __future__ import annotations
104
104 import inspect
105 import inspect
105 import linecache
106 import linecache
106 import sys
107 import re
108 import os
107 import os
108 import re
109 import sys
110 from contextlib import contextmanager
111 from functools import lru_cache
109
112
110 from IPython import get_ipython
113 from IPython import get_ipython
111 from contextlib import contextmanager
112 from IPython.utils import PyColorize
113 from IPython.utils import coloransi, py3compat
114 from IPython.core.excolors import exception_colors
114 from IPython.core.excolors import exception_colors
115 from IPython.utils import PyColorize, coloransi, py3compat
116
117 from typing import TYPE_CHECKING
118
119 if TYPE_CHECKING:
120 # otherwise circular import
121 from IPython.core.interactiveshell import InteractiveShell
115
122
116 # skip module docstests
123 # skip module docstests
117 __skip_doctest__ = True
124 __skip_doctest__ = True
@@ -191,6 +198,8 b' class Pdb(OldPdb):'
191
198
192 """
199 """
193
200
201 shell: InteractiveShell
202
194 if CHAIN_EXCEPTIONS:
203 if CHAIN_EXCEPTIONS:
195 MAX_CHAINED_EXCEPTION_DEPTH = 999
204 MAX_CHAINED_EXCEPTION_DEPTH = 999
196
205
@@ -471,24 +480,11 b' class Pdb(OldPdb):'
471
480
472 return line
481 return line
473
482
474 def new_do_frame(self, arg):
475 OldPdb.do_frame(self, arg)
476
477 def new_do_quit(self, arg):
483 def new_do_quit(self, arg):
478
479 if hasattr(self, 'old_all_completions'):
480 self.shell.Completer.all_completions = self.old_all_completions
481
482 return OldPdb.do_quit(self, arg)
484 return OldPdb.do_quit(self, arg)
483
485
484 do_q = do_quit = decorate_fn_with_doc(new_do_quit, OldPdb.do_quit)
486 do_q = do_quit = decorate_fn_with_doc(new_do_quit, OldPdb.do_quit)
485
487
486 def new_do_restart(self, arg):
487 """Restart command. In the context of ipython this is exactly the same
488 thing as 'quit'."""
489 self.msg("Restart doesn't make sense here. Using 'quit' instead.")
490 return self.do_quit(arg)
491
492 def print_stack_trace(self, context=None):
488 def print_stack_trace(self, context=None):
493 Colors = self.color_scheme_table.active_colors
489 Colors = self.color_scheme_table.active_colors
494 ColorsNormal = Colors.Normal
490 ColorsNormal = Colors.Normal
@@ -941,11 +937,14 b' class Pdb(OldPdb):'
941 Utility to tell us whether we are in a decorator internal and should stop.
937 Utility to tell us whether we are in a decorator internal and should stop.
942
938
943 """
939 """
944
945 # if we are disabled don't skip
940 # if we are disabled don't skip
946 if not self._predicates["debuggerskip"]:
941 if not self._predicates["debuggerskip"]:
947 return False
942 return False
948
943
944 return self._cachable_skip(frame)
945
946 @lru_cache
947 def _cachable_skip(self, frame):
949 # if frame is tagged, skip by default.
948 # if frame is tagged, skip by default.
950 if DEBUGGERSKIP in frame.f_code.co_varnames:
949 if DEBUGGERSKIP in frame.f_code.co_varnames:
951 return True
950 return True
General Comments 0
You need to be logged in to leave comments. Login now