gotcha / ipdb

Integration of IPython pdb
BSD 3-Clause "New" or "Revised" License
1.85k stars 146 forks source link

heads-up : Change in IPython behavior. #196

Closed Carreau closed 11 months ago

Carreau commented 4 years ago

in https://github.com/ipython/ipython/pull/12359 I'll change IPtyhon default behavior to skip hidden frames with a toggle. Not sure if you want to expose this in some way with ipdb

gotcha commented 4 years ago

I quickly went through ipython/ipython#12359. I do not understand the goal. Would you mind to expand ?

Carreau commented 4 years ago

Here is an example.

In [1]: from IPython.terminal.debugger import set_trace
   ...:
   ...: def g():
   ...:     import ipdb
   ...:     set_trace()
   ...:     raise ValueError
   ...:
   ...: def f(n):
   ...:
   ...:     __tracebackhide__ = True
   ...:     if n < 0:
   ...:         g()
   ...:     else:
   ...:         f(n-1)
   ...:
   ...: def a():
   ...:     f(5)
   ...: a()
> <ipython-input-1-2b5dbc49c3e4>(6)g()
      4     import ipdb
      5     set_trace()
----> 6     raise ValueError
      7
      8 def f(n):

ipdb> w
    [... skipping 12 hidden frame(s)]

  <ipython-input-1-2b5dbc49c3e4>(18)<module>()
     14         f(n-1)
     15
     16 def a():
     17     f(5)
---> 18 a()

  <ipython-input-1-2b5dbc49c3e4>(17)a()
     14         f(n-1)
     15
     16 def a():
---> 17     f(5)
     18 a()

    [... skipping 7 hidden frame(s)]

> <ipython-input-1-2b5dbc49c3e4>(6)g()
      4     import ipdb
      5     set_trace()
----> 6     raise ValueError
      7
      8 def f(n):

See the [skipping N hidden frames.].

gotcha commented 4 years ago

I had understood that the mean was to hide frames. What is not obvious to me is why you would want to hide them ?

ecotner commented 1 year ago

I am having an issue and the hidden frames are preventing me from debugging my code. How can I disable this behavior and go back to showing all frames by default?

Carreau commented 1 year ago
ipdb> help

Documented commands (type help <topic>):
========================================
EOF    commands   enable      ll        pp       s                until
...    ...        ...         ...       ...      skip_hidden      ...
...    ...        ...         ...       ...      skip_predicates  ...

Miscellaneous help topics:
==========================
exec  pdb

Undocumented commands:
======================
interact

ipdb> skip_hidden false

And you should be good to go.

You can tweak individual skip rules, or add your own:

ipdb> skip_predicates
current predicates:
    tbhide : True
    readonly : False
    ipython_internal : True
    debuggerskip : True
ipdb> skip_predicates tbhide false
ipdb> skip_predicates
current predicates:
    tbhide : False
    readonly : False
    ipython_internal : True
    debuggerskip : True
Carreau commented 11 months ago

I think we can close this one as this was just a FYI