[IPython-dev] pydb 1.19 released, thoughts about integration

Ville M. Vainio vivainio at gmail.com
Fri Oct 27 14:36:58 CDT 2006


On 10/27/06, R. Bernstein <rocky at panix.com> wrote:

> I tried that. And I assume you were in the directory that ipython was
> located in which is what I tried. The interesting question is what's
> the value of frame.f_code.co_filename and if that's a valid file name,
> where is it? Probably %pdb on would let you extract that information.

Ok, now I ran %pdb and %run -d ipython.py and got this traceback:

Q:\ipython\IPython\Debugger.py in __init__(self=<IPython.Debugger.Pdb
instance at 0x00F17C88>, color_scheme='Linux', completekey=None,
stdin=None, stdout=None)
    103             # IPython changes...
    104             self.prompt = prompt # The default prompt is '(Pdb)'
    105             self.is_pydb = prompt == 'ipydb>'
    106
    107             if self.is_pydb:
    108
    109                 # iplib.py's ipalias seems to want pdb's checkline
    110                 # which located in pydb.fn
    111                 import pydb.fns
    112                 self.checkline = lambda filename, lineno: \
    113                                  pydb.fns.checkline(self,
filename, lineno)
    114
    115                 self.curframe = None
    116                 self.do_restart = self.new_do_restart
    117
--> 118                 self.old_all_completions =
__IPYTHON__.Completer.all_completions
        self.old_all_completions = undefined
        global __IPYTHON__.Completer.all_completions = undefined
    119
__IPYTHON__.Completer.all_completions=self.all_completions
    120
    121                 # Do we have access to pydb's list command parser?
    122                 self.do_list =
decorate_fn_with_doc(self.list_command_pydb,
    123                                                     OldPdb.do_list)
    124                 self.do_l     = self.do_list
    125                 self.do_frame = decorate_fn_with_doc(self.new_do_frame,
    126                                                      OldPdb.do_frame)
    127
    128             self.aliases = {}
    129
    130             # Create color table: we copy the default one from
the traceback
    131             # module and add a few attributes needed for debugging
    132             self.color_scheme_table = ExceptionColors.copy()
    133
<type 'exceptions.AttributeError'>: 'InteractiveShell' object has no
attribute 'Completer'
**********************************************************************

>  > BTW, does pydb nuke the readline history in %run -d for you? I mean
>  > that, after the debug session is over, you can't go back to commands
>  > you executed before %run -d.
>
> If you run "set history save on", the history is be saved in
> $HOME/.pydbhist. The default is not to save the history, same as
> gdb. You could put this command in your $HOME/.pydbrc if that's what
> you want. But when I just tried it I don't see that .pydbrc is getting
> read. I'll check into this.

But the whole history is lost, including "normal" ipython stuff that
precedes %run -d. This is quite undesirable default behaviour.

> Yes, I think a separate %pydb magic would be better for a couple of
> reasons. First %run -d has no provision for sending options to the
> debugger. Second, because %run -d copies some of the top-level pdb
> debugger loop, a soft restart which is basically raising an exception
> caught in that loop can't done without more modification. To add it to
> that code would be increasing the wrongness, if not also the
> complexity.
>
> The way I've been using pydb inside ipython is real simple:
>   import pydb  # Needed once
>   pydb.runl(args1, arg2, arg3...)
>
> If the runl could be run via magic that'd be great.

Great, we're going to go with separate %pydb then. Screw %run -d for
pydb purposes, we should reserve it for plain pdb use only.

> There is perhaps one slight subtlety or ugliness. The above is the
> programming way to do things, not a command-line way. When you run any
> python program from the script's standpoint it gets the arguments as a
> list. When you run "%run -d" what's getting sent is a string. You
> can't just do a split on spaces to turn this string into a parameter
> list because there may be embedded blanks in string
> options/parameters.

shlex.split helps here:

[ipython]|4> shlex.split('hello world "and good luck"')
         <4> ['hello', 'world', 'and good luck']

-- 
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'


More information about the IPython-dev mailing list