##// END OF EJS Templates
- Added patches for better pydb and Emacs support....
fperez -
r552:41204998
parent child
Show More
@@ -15,7 +15,7 details on the PSF (Python Software Foundation) standard license, see:
15
15
16 http://www.python.org/2.2.3/license.html
16 http://www.python.org/2.2.3/license.html
17
17
18 $Id: Debugger.py 2014 2007-01-05 10:36:58Z fperez $"""
18 $Id: Debugger.py 2154 2007-03-19 00:10:07Z fperez $"""
19
19
20 #*****************************************************************************
20 #*****************************************************************************
21 #
21 #
@@ -48,18 +48,18 from IPython.excolors import ExceptionColors
48
48
49 # See if we can use pydb.
49 # See if we can use pydb.
50 has_pydb = False
50 has_pydb = False
51 prompt = 'ipdb>'
51 prompt = 'ipdb> '
52 try:
52 try:
53 import pydb
53 import pydb
54 if hasattr(pydb.pydb, "runl"):
54 if hasattr(pydb.pydb, "runl"):
55 has_pydb = True
55 has_pydb = True
56 from pydb import Pdb as OldPdb
56 from pydb import Pdb as OldPdb
57 prompt = 'ipydb>'
58 except ImportError:
57 except ImportError:
59 pass
58 pass
60
59
61 if has_pydb:
60 if has_pydb:
62 from pydb import Pdb as OldPdb
61 from pydb import Pdb as OldPdb
62 prompt = 'ipydb> '
63 else:
63 else:
64 from pdb import Pdb as OldPdb
64 from pdb import Pdb as OldPdb
65
65
@@ -178,10 +178,11 class Pdb(OldPdb):
178
178
179 # Parent constructor:
179 # Parent constructor:
180 if has_pydb and completekey is None:
180 if has_pydb and completekey is None:
181 OldPdb.__init__(self,stdin=stdin,stdout=stdout)
181 OldPdb.__init__(self,stdin=stdin,stdout=Term.cout) #stdout)
182 else:
182 else:
183 OldPdb.__init__(self,completekey,stdin,stdout)
183 OldPdb.__init__(self,completekey,stdin,stdout)
184 self.prompt = prompt # The default prompt is '(Pdb)'
184
185 self.prompt = prompt # The default prompt is '(Pdb)'
185
186
186 # IPython changes...
187 # IPython changes...
187 self.is_pydb = has_pydb
188 self.is_pydb = has_pydb
@@ -321,7 +322,7 class Pdb(OldPdb):
321
322
322 def print_stack_entry(self,frame_lineno,prompt_prefix='\n-> ',
323 def print_stack_entry(self,frame_lineno,prompt_prefix='\n-> ',
323 context = 3):
324 context = 3):
324 frame, lineno = frame_lineno
325 #frame, lineno = frame_lineno
325 print >>Term.cout, self.format_stack_entry(frame_lineno, '', context)
326 print >>Term.cout, self.format_stack_entry(frame_lineno, '', context)
326
327
327 def format_stack_entry(self, frame_lineno, lprefix=': ', context = 3):
328 def format_stack_entry(self, frame_lineno, lprefix=': ', context = 3):
@@ -365,7 +366,11 class Pdb(OldPdb):
365
366
366 # The level info should be generated in the same format pdb uses, to
367 # The level info should be generated in the same format pdb uses, to
367 # avoid breaking the pdbtrack functionality of python-mode in *emacs.
368 # avoid breaking the pdbtrack functionality of python-mode in *emacs.
368 ret.append('> %s(%s)%s\n' % (link,lineno,call))
369 if frame is self.curframe:
370 ret.append('> ')
371 else:
372 ret.append(' ')
373 ret.append('%s(%s)%s\n' % (link,lineno,call))
369
374
370 start = lineno - 1 - context//2
375 start = lineno - 1 - context//2
371 lines = linecache.getlines(filename)
376 lines = linecache.getlines(filename)
@@ -375,7 +380,10 class Pdb(OldPdb):
375
380
376 for i,line in enumerate(lines):
381 for i,line in enumerate(lines):
377 show_arrow = (start + 1 + i == lineno)
382 show_arrow = (start + 1 + i == lineno)
378 ret.append(self.__format_line(tpl_line_em, filename,
383 linetpl = (frame is self.curframe or show_arrow) \
384 and tpl_line_em \
385 or tpl_line
386 ret.append(self.__format_line(linetpl, filename,
379 start + 1 + i, line,
387 start + 1 + i, line,
380 arrow = show_arrow) )
388 arrow = show_arrow) )
381
389
@@ -18,7 +18,7 def call_pydb(self, args):
18 argl = arg_split(args)
18 argl = arg_split(args)
19 # print argl # dbg
19 # print argl # dbg
20 if len(inspect.getargspec(pydb.runv)[0]) == 2:
20 if len(inspect.getargspec(pydb.runv)[0]) == 2:
21 pdb = Debugger.Pdb()
21 pdb = Debugger.Pdb(color_scheme=self.rc.colors)
22 ip.IP.history_saving_wrapper( lambda : pydb.runv(argl, pdb) )()
22 ip.IP.history_saving_wrapper( lambda : pydb.runv(argl, pdb) )()
23 else:
23 else:
24 ip.IP.history_saving_wrapper( lambda : pydb.runv(argl) )()
24 ip.IP.history_saving_wrapper( lambda : pydb.runv(argl) )()
@@ -5,7 +5,7 General purpose utilities.
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
6 these things are also convenient when working at the command line.
6 these things are also convenient when working at the command line.
7
7
8 $Id: genutils.py 2152 2007-03-18 20:13:35Z fperez $"""
8 $Id: genutils.py 2154 2007-03-19 00:10:07Z fperez $"""
9
9
10 #*****************************************************************************
10 #*****************************************************************************
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
@@ -67,6 +67,10 class IOStream:
67 # if we get here, something is seriously broken.
67 # if we get here, something is seriously broken.
68 print >> sys.stderr, \
68 print >> sys.stderr, \
69 'ERROR - failed to write data to stream:', self.stream
69 'ERROR - failed to write data to stream:', self.stream
70
71 def close(self):
72 pass
73
70
74
71 class IOTerm:
75 class IOTerm:
72 """ Term holds the file or file-like objects for handling I/O operations.
76 """ Term holds the file or file-like objects for handling I/O operations.
@@ -1,5 +1,12
1 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
1 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
2
2
3 * IPython/genutils.py (IOStream.close): small patch by
4 R. Bernstein for improved pydb support.
5
6 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
7 DaveS <davls@telus.net> to improve support of debugging under
8 NTEmacs, including improved pydb behavior.
9
3 * IPython/Magic.py (magic_prun): Fix saving of profile info for
10 * IPython/Magic.py (magic_prun): Fix saving of profile info for
4 Python 2.5, where the stats object API changed a little. Thanks
11 Python 2.5, where the stats object API changed a little. Thanks
5 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
12 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
@@ -6,7 +6,7
6 ;; URL: http://ipython.scipy.org
6 ;; URL: http://ipython.scipy.org
7 ;; Compatibility: Emacs21, XEmacs21
7 ;; Compatibility: Emacs21, XEmacs21
8 ;; FIXME: #$@! INPUT RING
8 ;; FIXME: #$@! INPUT RING
9 (defconst ipython-version "$Revision: 1851 $"
9 (defconst ipython-version "$Revision: 2154 $"
10 "VC version number.")
10 "VC version number.")
11
11
12 ;;; Commentary
12 ;;; Commentary
@@ -195,12 +195,13 the second for a 'normal' command, and the third for a multiline command.")
195 ;;^ File \"\\(.*?\\)\", line \\([0-9]+\\)"
195 ;;^ File \"\\(.*?\\)\", line \\([0-9]+\\)"
196
196
197 (setq py-traceback-line-re
197 (setq py-traceback-line-re
198 "\\(^[^\t ].+?\\.py\\).*\n +[0-9]+[^\00]*?\n-+> \\([0-9]+\\) +")
198 "\\(^[^\t >].+?\\.py\\).*\n +[0-9]+[^\00]*?\n-+> \\([0-9]+\\)+")
199
199
200
200 ;; Recognize the ipython pdb, whose prompt is 'ipdb>' or 'ipydb>'
201 ;; Recognize the ipython pdb, whose prompt is 'ipdb>' or 'ipydb>'
201 ;;instead of '(Pdb)'
202 ;;instead of '(Pdb)'
202 (setq py-pdbtrack-input-prompt "\n[(<]*[Ii]?[Pp]y?db[>)]+ ")
203 (setq py-pdbtrack-input-prompt "\n[(<]*[Ii]?[Pp]y?db[>)]+ ")
203 (setq py-pydbtrack-input-prompt "\n[(]*ipydb[>)]+ ")
204 (setq pydb-pydbtrack-input-prompt "\n[(]*ipydb[>)]+ ")
204
205
205 (setq py-shell-input-prompt-1-regexp "^In \\[[0-9]+\\]: *"
206 (setq py-shell-input-prompt-1-regexp "^In \\[[0-9]+\\]: *"
206 py-shell-input-prompt-2-regexp "^ [.][.][.]+: *" )
207 py-shell-input-prompt-2-regexp "^ [.][.][.]+: *" )
@@ -1176,7 +1176,7 PyWin32
1176 PyWin32
1176 PyWin32
1177 \family default
1177 \family default
1178 from
1178 from
1179 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
1179 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/pywin32}
1180
1180
1181 \end_inset
1181 \end_inset
1182
1182
@@ -1186,33 +1186,39 PyWin32
1186 \begin_layout Enumerate
1186 \begin_layout Enumerate
1187
1187
1188 \family typewriter
1188 \family typewriter
1189 CTypes
1189 PyReadline
1190 \family default
1190 \family default
1191 from
1191 for Windows from
1192 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1192 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org/moin/PyReadline/Intro}
1193
1193
1194 \end_inset
1194 \end_inset
1195
1195
1196 (you
1196 .
1197 \emph on
1197 That page contains further details on using and configuring the system
1198 must
1198 to your liking.
1199 \emph default
1200 use version 0.9.1 or newer).
1201 \end_layout
1199 \end_layout
1202
1200
1203 \begin_layout Enumerate
1201 \begin_layout Enumerate
1204
1202 Finally,
1203 \emph on
1204 only
1205 \emph default
1206 if you are using Python 2.3 or 2.4, you need
1205 \family typewriter
1207 \family typewriter
1206 PyReadline
1208 CTypes
1207 \family default
1209 \family default
1208 for Windows from
1210 from
1209 \begin_inset LatexCommand \htmlurl{http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro}
1211 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1210
1212
1211 \end_inset
1213 \end_inset
1212
1214
1213 .
1215 (you
1214 That page contains further details on using and configuring the system
1216 \emph on
1215 to your liking.
1217 must
1218 \emph default
1219 use version 0.9.1 or newer).
1220 This package is included in Python 2.5, so you don't need to manually get
1221 it if your Python version is 2.5 or newer.
1216 \end_layout
1222 \end_layout
1217
1223
1218 \begin_layout Standard
1224 \begin_layout Standard
General Comments 0
You need to be logged in to leave comments. Login now