[IPython-dev] making pdoc, pdef, and pinfo more generally useful (Was Re: Patches to use pydb instead of pdb for debugging)

R. Bernstein rocky at panix.com
Fri Oct 13 18:48:35 EDT 2006

Ville M. Vainio writes:
 > On 10/13/06, Ville M. Vainio <vivainio at gmail.com> wrote:
 > > On 10/13/06, R. Bernstein <rocky at panix.com> wrote:
 > >
 > > > A revised patch follows.
 > > ....
 > >
 > > Now (after applying patches), when I quit ipydb after postmortem
 > > debugging (%pdb 1 and %run whichpy.py):
 > >
 > > ipydb>q
 > > *** ERROR ***
 > > This version of pdb has a bug and crashed.
 > > Returning to IPython...
 > >
 > > Any idea what's going on?
 > Ok, I got over that 

Good. What was the problem? I didn't encounter that when I initially
tried (which means the patch below might have the same problem).

> but now I get:

 > [lscripts]|7> %run -d whichpy.py cp
 > ---------------------------------------------------------------------------
 >    1518                     if not checkline:
 >    1519                         for bp in range(bp+1,bp+maxtries+1):
 > <type 'exceptions.AttributeError'>: Pdb instance has no attribute 'checkline'


When I look at that code in magic_run to set up a program to
debug it, I kringe. It looks to me like a couple of problems in pdb
are getting worked around, but I'm not really sure what those problems

Something's probably wrong. Sure, maybe in the past you couldn't get
pdb changed all that quickly, but with pydb that's not the case. Talk
to me!

What I had been using to debug a program was this:

  import pydb
  pydb.runl("debug-opt1", "debug-opt2", "program", "prog-opt1", ...)

This works whether you are in ipython, the stock python shell, or
running out of your own Python program not run from a shell.

What ipython's "run -d" doesn't give you is the ablity to pass options
to the debugger. For pdb that's not an issue because, well, pdb
doesn't *have* any debugger options. 
That said, for now we'll limp things along. The particular error you
encountered has to do with a somewhat general function (testing to see
if a line is someplace you can put a breakpoint) which was moved out
of the debugger class into a class of auxiliary functions. If
Magic.magic_run wants to call that function in order to figure out
where to put a breakpoint, so be it. I've added that as a lambda
function in the Debugger __init__. 

But of course there were a number of other problems. For some of them
changes were more appropriate in pydb than in ipython. And as a
result, I think initially I reduce the scope even more. You need the
latest version of pydb (and Python 2.5). 

For now and testing use what's just been checked in to CVS.

Here is a revised set of patches off of the current SVN.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pydb-take3.patch
Type: application/octet-stream
Size: 10309 bytes
Desc: 3rd try at patches for pydb support.
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20061013/1e3ed87d/attachment.obj>

More information about the IPython-dev mailing list