From 8d0d6dca14828ab92671821ada629e173d41dc9d 2021-06-01 16:46:03 From: Matthias Bussonnier Date: 2021-06-01 16:46:03 Subject: [PATCH] Document how to change the default predicates for the debugger. Also make the default a class attribute for progrmatic modifications --- diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py index 29d5794..b25d2d7 100644 --- a/IPython/core/debugger.py +++ b/IPython/core/debugger.py @@ -199,21 +199,39 @@ class Pdb(OldPdb): for a standalone version that uses prompt_toolkit, see `IPython.terminal.debugger.TerminalPdb` and `IPython.terminal.debugger.set_trace()` + + + This debugger can hide and skip frames that are tagged according to some predicates. + See the `skip_predicates` commands. + """ + default_predicates = {"tbhide": True, "readonly": False, "ipython_internal": True} + def __init__(self, color_scheme=None, completekey=None, stdin=None, stdout=None, context=5, **kwargs): """Create a new IPython debugger. - :param color_scheme: Deprecated, do not use. - :param completekey: Passed to pdb.Pdb. - :param stdin: Passed to pdb.Pdb. - :param stdout: Passed to pdb.Pdb. - :param context: Number of lines of source code context to show when + Parameters + ---------- + color_scheme : default None + Deprecated, do not use. + completekey : default None + Passed to pdb.Pdb. + stdin : default None + Passed to pdb.Pdb. + stdout : default None + Passed to pdb.Pdb. + context : int + Number of lines of source code context to show when displaying stacktrace information. - :param kwargs: Passed to pdb.Pdb. - The possibilities are python version dependent, see the python - docs for more info. + **kwargs + Passed to pdb.Pdb. + + Notes + ----- + The possibilities are python version dependent, see the python + docs for more info. """ # Parent constructor: @@ -283,7 +301,7 @@ class Pdb(OldPdb): self.skip_hidden = True # list of predicates we use to skip frames - self._predicates = {"tbhide": True, "readonly": False, "ipython_internal": True} + self._predicates = self.default_predicates def set_colors(self, scheme): """Shorthand access to the color table scheme selector method.""" @@ -563,6 +581,10 @@ class Pdb(OldPdb): Call without arguments to see the current values. + To permanently change the value of an option add the corresponding + command to your ``~/.pdbrc`` file. If you are programmatically using the + Pdb instance you can also change the ``default_predicates`` class + attribute. """ if not args.strip(): print("current predicates:") diff --git a/docs/source/whatsnew/version7.rst b/docs/source/whatsnew/version7.rst index 1156011..a8768d6 100644 --- a/docs/source/whatsnew/version7.rst +++ b/docs/source/whatsnew/version7.rst @@ -64,6 +64,22 @@ Note that the ``readonly`` predicate may increase disk access as we check for file access permission for all frames on many command invocation, but is usually cached by operating systems. Let us know if you encounter any issues. +As the IPython debugger does not use the traitlets infrastructure for +configuration, by editing your ``.pdbrc`` files and appending commands you would +like to be executed just before entering the interactive prompt. For example: + + +.. code:: + + # file : ~/.pdbrc + skip_predicates readonly True + skip_predicates tbhide False + +Will hide read only frames by default and show frames marked with +``__tracebackhide__``. + + + Thanks ------ @@ -236,14 +252,14 @@ was exceptionally no release last month. - Docs docs formatting that make the install commands work on zsh :ghpull:`12587` - Always display the last frame in tracebacks even if hidden with - ``__traceback_hide__`` :ghpull:`12601` + ``__tracebackhide__`` :ghpull:`12601` - Avoid an issue where a callback can be registered multiple times. :ghpull:`12625` - Avoid an issue in debugger mode where frames changes could be lost. :ghpull:`12627` - Never hide the frames that invoke a debugger, even if marked as hidden by - ``__traceback_hide__`` :ghpull:`12631` + ``__tracebackhide__`` :ghpull:`12631` - Fix calling the debugger in a recursive manner :ghpull:`12659` @@ -394,7 +410,7 @@ Change of API and exposed objects automatically detected using `frappuccino `_ (still in beta): -The following items are new and mostly related to understanding ``__tracebackbhide__``:: +The following items are new and mostly related to understanding ``__tracebackbide__``:: + IPython.core.debugger.Pdb.do_down(self, arg) + IPython.core.debugger.Pdb.do_skip_hidden(self, arg)