diff --git a/IPython/Debugger.py b/IPython/Debugger.py index 1480fb9..02018a7 100644 --- a/IPython/Debugger.py +++ b/IPython/Debugger.py @@ -15,7 +15,7 @@ details on the PSF (Python Software Foundation) standard license, see: http://www.python.org/2.2.3/license.html -$Id: Debugger.py 2014 2007-01-05 10:36:58Z fperez $""" +$Id: Debugger.py 2154 2007-03-19 00:10:07Z fperez $""" #***************************************************************************** # @@ -48,18 +48,18 @@ from IPython.excolors import ExceptionColors # See if we can use pydb. has_pydb = False -prompt = 'ipdb>' +prompt = 'ipdb> ' try: import pydb if hasattr(pydb.pydb, "runl"): has_pydb = True from pydb import Pdb as OldPdb - prompt = 'ipydb>' except ImportError: pass if has_pydb: from pydb import Pdb as OldPdb + prompt = 'ipydb> ' else: from pdb import Pdb as OldPdb @@ -178,10 +178,11 @@ class Pdb(OldPdb): # Parent constructor: if has_pydb and completekey is None: - OldPdb.__init__(self,stdin=stdin,stdout=stdout) + OldPdb.__init__(self,stdin=stdin,stdout=Term.cout) #stdout) else: OldPdb.__init__(self,completekey,stdin,stdout) - self.prompt = prompt # The default prompt is '(Pdb)' + + self.prompt = prompt # The default prompt is '(Pdb)' # IPython changes... self.is_pydb = has_pydb @@ -321,7 +322,7 @@ class Pdb(OldPdb): def print_stack_entry(self,frame_lineno,prompt_prefix='\n-> ', context = 3): - frame, lineno = frame_lineno + #frame, lineno = frame_lineno print >>Term.cout, self.format_stack_entry(frame_lineno, '', context) def format_stack_entry(self, frame_lineno, lprefix=': ', context = 3): @@ -365,7 +366,11 @@ class Pdb(OldPdb): # The level info should be generated in the same format pdb uses, to # avoid breaking the pdbtrack functionality of python-mode in *emacs. - ret.append('> %s(%s)%s\n' % (link,lineno,call)) + if frame is self.curframe: + ret.append('> ') + else: + ret.append(' ') + ret.append('%s(%s)%s\n' % (link,lineno,call)) start = lineno - 1 - context//2 lines = linecache.getlines(filename) @@ -375,7 +380,10 @@ class Pdb(OldPdb): for i,line in enumerate(lines): show_arrow = (start + 1 + i == lineno) - ret.append(self.__format_line(tpl_line_em, filename, + linetpl = (frame is self.curframe or show_arrow) \ + and tpl_line_em \ + or tpl_line + ret.append(self.__format_line(linetpl, filename, start + 1 + i, line, arrow = show_arrow) ) diff --git a/IPython/Extensions/ipy_pydb.py b/IPython/Extensions/ipy_pydb.py index 10d9b71..ee30523 100755 --- a/IPython/Extensions/ipy_pydb.py +++ b/IPython/Extensions/ipy_pydb.py @@ -18,7 +18,7 @@ def call_pydb(self, args): argl = arg_split(args) # print argl # dbg if len(inspect.getargspec(pydb.runv)[0]) == 2: - pdb = Debugger.Pdb() + pdb = Debugger.Pdb(color_scheme=self.rc.colors) ip.IP.history_saving_wrapper( lambda : pydb.runv(argl, pdb) )() else: ip.IP.history_saving_wrapper( lambda : pydb.runv(argl) )() diff --git a/IPython/genutils.py b/IPython/genutils.py index 6979116..09ab0b4 100644 --- a/IPython/genutils.py +++ b/IPython/genutils.py @@ -5,7 +5,7 @@ General purpose utilities. This is a grab-bag of stuff I find useful in most programs I write. Some of these things are also convenient when working at the command line. -$Id: genutils.py 2152 2007-03-18 20:13:35Z fperez $""" +$Id: genutils.py 2154 2007-03-19 00:10:07Z fperez $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez. @@ -67,6 +67,10 @@ class IOStream: # if we get here, something is seriously broken. print >> sys.stderr, \ 'ERROR - failed to write data to stream:', self.stream + + def close(self): + pass + class IOTerm: """ Term holds the file or file-like objects for handling I/O operations. diff --git a/doc/ChangeLog b/doc/ChangeLog index dbdb700..08ddfe8 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,12 @@ 2007-03-18 Fernando Perez + * IPython/genutils.py (IOStream.close): small patch by + R. Bernstein for improved pydb support. + + * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by + DaveS to improve support of debugging under + NTEmacs, including improved pydb behavior. + * IPython/Magic.py (magic_prun): Fix saving of profile info for Python 2.5, where the stats object API changed a little. Thanks to a bug report by Paul Smith . diff --git a/doc/ipython.el b/doc/ipython.el index a123605..b90b4de 100644 --- a/doc/ipython.el +++ b/doc/ipython.el @@ -6,7 +6,7 @@ ;; URL: http://ipython.scipy.org ;; Compatibility: Emacs21, XEmacs21 ;; FIXME: #$@! INPUT RING -(defconst ipython-version "$Revision: 1851 $" +(defconst ipython-version "$Revision: 2154 $" "VC version number.") ;;; Commentary @@ -195,12 +195,13 @@ the second for a 'normal' command, and the third for a multiline command.") ;;^ File \"\\(.*?\\)\", line \\([0-9]+\\)" (setq py-traceback-line-re - "\\(^[^\t ].+?\\.py\\).*\n +[0-9]+[^\00]*?\n-+> \\([0-9]+\\) +") + "\\(^[^\t >].+?\\.py\\).*\n +[0-9]+[^\00]*?\n-+> \\([0-9]+\\)+") + ;; Recognize the ipython pdb, whose prompt is 'ipdb>' or 'ipydb>' ;;instead of '(Pdb)' (setq py-pdbtrack-input-prompt "\n[(<]*[Ii]?[Pp]y?db[>)]+ ") - (setq py-pydbtrack-input-prompt "\n[(]*ipydb[>)]+ ") + (setq pydb-pydbtrack-input-prompt "\n[(]*ipydb[>)]+ ") (setq py-shell-input-prompt-1-regexp "^In \\[[0-9]+\\]: *" py-shell-input-prompt-2-regexp "^ [.][.][.]+: *" ) diff --git a/doc/manual_base.lyx b/doc/manual_base.lyx index 32948c6..b0c1b0b 100644 --- a/doc/manual_base.lyx +++ b/doc/manual_base.lyx @@ -1176,7 +1176,7 @@ PyWin32 PyWin32 \family default from -\begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond} +\begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/pywin32} \end_inset @@ -1186,33 +1186,39 @@ PyWin32 \begin_layout Enumerate \family typewriter -CTypes +PyReadline \family default - from -\begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes} + for Windows from +\begin_inset LatexCommand \htmlurl{http://ipython.scipy.org/moin/PyReadline/Intro} \end_inset - (you -\emph on -must -\emph default - use version 0.9.1 or newer). +. + That page contains further details on using and configuring the system + to your liking. \end_layout \begin_layout Enumerate - +Finally, +\emph on +only +\emph default +if you are using Python 2.3 or 2.4, you need \family typewriter -PyReadline +CTypes \family default - for Windows from -\begin_inset LatexCommand \htmlurl{http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro} + from +\begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes} \end_inset -. - That page contains further details on using and configuring the system - to your liking. + (you +\emph on +must +\emph default + use version 0.9.1 or newer). + This package is included in Python 2.5, so you don't need to manually get + it if your Python version is 2.5 or newer. \end_layout \begin_layout Standard