##// END OF EJS Templates
- Cleanup [1786], which went in with unfinished stuff by accident....
fperez -
Show More
@@ -15,7 +15,7 b' details on the PSF (Python Software Foundation) standard license, see:'
15 15
16 16 http://www.python.org/2.2.3/license.html
17 17
18 $Id: Debugger.py 1786 2006-09-27 05:47:28Z fperez $"""
18 $Id: Debugger.py 1787 2006-09-27 06:56:29Z fperez $"""
19 19
20 20 #*****************************************************************************
21 21 #
@@ -65,63 +65,14 b' def _file_lines(fname):'
65 65 class Pdb(pdb.Pdb):
66 66 """Modified Pdb class, does not load readline."""
67 67
68 # Ugly hack: we can't call the parent constructor, because it binds
69 # readline and breaks tab-completion. This means we have to COPY the
70 # constructor here, and that requires tracking various python versions.
71
72 if sys.version[:3] == '2.5':
68 if sys.version[:3] >= '2.5':
73 69 def __init__(self,color_scheme='NoColor',completekey=None,
74 70 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 71
72 # Parent constructor:
73 pdb.Pdb.__init__(self,completekey,stdin,stdout)
122 74
123 75 # IPython changes...
124
125 76 self.prompt = 'ipdb> ' # The default prompt is '(Pdb)'
126 77 self.aliases = {}
127 78
@@ -144,9 +95,10 b' class Pdb(pdb.Pdb):'
144 95
145 96 self.set_colors(color_scheme)
146 97
147
148 98 else:
149
99 # Ugly hack: for Python 2.3-2.4, we can't call the parent constructor,
100 # because it binds readline and breaks tab-completion. This means we
101 # have to COPY the constructor here.
150 102 def __init__(self,color_scheme='NoColor'):
151 103 bdb.Bdb.__init__(self)
152 104 cmd.Cmd.__init__(self,completekey=None) # don't load readline
@@ -1,7 +1,7 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Magic functions for InteractiveShell.
3 3
4 $Id: Magic.py 1386 2006-07-08 09:32:30Z vivainio $"""
4 $Id: Magic.py 1787 2006-09-27 06:56:29Z fperez $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -2198,11 +2198,12 b' Currently the magic system has the following functions:\\n"""'
2198 2198 import IPython.rlineimpl as readline
2199 2199 if not readline.have_readline:
2200 2200 msg = """\
2201 Proper color support under MS Windows requires Gary Bishop's readline library.
2201 Proper color support under MS Windows requires the pyreadline library.
2202 2202 You can find it at:
2203 http://sourceforge.net/projects/uncpythontools
2203 http://ipython.scipy.org/moin/PyReadline/Intro
2204 2204 Gary's readline needs the ctypes module, from:
2205 2205 http://starship.python.net/crew/theller/ctypes
2206 (Note that ctypes is already part of Python versions 2.5 and newer).
2206 2207
2207 2208 Defaulting color scheme to 'NoColor'"""
2208 2209 new_scheme = 'NoColor'
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.'
6 6
7 7 This file contains all the classes and helper functions specific to IPython.
8 8
9 $Id: iplib.py 1786 2006-09-27 05:47:28Z fperez $
9 $Id: iplib.py 1787 2006-09-27 06:56:29Z fperez $
10 10 """
11 11
12 12 #*****************************************************************************
@@ -219,6 +219,12 b' class InteractiveShell(object,Magic):'
219 219 # Default name given in compilation of code
220 220 self.filename = '<ipython console>'
221 221
222 # Install our own quitter instead of the builtins. For python2.3-2.4,
223 # this brings in behavior more like 2.5, and for 2.5 it's almost
224 # identical to Python's official behavior (except we lack the message,
225 # but with autocall the need for that is much less).
226 __builtin__.exit = __builtin__.quit = self.exit
227
222 228 # Make an empty namespace, which extension writers can rely on both
223 229 # existing and NEVER being used by ipython itself. This gives them a
224 230 # convenient location for storing additional information and state
@@ -1801,14 +1807,7 b' want to merge them back into the new files.""" % locals()'
1801 1807 continuation in a sequence of inputs.
1802 1808 """
1803 1809
1804 try:
1805 1810 line = raw_input_original(prompt)
1806 except ValueError:
1807 # python 2.5 closes stdin on exit -> ValueError
1808 # xxx should we delete 'exit' and 'quit' from builtin?
1809 self.exit_now = True
1810 return ''
1811
1812 1811
1813 1812 # Try to be reasonably smart about not re-indenting pasted input more
1814 1813 # than necessary. We do this by trimming out the auto-indent initial
@@ -2252,7 +2251,6 b' want to merge them back into the new files.""" % locals()'
2252 2251 self.exit_now = True
2253 2252 else:
2254 2253 self.exit_now = True
2255 return self.exit_now
2256 2254
2257 2255 def safe_execfile(self,fname,*where,**kw):
2258 2256 fname = os.path.expanduser(fname)
@@ -235,28 +235,6 b' class PythonRunner(InteractiveRunner):'
235 235 InteractiveRunner.__init__(self,program,prompts,args)
236 236
237 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
260 238 class SAGERunner(InteractiveRunner):
261 239 """Interactive SAGE runner.
262 240
@@ -60,7 +60,7 b' You can implement other color schemes easily, the syntax is fairly'
60 60 self-explanatory. Please send back new schemes you develop to the author for
61 61 possible inclusion in future releases.
62 62
63 $Id: ultraTB.py 1786 2006-09-27 05:47:28Z fperez $"""
63 $Id: ultraTB.py 1787 2006-09-27 06:56:29Z fperez $"""
64 64
65 65 #*****************************************************************************
66 66 # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu>
@@ -205,9 +205,13 b' class TBTools:'
205 205 def set_colors(self,*args,**kw):
206 206 """Shorthand access to the color table scheme selector method."""
207 207
208 # Set own color table
208 209 self.color_scheme_table.set_active_scheme(*args,**kw)
209 210 # for convenience, set Colors to the active scheme
210 211 self.Colors = self.color_scheme_table.active_colors
212 # Also set colors of debugger
213 if hasattr(self,'pdb') and self.pdb is not None:
214 self.pdb.set_colors(*args,**kw)
211 215
212 216 def color_toggle(self):
213 217 """Toggle between the currently active color scheme and NoColor."""
@@ -692,7 +696,7 b' class VerboseTB(TBTools):'
692 696 etb = etb.tb_next
693 697 self.pdb.botframe = etb.tb_frame
694 698 self.pdb.interaction(self.tb.tb_frame, self.tb)
695 except 'ha': # dbg
699 except:
696 700 print '*** ERROR ***'
697 701 print 'This version of pdb has a bug and crashed.'
698 702 print 'Returning to IPython...'
@@ -1,3 +1,21 b''
1 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
4 to help in handling doctests. irunner is now pretty useful for
5 running standalone scripts and simulate a full interactive session
6 in a format that can be then pasted as a doctest.
7
8 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
9 on top of the default (useless) ones. This also fixes the nasty
10 way in which 2.5's Quitter() exits (reverted [1785]).
11
12 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
13 2.5.
14
15 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
16 color scheme is updated as well when color scheme is changed
17 interactively.
18
1 19 2006-09-27 Ville Vainio <vivainio@gmail.com>
2 20
3 21 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
General Comments 0
You need to be logged in to leave comments. Login now