Cannot browse pdb/ipdb history in qtconsole #682

Closed
rabbitmcrabbit opened this Issue Aug 6, 2011 · 18 comments

Projects

None yet
Contributor

If I turn %pdb on and generate an Exception, or if I execute pdb.set_trace(), so that I'm at a (pdb) or ipdb> shell, then I do not appear to have access to a history of recent commands -- i.e. I cannot retrieve previous commands from within pdb or from the python session prior to launching pdb. Likewise, after exiting the pdb session and returning to the main prompt, history only contains commands entered outside of pdb.

This is only the case within the qtconsole -- a terminal ipython session has a contiguous history across the main session and any pdb subsessions.

Owner

We've tried to exclude history in subsessions, with the idea that that's a different set of commands, and when you return to the IPython shell, we wanted pressing to get the last command entered at an IPython prompt. So in a sense, the bug is that that's not working at the terminal.

But maybe we should reconsider the design. You may want to raise this on the mailing list.

Contributor

That's a fair design point. But there's another half to the bug -- there's no history at all from within the pdb subsession.

Owner
minrk commented Sep 9, 2011

pdb previously got the history 'for free' by inheriting the readline environment. Since the qtconsole doesn't use readline at all for history, that inherited environment is empty. To initialize the pdb history with IPython's session will require dumping the real (sqlite) history session into a readline history at the invocation of pdb.

Contributor

ok, but does that solve all of the problem? If I invoke a new pdb trace, not
only is its history empty, but it doesn't seem to create an ongoing history
that I can access. e.g. if I type in 1+1 and get out 2 in the pdb session,
pressing "up" or Ctrl-P does nothing.

On Fri, Sep 9, 2011 at 10:51 PM, Min RK <
reply@reply.github.com>wrote:

pdb previously got the history 'for free' by inheriting the readline
environment. Since the qtconsole doesn't use readline at all for history,
that inherited environment is empty. To initialize the pdb history with
IPython's session will require dumping the real (sqlite) history session
into a readline history at the invocation of pdb.

Reply to this email directly or view it on GitHub:
#682 (comment)

Owner
minrk commented Sep 10, 2011

No, thinking about it now, I don't think it solves any of the the problem. ipdb would have the history on the kernel, but since the frontend doesn't use the readline history it wouldn't much matter, since you wouldn't actually access it.

As far as I understand what's going on, ipdb is just hooking getting lines from raw_input. I don't think the frontend has any knowledge that ipdb is anything but arbitrary Python code asking for input, which probably doesn't make sense in general to hook up to the frontend's history.

In order for ipdb to have access to a sensible history, we need to do one of the following:

  • add a switch or message, so that the frontend knows whether raw_input requests should engage with the frontend's history
  • treat all raw_input requests as having access to the history (easy, but bad in general)
  • record history of raw_input requests separately, so that you are navigating an entirely independent list of the actual IPython history
  • add first-class support for things like ipdb, so the frontend has full knowledge of the environment, and can try to make the best decisions (ideal, but a fair amount of work).

In general, running code (scripts, subprocesses, debuggers) that expects anything other than basic text input is just not yet supported in the qtconsole. A lot of code that 'just works' when running in the same terminal really doesn't when you don't have a terminal (the qtconsole is not a terminal emulator), which is extra frustrating when it looks very similar.

We definitely need to improve debugger behavior, as they just aren't particularly functional with the qtconsole as it is.

Contributor
pwaller commented Sep 22, 2013

Ping. Seems there are a few people wanting history with ipdb, looking around the internet.

http://stackoverflow.com/questions/17138106/ipython-ipdb-when-invoked-via-ipdb-set-trace-does-not-remember-the-command-h

If I'm understanding correctly, we don't get history because ipdb is really just a thin layer around the original pdb, which doesn't call the necessary store_inputs to record the history for each line entered.

Any takers?

myoung8 commented Jul 24, 2014

+1 for history within an ipdb session

+1

+1 Guys do you have an update on this? Is this feature going to be included soon or is there a work around for this? I would love to have this as it would save a lot of time while debugging.

Contributor
pwaller commented Nov 8, 2014

👍 once more

👍 Would be very helpful to have an history in ipdb for the qtconsole.

Contributor
dsblank commented Nov 14, 2014

I think that because this is a qtconsole enhancement, if someone wants the functionality, you will have to write it. And then please donate it back to IPython with a Pull Request. (This may sound like an intimidating process if you don't know the IPython internals, but having just done this I can say that the IPython team is very helpful in guiding one through the process. Give it a try!)

Contributor
pwaller commented Nov 17, 2014

Is this strictly a qtconsole enhancement? I somehow came to understand this was a problem with ipdb in general.

Contributor
joonro commented Nov 17, 2014

I agree - this happens in the notebook as well. Terminal IPython is the only one without this issue for the reasons explained by Min.

+1 for history within ipdb, ideally isolated from history within IPython. The things I do in IPython are not really related to those in ipdb.

ned2 commented Mar 12, 2016

@pwaller is right, this is a limitation of ipdb in general, and one that has been frustrating me ever since I started using ipdb.

Owner
Carreau commented Jul 21, 2016

Hi,

The qtconsole has been moved to https://github.com/jupyter/qtconsole, so it shoudl likely be moved therefor the qtconsole part.

This will allow us to keep the number of IPython issues smaller and focussed on IPython. As currently there is an extremely high number of opened issues , it make it really hard to find if a problem is actually known, or going to be worked one.

The issue of debugger is a more general issue on the Jupyter Project and we are aware of that.
I'm not sure this issue in particular reflect nicely what the state is, and leaving it open will just incite people to +1, while there likely be no work directly on that.

Feel free to reopen if need, for the time being I'm going to close this. But a fresh issue that lay out nicely all the moving pieces and requirement would be prefered.

Thanks.

@Carreau Carreau closed this Jul 21, 2016
@minrk minrk modified the milestone: wishlist, not ipython Jan 9, 2017

+1 for history, it blows my mind that I have to retype a line in the debugger any time I want to re-run a command or a similar one. My lowly cygwin terminal can handle this much...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment