aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py3/IPython/core/debugger.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-05-11 14:26:05 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-05-11 14:35:40 +0300
commitebf1daa4c46f1c48865e6db613db68751770ccea (patch)
treed58d354f25c8106d5add16f6e2979d0e353e0318 /contrib/python/ipython/py3/IPython/core/debugger.py
parent8173b4515355158a5787dcb12aa6036874776101 (diff)
downloadydb-ebf1daa4c46f1c48865e6db613db68751770ccea.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/ipython/py3/IPython/core/debugger.py')
-rw-r--r--contrib/python/ipython/py3/IPython/core/debugger.py86
1 files changed, 38 insertions, 48 deletions
diff --git a/contrib/python/ipython/py3/IPython/core/debugger.py b/contrib/python/ipython/py3/IPython/core/debugger.py
index b409416ece..a858972bb5 100644
--- a/contrib/python/ipython/py3/IPython/core/debugger.py
+++ b/contrib/python/ipython/py3/IPython/core/debugger.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
Pdb debugger class.
@@ -101,17 +100,25 @@ All the changes since then are under the same license as IPython.
#
#*****************************************************************************
+from __future__ import annotations
+
import inspect
import linecache
-import sys
-import re
import os
+import re
+import sys
+from contextlib import contextmanager
+from functools import lru_cache
from IPython import get_ipython
-from contextlib import contextmanager
-from IPython.utils import PyColorize
-from IPython.utils import coloransi, py3compat
from IPython.core.excolors import exception_colors
+from IPython.utils import PyColorize, coloransi, py3compat
+
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+ # otherwise circular import
+ from IPython.core.interactiveshell import InteractiveShell
# skip module docstests
__skip_doctest__ = True
@@ -149,16 +156,10 @@ def BdbQuit_excepthook(et, ev, tb, excepthook=None):
parameter.
"""
raise ValueError(
- "`BdbQuit_excepthook` is deprecated since version 5.1",
+ "`BdbQuit_excepthook` is deprecated since version 5.1. It is still arround only because it is still imported by ipdb.",
)
-def BdbQuit_IPython_excepthook(self, et, ev, tb, tb_offset=None):
- raise ValueError(
- "`BdbQuit_IPython_excepthook` is deprecated since version 5.1",
- DeprecationWarning, stacklevel=2)
-
-
RGX_EXTRA_INDENT = re.compile(r'(?<=\n)\s+')
@@ -191,6 +192,8 @@ class Pdb(OldPdb):
"""
+ shell: InteractiveShell
+
if CHAIN_EXCEPTIONS:
MAX_CHAINED_EXCEPTION_DEPTH = 999
@@ -261,21 +264,6 @@ class Pdb(OldPdb):
C = coloransi.TermColors
cst = self.color_scheme_table
- cst['NoColor'].colors.prompt = C.NoColor
- cst['NoColor'].colors.breakpoint_enabled = C.NoColor
- cst['NoColor'].colors.breakpoint_disabled = C.NoColor
-
- cst['Linux'].colors.prompt = C.Green
- cst['Linux'].colors.breakpoint_enabled = C.LightRed
- cst['Linux'].colors.breakpoint_disabled = C.Red
-
- cst['LightBG'].colors.prompt = C.Blue
- cst['LightBG'].colors.breakpoint_enabled = C.LightRed
- cst['LightBG'].colors.breakpoint_disabled = C.Red
-
- cst['Neutral'].colors.prompt = C.Blue
- cst['Neutral'].colors.breakpoint_enabled = C.LightRed
- cst['Neutral'].colors.breakpoint_disabled = C.Red
# Add a python parser so we can syntax highlight source while
# debugging.
@@ -471,24 +459,11 @@ class Pdb(OldPdb):
return line
- def new_do_frame(self, arg):
- OldPdb.do_frame(self, arg)
-
def new_do_quit(self, arg):
-
- if hasattr(self, 'old_all_completions'):
- self.shell.Completer.all_completions = self.old_all_completions
-
return OldPdb.do_quit(self, arg)
do_q = do_quit = decorate_fn_with_doc(new_do_quit, OldPdb.do_quit)
- def new_do_restart(self, arg):
- """Restart command. In the context of ipython this is exactly the same
- thing as 'quit'."""
- self.msg("Restart doesn't make sense here. Using 'quit' instead.")
- return self.do_quit(arg)
-
def print_stack_trace(self, context=None):
Colors = self.color_scheme_table.active_colors
ColorsNormal = Colors.Normal
@@ -941,22 +916,37 @@ class Pdb(OldPdb):
Utility to tell us whether we are in a decorator internal and should stop.
"""
-
# if we are disabled don't skip
if not self._predicates["debuggerskip"]:
return False
+ return self._cachable_skip(frame)
+
+ @lru_cache(1024)
+ def _cached_one_parent_frame_debuggerskip(self, frame):
+ """
+ Cache looking up for DEBUGGERSKIP on parent frame.
+
+ This should speedup walking through deep frame when one of the highest
+ one does have a debugger skip.
+
+ This is likely to introduce fake positive though.
+ """
+ while getattr(frame, "f_back", None):
+ frame = frame.f_back
+ if self._get_frame_locals(frame).get(DEBUGGERSKIP):
+ return True
+ return None
+
+ @lru_cache(1024)
+ def _cachable_skip(self, frame):
# if frame is tagged, skip by default.
if DEBUGGERSKIP in frame.f_code.co_varnames:
return True
# if one of the parent frame value set to True skip as well.
-
- cframe = frame
- while getattr(cframe, "f_back", None):
- cframe = cframe.f_back
- if self._get_frame_locals(cframe).get(DEBUGGERSKIP):
- return True
+ if self._cached_one_parent_frame_debuggerskip(frame):
+ return True
return False