##// END OF EJS Templates
Apply Ville's patch, closes #87
fperez -
Show More
@@ -15,7 +15,7 b' 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 1324 2006-05-24 20:25:11Z fperez $"""
18 $Id: Debugger.py 1786 2006-09-27 05:47:28Z fperez $"""
19
19
20 #*****************************************************************************
20 #*****************************************************************************
21 #
21 #
@@ -69,6 +69,84 b' class Pdb(pdb.Pdb):'
69 # readline and breaks tab-completion. This means we have to COPY the
69 # readline and breaks tab-completion. This means we have to COPY the
70 # constructor here, and that requires tracking various python versions.
70 # constructor here, and that requires tracking various python versions.
71
71
72 if sys.version[:3] == '2.5':
73 def __init__(self,color_scheme='NoColor',completekey=None,
74 stdin=None, stdout=None):
75 bdb.Bdb.__init__(self)
76
77 # IPython change
78 # don't load readline
79 cmd.Cmd.__init__(self,completekey,stdin,stdout)
80 #cmd.Cmd.__init__(self, completekey, stdin, stdout)
81 # /IPython change
82
83 if stdout:
84 self.use_rawinput = 0
85 self.prompt = '(Pdb) '
86 self.aliases = {}
87 self.mainpyfile = ''
88 self._wait_for_mainpyfile = 0
89 # Try to load readline if it exists
90 try:
91 import readline
92 except ImportError:
93 pass
94
95 # Read $HOME/.pdbrc and ./.pdbrc
96 self.rcLines = []
97 if 'HOME' in os.environ:
98 envHome = os.environ['HOME']
99 try:
100 rcFile = open(os.path.join(envHome, ".pdbrc"))
101 except IOError:
102 pass
103 else:
104 for line in rcFile.readlines():
105 self.rcLines.append(line)
106 rcFile.close()
107 try:
108 rcFile = open(".pdbrc")
109 except IOError:
110 pass
111 else:
112 for line in rcFile.readlines():
113 self.rcLines.append(line)
114 rcFile.close()
115
116 self.commands = {} # associates a command list to breakpoint numbers
117 self.commands_doprompt = {} # for each bp num, tells if the prompt must be disp. after execing the cmd list
118 self.commands_silent = {} # for each bp num, tells if the stack trace must be disp. after execing the cmd list
119 self.commands_defining = False # True while in the process of defining a command list
120 self.commands_bnum = None # The breakpoint number for which we are defining a list
121
122
123 # IPython changes...
124
125 self.prompt = 'ipdb> ' # The default prompt is '(Pdb)'
126 self.aliases = {}
127
128 # Create color table: we copy the default one from the traceback
129 # module and add a few attributes needed for debugging
130 self.color_scheme_table = ExceptionColors.copy()
131
132 # shorthands
133 C = ColorANSI.TermColors
134 cst = self.color_scheme_table
135
136 cst['NoColor'].colors.breakpoint_enabled = C.NoColor
137 cst['NoColor'].colors.breakpoint_disabled = C.NoColor
138
139 cst['Linux'].colors.breakpoint_enabled = C.LightRed
140 cst['Linux'].colors.breakpoint_disabled = C.Red
141
142 cst['LightBG'].colors.breakpoint_enabled = C.LightRed
143 cst['LightBG'].colors.breakpoint_disabled = C.Red
144
145 self.set_colors(color_scheme)
146
147
148 else:
149
72 def __init__(self,color_scheme='NoColor'):
150 def __init__(self,color_scheme='NoColor'):
73 bdb.Bdb.__init__(self)
151 bdb.Bdb.__init__(self)
74 cmd.Cmd.__init__(self,completekey=None) # don't load readline
152 cmd.Cmd.__init__(self,completekey=None) # don't load readline
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.'
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 1785 2006-09-26 21:08:22Z vivainio $
9 $Id: iplib.py 1786 2006-09-27 05:47:28Z fperez $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
@@ -2029,8 +2029,22 b' want to merge them back into the new files.""" % locals()'
2029 """simple prefilter function, for debugging"""
2029 """simple prefilter function, for debugging"""
2030 return self.handle_normal(line,continue_prompt)
2030 return self.handle_normal(line,continue_prompt)
2031
2031
2032
2033 def multiline_prefilter(self, line, continue_prompt):
2034 """ Run _prefilter for each line of input
2035
2036 Covers cases where there are multiple lines in the user entry,
2037 which is the case when the user goes back to a multiline history
2038 entry and presses enter.
2039
2040 """
2041 out = []
2042 for l in line.rstrip('\n').split('\n'):
2043 out.append(self._prefilter(l, continue_prompt))
2044 return '\n'.join(out)
2045
2032 # Set the default prefilter() function (this can be user-overridden)
2046 # Set the default prefilter() function (this can be user-overridden)
2033 prefilter = _prefilter
2047 prefilter = multiline_prefilter
2034
2048
2035 def handle_normal(self,line,continue_prompt=None,
2049 def handle_normal(self,line,continue_prompt=None,
2036 pre=None,iFun=None,theRest=None):
2050 pre=None,iFun=None,theRest=None):
@@ -32,6 +32,7 b' NOTES:'
32
32
33 # Stdlib imports
33 # Stdlib imports
34 import optparse
34 import optparse
35 import os
35 import sys
36 import sys
36
37
37 # Third-party modules.
38 # Third-party modules.
@@ -127,8 +128,11 b' class InteractiveRunner(object):'
127
128
128 # grab the true write method of stdout, in case anything later
129 # grab the true write method of stdout, in case anything later
129 # reassigns sys.stdout, so that we really are writing to the true
130 # reassigns sys.stdout, so that we really are writing to the true
130 # stdout and not to something else.
131 # stdout and not to something else. We also normalize all strings we
131 write = sys.stdout.write
132 # write to use the native OS line separators.
133 linesep = os.linesep
134 stdwrite = sys.stdout.write
135 write = lambda s: stdwrite(s.replace('\r\n',linesep))
132
136
133 c = pexpect.spawn(self.program,self.args,timeout=None)
137 c = pexpect.spawn(self.program,self.args,timeout=None)
134 c.delaybeforesend = self.delaybeforesend
138 c.delaybeforesend = self.delaybeforesend
@@ -142,7 +146,9 b' class InteractiveRunner(object):'
142 for cmd in source:
146 for cmd in source:
143 # skip blank lines for all matches to the 'main' prompt, while the
147 # skip blank lines for all matches to the 'main' prompt, while the
144 # secondary prompts do not
148 # secondary prompts do not
145 if prompt_idx==0 and cmd.isspace():
149 if prompt_idx==0 and \
150 (cmd.isspace() or cmd.lstrip().startswith('#')):
151 print cmd,
146 continue
152 continue
147
153
148 write(c.after)
154 write(c.after)
@@ -156,9 +162,6 b' class InteractiveRunner(object):'
156 break
162 break
157 write(c.before)
163 write(c.before)
158
164
159 if isinstance(source,file):
160 source.close()
161
162 if end_normal:
165 if end_normal:
163 if interact:
166 if interact:
164 c.send('\n')
167 c.send('\n')
@@ -232,6 +235,28 b' class PythonRunner(InteractiveRunner):'
232 InteractiveRunner.__init__(self,program,prompts,args)
235 InteractiveRunner.__init__(self,program,prompts,args)
233
236
234
237
238 class DocTestRunner(PythonRunner):
239 """A python runner customized for doctest usage."""
240
241 def run_source(self,source,interact=False):
242 """Run the given source code interactively.
243
244 See the parent docstring for details.
245 """
246
247 # if the source is a string, chop it up in lines so we can iterate
248 # over it just as if it were an open file.
249 if not isinstance(source,file):
250 source = source.splitlines(True)
251
252
253 for line in source:
254 pass
255 # finish by calling the parent run_source method
256 super(DocTestRunner,self).run_source(dsource,interact)
257
258
259
235 class SAGERunner(InteractiveRunner):
260 class SAGERunner(InteractiveRunner):
236 """Interactive SAGE runner.
261 """Interactive SAGE runner.
237
262
@@ -60,7 +60,7 b' You can implement other color schemes easily, the syntax is fairly'
60 self-explanatory. Please send back new schemes you develop to the author for
60 self-explanatory. Please send back new schemes you develop to the author for
61 possible inclusion in future releases.
61 possible inclusion in future releases.
62
62
63 $Id: ultraTB.py 1154 2006-02-11 23:20:05Z fperez $"""
63 $Id: ultraTB.py 1786 2006-09-27 05:47:28Z fperez $"""
64
64
65 #*****************************************************************************
65 #*****************************************************************************
66 # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu>
66 # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu>
@@ -692,7 +692,7 b' class VerboseTB(TBTools):'
692 etb = etb.tb_next
692 etb = etb.tb_next
693 self.pdb.botframe = etb.tb_frame
693 self.pdb.botframe = etb.tb_frame
694 self.pdb.interaction(self.tb.tb_frame, self.tb)
694 self.pdb.interaction(self.tb.tb_frame, self.tb)
695 except:
695 except 'ha': # dbg
696 print '*** ERROR ***'
696 print '*** ERROR ***'
697 print 'This version of pdb has a bug and crashed.'
697 print 'This version of pdb has a bug and crashed.'
698 print 'Returning to IPython...'
698 print 'Returning to IPython...'
General Comments 0
You need to be logged in to leave comments. Login now