##// END OF EJS Templates
Close issue 41, remove obsolete gtk 1.x code, trap os.getcwd exceptions at...
fperez -
Show More
@@ -1,886 +1,881
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """IPython Shell classes.
2 """IPython Shell classes.
3
3
4 All the matplotlib support code was co-developed with John Hunter,
4 All the matplotlib support code was co-developed with John Hunter,
5 matplotlib's author.
5 matplotlib's author.
6
6
7 $Id: Shell.py 703 2005-08-16 17:34:44Z fperez $"""
7 $Id: Shell.py 802 2005-09-06 03:49:12Z fperez $"""
8
8
9 #*****************************************************************************
9 #*****************************************************************************
10 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
10 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
11 #
11 #
12 # Distributed under the terms of the BSD License. The full license is in
12 # Distributed under the terms of the BSD License. The full license is in
13 # the file COPYING, distributed as part of this software.
13 # the file COPYING, distributed as part of this software.
14 #*****************************************************************************
14 #*****************************************************************************
15
15
16 from IPython import Release
16 from IPython import Release
17 __author__ = '%s <%s>' % Release.authors['Fernando']
17 __author__ = '%s <%s>' % Release.authors['Fernando']
18 __license__ = Release.license
18 __license__ = Release.license
19
19
20 # Code begins
20 # Code begins
21 import __main__
21 import __main__
22 import __builtin__
22 import __builtin__
23 import sys
23 import sys
24 import os
24 import os
25 import code
25 import code
26 import threading
26 import threading
27 import signal
27 import signal
28
28
29 import IPython
29 import IPython
30 from IPython.iplib import InteractiveShell
30 from IPython.iplib import InteractiveShell
31 from IPython.ipmaker import make_IPython
31 from IPython.ipmaker import make_IPython
32 from IPython.genutils import Term,warn,error,flag_calls
32 from IPython.genutils import Term,warn,error,flag_calls
33 from IPython.Struct import Struct
33 from IPython.Struct import Struct
34 from IPython.Magic import Magic
34 from IPython.Magic import Magic
35 from IPython import ultraTB
35 from IPython import ultraTB
36
36
37 # global flag to pass around information about Ctrl-C without exceptions
37 # global flag to pass around information about Ctrl-C without exceptions
38 KBINT = False
38 KBINT = False
39
39
40 # global flag to turn on/off Tk support.
40 # global flag to turn on/off Tk support.
41 USE_TK = False
41 USE_TK = False
42
42
43 #-----------------------------------------------------------------------------
43 #-----------------------------------------------------------------------------
44 # This class is trivial now, but I want to have it in to publish a clean
44 # This class is trivial now, but I want to have it in to publish a clean
45 # interface. Later when the internals are reorganized, code that uses this
45 # interface. Later when the internals are reorganized, code that uses this
46 # shouldn't have to change.
46 # shouldn't have to change.
47
47
48 class IPShell:
48 class IPShell:
49 """Create an IPython instance."""
49 """Create an IPython instance."""
50
50
51 def __init__(self,argv=None,user_ns=None,debug=1,
51 def __init__(self,argv=None,user_ns=None,debug=1,
52 shell_class=InteractiveShell):
52 shell_class=InteractiveShell):
53 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
53 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
54 shell_class=shell_class)
54 shell_class=shell_class)
55
55
56 def mainloop(self,sys_exit=0,banner=None):
56 def mainloop(self,sys_exit=0,banner=None):
57 self.IP.mainloop(banner)
57 self.IP.mainloop(banner)
58 if sys_exit:
58 if sys_exit:
59 sys.exit()
59 sys.exit()
60
60
61 #-----------------------------------------------------------------------------
61 #-----------------------------------------------------------------------------
62 class IPShellEmbed:
62 class IPShellEmbed:
63 """Allow embedding an IPython shell into a running program.
63 """Allow embedding an IPython shell into a running program.
64
64
65 Instances of this class are callable, with the __call__ method being an
65 Instances of this class are callable, with the __call__ method being an
66 alias to the embed() method of an InteractiveShell instance.
66 alias to the embed() method of an InteractiveShell instance.
67
67
68 Usage (see also the example-embed.py file for a running example):
68 Usage (see also the example-embed.py file for a running example):
69
69
70 ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override])
70 ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override])
71
71
72 - argv: list containing valid command-line options for IPython, as they
72 - argv: list containing valid command-line options for IPython, as they
73 would appear in sys.argv[1:].
73 would appear in sys.argv[1:].
74
74
75 For example, the following command-line options:
75 For example, the following command-line options:
76
76
77 $ ipython -prompt_in1 'Input <\\#>' -colors LightBG
77 $ ipython -prompt_in1 'Input <\\#>' -colors LightBG
78
78
79 would be passed in the argv list as:
79 would be passed in the argv list as:
80
80
81 ['-prompt_in1','Input <\\#>','-colors','LightBG']
81 ['-prompt_in1','Input <\\#>','-colors','LightBG']
82
82
83 - banner: string which gets printed every time the interpreter starts.
83 - banner: string which gets printed every time the interpreter starts.
84
84
85 - exit_msg: string which gets printed every time the interpreter exits.
85 - exit_msg: string which gets printed every time the interpreter exits.
86
86
87 - rc_override: a dict or Struct of configuration options such as those
87 - rc_override: a dict or Struct of configuration options such as those
88 used by IPython. These options are read from your ~/.ipython/ipythonrc
88 used by IPython. These options are read from your ~/.ipython/ipythonrc
89 file when the Shell object is created. Passing an explicit rc_override
89 file when the Shell object is created. Passing an explicit rc_override
90 dict with any options you want allows you to override those values at
90 dict with any options you want allows you to override those values at
91 creation time without having to modify the file. This way you can create
91 creation time without having to modify the file. This way you can create
92 embeddable instances configured in any way you want without editing any
92 embeddable instances configured in any way you want without editing any
93 global files (thus keeping your interactive IPython configuration
93 global files (thus keeping your interactive IPython configuration
94 unchanged).
94 unchanged).
95
95
96 Then the ipshell instance can be called anywhere inside your code:
96 Then the ipshell instance can be called anywhere inside your code:
97
97
98 ipshell(header='') -> Opens up an IPython shell.
98 ipshell(header='') -> Opens up an IPython shell.
99
99
100 - header: string printed by the IPython shell upon startup. This can let
100 - header: string printed by the IPython shell upon startup. This can let
101 you know where in your code you are when dropping into the shell. Note
101 you know where in your code you are when dropping into the shell. Note
102 that 'banner' gets prepended to all calls, so header is used for
102 that 'banner' gets prepended to all calls, so header is used for
103 location-specific information.
103 location-specific information.
104
104
105 For more details, see the __call__ method below.
105 For more details, see the __call__ method below.
106
106
107 When the IPython shell is exited with Ctrl-D, normal program execution
107 When the IPython shell is exited with Ctrl-D, normal program execution
108 resumes.
108 resumes.
109
109
110 This functionality was inspired by a posting on comp.lang.python by cmkl
110 This functionality was inspired by a posting on comp.lang.python by cmkl
111 <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and
111 <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and
112 by the IDL stop/continue commands."""
112 by the IDL stop/continue commands."""
113
113
114 def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None):
114 def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None):
115 """Note that argv here is a string, NOT a list."""
115 """Note that argv here is a string, NOT a list."""
116 self.set_banner(banner)
116 self.set_banner(banner)
117 self.set_exit_msg(exit_msg)
117 self.set_exit_msg(exit_msg)
118 self.set_dummy_mode(0)
118 self.set_dummy_mode(0)
119
119
120 # sys.displayhook is a global, we need to save the user's original
120 # sys.displayhook is a global, we need to save the user's original
121 # Don't rely on __displayhook__, as the user may have changed that.
121 # Don't rely on __displayhook__, as the user may have changed that.
122 self.sys_displayhook_ori = sys.displayhook
122 self.sys_displayhook_ori = sys.displayhook
123
123
124 # save readline completer status
124 # save readline completer status
125 try:
125 try:
126 #print 'Save completer',sys.ipcompleter # dbg
126 #print 'Save completer',sys.ipcompleter # dbg
127 self.sys_ipcompleter_ori = sys.ipcompleter
127 self.sys_ipcompleter_ori = sys.ipcompleter
128 except:
128 except:
129 pass # not nested with IPython
129 pass # not nested with IPython
130
130
131 # FIXME. Passing user_ns breaks namespace handling.
131 # FIXME. Passing user_ns breaks namespace handling.
132 #self.IP = make_IPython(argv,user_ns=__main__.__dict__)
132 #self.IP = make_IPython(argv,user_ns=__main__.__dict__)
133 self.IP = make_IPython(argv,rc_override=rc_override,embedded=True)
133 self.IP = make_IPython(argv,rc_override=rc_override,embedded=True)
134
134
135 self.IP.name_space_init()
135 self.IP.name_space_init()
136 # mark this as an embedded instance so we know if we get a crash
136 # mark this as an embedded instance so we know if we get a crash
137 # post-mortem
137 # post-mortem
138 self.IP.rc.embedded = 1
138 self.IP.rc.embedded = 1
139 # copy our own displayhook also
139 # copy our own displayhook also
140 self.sys_displayhook_embed = sys.displayhook
140 self.sys_displayhook_embed = sys.displayhook
141 # and leave the system's display hook clean
141 # and leave the system's display hook clean
142 sys.displayhook = self.sys_displayhook_ori
142 sys.displayhook = self.sys_displayhook_ori
143 # don't use the ipython crash handler so that user exceptions aren't
143 # don't use the ipython crash handler so that user exceptions aren't
144 # trapped
144 # trapped
145 sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors,
145 sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors,
146 mode = self.IP.rc.xmode,
146 mode = self.IP.rc.xmode,
147 call_pdb = self.IP.rc.pdb)
147 call_pdb = self.IP.rc.pdb)
148 self.restore_system_completer()
148 self.restore_system_completer()
149
149
150 def restore_system_completer(self):
150 def restore_system_completer(self):
151 """Restores the readline completer which was in place.
151 """Restores the readline completer which was in place.
152
152
153 This allows embedded IPython within IPython not to disrupt the
153 This allows embedded IPython within IPython not to disrupt the
154 parent's completion.
154 parent's completion.
155 """
155 """
156
156
157 try:
157 try:
158 self.IP.readline.set_completer(self.sys_ipcompleter_ori)
158 self.IP.readline.set_completer(self.sys_ipcompleter_ori)
159 sys.ipcompleter = self.sys_ipcompleter_ori
159 sys.ipcompleter = self.sys_ipcompleter_ori
160 except:
160 except:
161 pass
161 pass
162
162
163 def __call__(self,header='',local_ns=None,global_ns=None,dummy=None):
163 def __call__(self,header='',local_ns=None,global_ns=None,dummy=None):
164 """Activate the interactive interpreter.
164 """Activate the interactive interpreter.
165
165
166 __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start
166 __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start
167 the interpreter shell with the given local and global namespaces, and
167 the interpreter shell with the given local and global namespaces, and
168 optionally print a header string at startup.
168 optionally print a header string at startup.
169
169
170 The shell can be globally activated/deactivated using the
170 The shell can be globally activated/deactivated using the
171 set/get_dummy_mode methods. This allows you to turn off a shell used
171 set/get_dummy_mode methods. This allows you to turn off a shell used
172 for debugging globally.
172 for debugging globally.
173
173
174 However, *each* time you call the shell you can override the current
174 However, *each* time you call the shell you can override the current
175 state of dummy_mode with the optional keyword parameter 'dummy'. For
175 state of dummy_mode with the optional keyword parameter 'dummy'. For
176 example, if you set dummy mode on with IPShell.set_dummy_mode(1), you
176 example, if you set dummy mode on with IPShell.set_dummy_mode(1), you
177 can still have a specific call work by making it as IPShell(dummy=0).
177 can still have a specific call work by making it as IPShell(dummy=0).
178
178
179 The optional keyword parameter dummy controls whether the call
179 The optional keyword parameter dummy controls whether the call
180 actually does anything. """
180 actually does anything. """
181
181
182 # Allow the dummy parameter to override the global __dummy_mode
182 # Allow the dummy parameter to override the global __dummy_mode
183 if dummy or (dummy != 0 and self.__dummy_mode):
183 if dummy or (dummy != 0 and self.__dummy_mode):
184 return
184 return
185
185
186 # Set global subsystems (display,completions) to our values
186 # Set global subsystems (display,completions) to our values
187 sys.displayhook = self.sys_displayhook_embed
187 sys.displayhook = self.sys_displayhook_embed
188 if self.IP.has_readline:
188 if self.IP.has_readline:
189 self.IP.readline.set_completer(self.IP.Completer.complete)
189 self.IP.readline.set_completer(self.IP.Completer.complete)
190
190
191 if self.banner and header:
191 if self.banner and header:
192 format = '%s\n%s\n'
192 format = '%s\n%s\n'
193 else:
193 else:
194 format = '%s%s\n'
194 format = '%s%s\n'
195 banner = format % (self.banner,header)
195 banner = format % (self.banner,header)
196
196
197 # Call the embedding code with a stack depth of 1 so it can skip over
197 # Call the embedding code with a stack depth of 1 so it can skip over
198 # our call and get the original caller's namespaces.
198 # our call and get the original caller's namespaces.
199 self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1)
199 self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1)
200
200
201 if self.exit_msg:
201 if self.exit_msg:
202 print self.exit_msg
202 print self.exit_msg
203
203
204 # Restore global systems (display, completion)
204 # Restore global systems (display, completion)
205 sys.displayhook = self.sys_displayhook_ori
205 sys.displayhook = self.sys_displayhook_ori
206 self.restore_system_completer()
206 self.restore_system_completer()
207
207
208 def set_dummy_mode(self,dummy):
208 def set_dummy_mode(self,dummy):
209 """Sets the embeddable shell's dummy mode parameter.
209 """Sets the embeddable shell's dummy mode parameter.
210
210
211 set_dummy_mode(dummy): dummy = 0 or 1.
211 set_dummy_mode(dummy): dummy = 0 or 1.
212
212
213 This parameter is persistent and makes calls to the embeddable shell
213 This parameter is persistent and makes calls to the embeddable shell
214 silently return without performing any action. This allows you to
214 silently return without performing any action. This allows you to
215 globally activate or deactivate a shell you're using with a single call.
215 globally activate or deactivate a shell you're using with a single call.
216
216
217 If you need to manually"""
217 If you need to manually"""
218
218
219 if dummy not in [0,1]:
219 if dummy not in [0,1]:
220 raise ValueError,'dummy parameter must be 0 or 1'
220 raise ValueError,'dummy parameter must be 0 or 1'
221 self.__dummy_mode = dummy
221 self.__dummy_mode = dummy
222
222
223 def get_dummy_mode(self):
223 def get_dummy_mode(self):
224 """Return the current value of the dummy mode parameter.
224 """Return the current value of the dummy mode parameter.
225 """
225 """
226 return self.__dummy_mode
226 return self.__dummy_mode
227
227
228 def set_banner(self,banner):
228 def set_banner(self,banner):
229 """Sets the global banner.
229 """Sets the global banner.
230
230
231 This banner gets prepended to every header printed when the shell
231 This banner gets prepended to every header printed when the shell
232 instance is called."""
232 instance is called."""
233
233
234 self.banner = banner
234 self.banner = banner
235
235
236 def set_exit_msg(self,exit_msg):
236 def set_exit_msg(self,exit_msg):
237 """Sets the global exit_msg.
237 """Sets the global exit_msg.
238
238
239 This exit message gets printed upon exiting every time the embedded
239 This exit message gets printed upon exiting every time the embedded
240 shell is called. It is None by default. """
240 shell is called. It is None by default. """
241
241
242 self.exit_msg = exit_msg
242 self.exit_msg = exit_msg
243
243
244 #-----------------------------------------------------------------------------
244 #-----------------------------------------------------------------------------
245 def sigint_handler (signum,stack_frame):
245 def sigint_handler (signum,stack_frame):
246 """Sigint handler for threaded apps.
246 """Sigint handler for threaded apps.
247
247
248 This is a horrible hack to pass information about SIGINT _without_ using
248 This is a horrible hack to pass information about SIGINT _without_ using
249 exceptions, since I haven't been able to properly manage cross-thread
249 exceptions, since I haven't been able to properly manage cross-thread
250 exceptions in GTK/WX. In fact, I don't think it can be done (or at least
250 exceptions in GTK/WX. In fact, I don't think it can be done (or at least
251 that's my understanding from a c.l.py thread where this was discussed)."""
251 that's my understanding from a c.l.py thread where this was discussed)."""
252
252
253 global KBINT
253 global KBINT
254
254
255 print '\nKeyboardInterrupt - Press <Enter> to continue.',
255 print '\nKeyboardInterrupt - Press <Enter> to continue.',
256 Term.cout.flush()
256 Term.cout.flush()
257 # Set global flag so that runsource can know that Ctrl-C was hit
257 # Set global flag so that runsource can know that Ctrl-C was hit
258 KBINT = True
258 KBINT = True
259
259
260 class MTInteractiveShell(InteractiveShell):
260 class MTInteractiveShell(InteractiveShell):
261 """Simple multi-threaded shell."""
261 """Simple multi-threaded shell."""
262
262
263 # Threading strategy taken from:
263 # Threading strategy taken from:
264 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian
264 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian
265 # McErlean and John Finlay. Modified with corrections by Antoon Pardon,
265 # McErlean and John Finlay. Modified with corrections by Antoon Pardon,
266 # from the pygtk mailing list, to avoid lockups with system calls.
266 # from the pygtk mailing list, to avoid lockups with system calls.
267
267
268 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
268 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
269 user_ns = None, banner2='',**kw):
269 user_ns = None, banner2='',**kw):
270 """Similar to the normal InteractiveShell, but with threading control"""
270 """Similar to the normal InteractiveShell, but with threading control"""
271
271
272 IPython.iplib.InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2)
272 IPython.iplib.InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2)
273
273
274 # Locking control variable
274 # Locking control variable
275 self.thread_ready = threading.Condition()
275 self.thread_ready = threading.Condition()
276
276
277 # Stuff to do at closing time
277 # Stuff to do at closing time
278 self._kill = False
278 self._kill = False
279 on_kill = kw.get('on_kill')
279 on_kill = kw.get('on_kill')
280 if on_kill is None:
280 if on_kill is None:
281 on_kill = []
281 on_kill = []
282 # Check that all things to kill are callable:
282 # Check that all things to kill are callable:
283 for t in on_kill:
283 for t in on_kill:
284 if not callable(t):
284 if not callable(t):
285 raise TypeError,'on_kill must be a list of callables'
285 raise TypeError,'on_kill must be a list of callables'
286 self.on_kill = on_kill
286 self.on_kill = on_kill
287
287
288 def runsource(self, source, filename="<input>", symbol="single"):
288 def runsource(self, source, filename="<input>", symbol="single"):
289 """Compile and run some source in the interpreter.
289 """Compile and run some source in the interpreter.
290
290
291 Modified version of code.py's runsource(), to handle threading issues.
291 Modified version of code.py's runsource(), to handle threading issues.
292 See the original for full docstring details."""
292 See the original for full docstring details."""
293
293
294 global KBINT
294 global KBINT
295
295
296 # If Ctrl-C was typed, we reset the flag and return right away
296 # If Ctrl-C was typed, we reset the flag and return right away
297 if KBINT:
297 if KBINT:
298 KBINT = False
298 KBINT = False
299 return False
299 return False
300
300
301 try:
301 try:
302 code = self.compile(source, filename, symbol)
302 code = self.compile(source, filename, symbol)
303 except (OverflowError, SyntaxError, ValueError):
303 except (OverflowError, SyntaxError, ValueError):
304 # Case 1
304 # Case 1
305 self.showsyntaxerror(filename)
305 self.showsyntaxerror(filename)
306 return False
306 return False
307
307
308 if code is None:
308 if code is None:
309 # Case 2
309 # Case 2
310 return True
310 return True
311
311
312 # Case 3
312 # Case 3
313 # Store code in self, so the execution thread can handle it
313 # Store code in self, so the execution thread can handle it
314 self.thread_ready.acquire()
314 self.thread_ready.acquire()
315 self.code_to_run = code
315 self.code_to_run = code
316 self.thread_ready.wait() # Wait until processed in timeout interval
316 self.thread_ready.wait() # Wait until processed in timeout interval
317 self.thread_ready.release()
317 self.thread_ready.release()
318
318
319 return False
319 return False
320
320
321 def runcode(self):
321 def runcode(self):
322 """Execute a code object.
322 """Execute a code object.
323
323
324 Multithreaded wrapper around IPython's runcode()."""
324 Multithreaded wrapper around IPython's runcode()."""
325
325
326 # lock thread-protected stuff
326 # lock thread-protected stuff
327 self.thread_ready.acquire()
327 self.thread_ready.acquire()
328
328
329 # Install sigint handler
329 # Install sigint handler
330 try:
330 try:
331 signal.signal(signal.SIGINT, sigint_handler)
331 signal.signal(signal.SIGINT, sigint_handler)
332 except SystemError:
332 except SystemError:
333 # This happens under Windows, which seems to have all sorts
333 # This happens under Windows, which seems to have all sorts
334 # of problems with signal handling. Oh well...
334 # of problems with signal handling. Oh well...
335 pass
335 pass
336
336
337 if self._kill:
337 if self._kill:
338 print >>Term.cout, 'Closing threads...',
338 print >>Term.cout, 'Closing threads...',
339 Term.cout.flush()
339 Term.cout.flush()
340 for tokill in self.on_kill:
340 for tokill in self.on_kill:
341 tokill()
341 tokill()
342 print >>Term.cout, 'Done.'
342 print >>Term.cout, 'Done.'
343
343
344 # Run pending code by calling parent class
344 # Run pending code by calling parent class
345 if self.code_to_run is not None:
345 if self.code_to_run is not None:
346 self.thread_ready.notify()
346 self.thread_ready.notify()
347 InteractiveShell.runcode(self,self.code_to_run)
347 InteractiveShell.runcode(self,self.code_to_run)
348
348
349 # We're done with thread-protected variables
349 # We're done with thread-protected variables
350 self.thread_ready.release()
350 self.thread_ready.release()
351 # This MUST return true for gtk threading to work
351 # This MUST return true for gtk threading to work
352 return True
352 return True
353
353
354 def kill (self):
354 def kill (self):
355 """Kill the thread, returning when it has been shut down."""
355 """Kill the thread, returning when it has been shut down."""
356 self.thread_ready.acquire()
356 self.thread_ready.acquire()
357 self._kill = True
357 self._kill = True
358 self.thread_ready.release()
358 self.thread_ready.release()
359
359
360 class MatplotlibShellBase:
360 class MatplotlibShellBase:
361 """Mixin class to provide the necessary modifications to regular IPython
361 """Mixin class to provide the necessary modifications to regular IPython
362 shell classes for matplotlib support.
362 shell classes for matplotlib support.
363
363
364 Given Python's MRO, this should be used as the FIRST class in the
364 Given Python's MRO, this should be used as the FIRST class in the
365 inheritance hierarchy, so that it overrides the relevant methods."""
365 inheritance hierarchy, so that it overrides the relevant methods."""
366
366
367 def _matplotlib_config(self,name):
367 def _matplotlib_config(self,name):
368 """Return various items needed to setup the user's shell with matplotlib"""
368 """Return various items needed to setup the user's shell with matplotlib"""
369
369
370 # Initialize matplotlib to interactive mode always
370 # Initialize matplotlib to interactive mode always
371 import matplotlib
371 import matplotlib
372 from matplotlib import backends
372 from matplotlib import backends
373 matplotlib.interactive(True)
373 matplotlib.interactive(True)
374
374
375 def use(arg):
375 def use(arg):
376 """IPython wrapper for matplotlib's backend switcher.
376 """IPython wrapper for matplotlib's backend switcher.
377
377
378 In interactive use, we can not allow switching to a different
378 In interactive use, we can not allow switching to a different
379 interactive backend, since thread conflicts will most likely crash
379 interactive backend, since thread conflicts will most likely crash
380 the python interpreter. This routine does a safety check first,
380 the python interpreter. This routine does a safety check first,
381 and refuses to perform a dangerous switch. It still allows
381 and refuses to perform a dangerous switch. It still allows
382 switching to non-interactive backends."""
382 switching to non-interactive backends."""
383
383
384 if arg in backends.interactive_bk and arg != self.mpl_backend:
384 if arg in backends.interactive_bk and arg != self.mpl_backend:
385 m=('invalid matplotlib backend switch.\n'
385 m=('invalid matplotlib backend switch.\n'
386 'This script attempted to switch to the interactive '
386 'This script attempted to switch to the interactive '
387 'backend: `%s`\n'
387 'backend: `%s`\n'
388 'Your current choice of interactive backend is: `%s`\n\n'
388 'Your current choice of interactive backend is: `%s`\n\n'
389 'Switching interactive matplotlib backends at runtime\n'
389 'Switching interactive matplotlib backends at runtime\n'
390 'would crash the python interpreter, '
390 'would crash the python interpreter, '
391 'and IPython has blocked it.\n\n'
391 'and IPython has blocked it.\n\n'
392 'You need to either change your choice of matplotlib backend\n'
392 'You need to either change your choice of matplotlib backend\n'
393 'by editing your .matplotlibrc file, or run this script as a \n'
393 'by editing your .matplotlibrc file, or run this script as a \n'
394 'standalone file from the command line, not using IPython.\n' %
394 'standalone file from the command line, not using IPython.\n' %
395 (arg,self.mpl_backend) )
395 (arg,self.mpl_backend) )
396 raise RuntimeError, m
396 raise RuntimeError, m
397 else:
397 else:
398 self.mpl_use(arg)
398 self.mpl_use(arg)
399 self.mpl_use._called = True
399 self.mpl_use._called = True
400
400
401 self.matplotlib = matplotlib
401 self.matplotlib = matplotlib
402 self.mpl_backend = matplotlib.rcParams['backend']
402 self.mpl_backend = matplotlib.rcParams['backend']
403
403
404 # we also need to block switching of interactive backends by use()
404 # we also need to block switching of interactive backends by use()
405 self.mpl_use = matplotlib.use
405 self.mpl_use = matplotlib.use
406 self.mpl_use._called = False
406 self.mpl_use._called = False
407 # overwrite the original matplotlib.use with our wrapper
407 # overwrite the original matplotlib.use with our wrapper
408 matplotlib.use = use
408 matplotlib.use = use
409
409
410
410
411 # This must be imported last in the matplotlib series, after
411 # This must be imported last in the matplotlib series, after
412 # backend/interactivity choices have been made
412 # backend/interactivity choices have been made
413 try:
413 try:
414 import matplotlib.pylab as pylab
414 import matplotlib.pylab as pylab
415 self.pylab = pylab
415 self.pylab = pylab
416 self.pylab_name = 'pylab'
416 self.pylab_name = 'pylab'
417 except ImportError:
417 except ImportError:
418 import matplotlib.matlab as matlab
418 import matplotlib.matlab as matlab
419 self.pylab = matlab
419 self.pylab = matlab
420 self.pylab_name = 'matlab'
420 self.pylab_name = 'matlab'
421
421
422 self.pylab.show._needmain = False
422 self.pylab.show._needmain = False
423 # We need to detect at runtime whether show() is called by the user.
423 # We need to detect at runtime whether show() is called by the user.
424 # For this, we wrap it into a decorator which adds a 'called' flag.
424 # For this, we wrap it into a decorator which adds a 'called' flag.
425 self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive)
425 self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive)
426
426
427 # Build a user namespace initialized with matplotlib/matlab features.
427 # Build a user namespace initialized with matplotlib/matlab features.
428 user_ns = {'__name__':'__main__',
428 user_ns = {'__name__':'__main__',
429 '__builtins__' : __builtin__ }
429 '__builtins__' : __builtin__ }
430
430
431 # Be careful not to remove the final \n in the code string below, or
431 # Be careful not to remove the final \n in the code string below, or
432 # things will break badly with py22 (I think it's a python bug, 2.3 is
432 # things will break badly with py22 (I think it's a python bug, 2.3 is
433 # OK).
433 # OK).
434 pname = self.pylab_name # Python can't interpolate dotted var names
434 pname = self.pylab_name # Python can't interpolate dotted var names
435 exec ("import matplotlib\n"
435 exec ("import matplotlib\n"
436 "import matplotlib.%(pname)s as %(pname)s\n"
436 "import matplotlib.%(pname)s as %(pname)s\n"
437 "from matplotlib.%(pname)s import *\n" % locals()) in user_ns
437 "from matplotlib.%(pname)s import *\n" % locals()) in user_ns
438
438
439 # Build matplotlib info banner
439 # Build matplotlib info banner
440 b="""
440 b="""
441 Welcome to pylab, a matplotlib-based Python environment.
441 Welcome to pylab, a matplotlib-based Python environment.
442 For more information, type 'help(pylab)'.
442 For more information, type 'help(pylab)'.
443 """
443 """
444 return user_ns,b
444 return user_ns,b
445
445
446 def mplot_exec(self,fname,*where,**kw):
446 def mplot_exec(self,fname,*where,**kw):
447 """Execute a matplotlib script.
447 """Execute a matplotlib script.
448
448
449 This is a call to execfile(), but wrapped in safeties to properly
449 This is a call to execfile(), but wrapped in safeties to properly
450 handle interactive rendering and backend switching."""
450 handle interactive rendering and backend switching."""
451
451
452 #print '*** Matplotlib runner ***' # dbg
452 #print '*** Matplotlib runner ***' # dbg
453 # turn off rendering until end of script
453 # turn off rendering until end of script
454 isInteractive = self.matplotlib.rcParams['interactive']
454 isInteractive = self.matplotlib.rcParams['interactive']
455 self.matplotlib.interactive(False)
455 self.matplotlib.interactive(False)
456 self.safe_execfile(fname,*where,**kw)
456 self.safe_execfile(fname,*where,**kw)
457 self.matplotlib.interactive(isInteractive)
457 self.matplotlib.interactive(isInteractive)
458 # make rendering call now, if the user tried to do it
458 # make rendering call now, if the user tried to do it
459 if self.pylab.draw_if_interactive.called:
459 if self.pylab.draw_if_interactive.called:
460 self.pylab.draw()
460 self.pylab.draw()
461 self.pylab.draw_if_interactive.called = False
461 self.pylab.draw_if_interactive.called = False
462
462
463 # if a backend switch was performed, reverse it now
463 # if a backend switch was performed, reverse it now
464 if self.mpl_use._called:
464 if self.mpl_use._called:
465 self.matplotlib.rcParams['backend'] = self.mpl_backend
465 self.matplotlib.rcParams['backend'] = self.mpl_backend
466
466
467 def magic_run(self,parameter_s=''):
467 def magic_run(self,parameter_s=''):
468 Magic.magic_run(self,parameter_s,runner=self.mplot_exec)
468 Magic.magic_run(self,parameter_s,runner=self.mplot_exec)
469
469
470 # Fix the docstring so users see the original as well
470 # Fix the docstring so users see the original as well
471 magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__,
471 magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__,
472 "\n *** Modified %run for Matplotlib,"
472 "\n *** Modified %run for Matplotlib,"
473 " with proper interactive handling ***")
473 " with proper interactive handling ***")
474
474
475 # Now we provide 2 versions of a matplotlib-aware IPython base shells, single
475 # Now we provide 2 versions of a matplotlib-aware IPython base shells, single
476 # and multithreaded. Note that these are meant for internal use, the IPShell*
476 # and multithreaded. Note that these are meant for internal use, the IPShell*
477 # classes below are the ones meant for public consumption.
477 # classes below are the ones meant for public consumption.
478
478
479 class MatplotlibShell(MatplotlibShellBase,InteractiveShell):
479 class MatplotlibShell(MatplotlibShellBase,InteractiveShell):
480 """Single-threaded shell with matplotlib support."""
480 """Single-threaded shell with matplotlib support."""
481
481
482 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
482 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
483 user_ns = None, **kw):
483 user_ns = None, **kw):
484 user_ns,b2 = self._matplotlib_config(name)
484 user_ns,b2 = self._matplotlib_config(name)
485 InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw)
485 InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw)
486
486
487 class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell):
487 class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell):
488 """Multi-threaded shell with matplotlib support."""
488 """Multi-threaded shell with matplotlib support."""
489
489
490 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
490 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
491 user_ns = None, **kw):
491 user_ns = None, **kw):
492 user_ns,b2 = self._matplotlib_config(name)
492 user_ns,b2 = self._matplotlib_config(name)
493 MTInteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw)
493 MTInteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw)
494
494
495 #-----------------------------------------------------------------------------
495 #-----------------------------------------------------------------------------
496 # Utility functions for the different GUI enabled IPShell* classes.
496 # Utility functions for the different GUI enabled IPShell* classes.
497
497
498 def get_tk():
498 def get_tk():
499 """Tries to import Tkinter and returns a withdrawn Tkinter root
499 """Tries to import Tkinter and returns a withdrawn Tkinter root
500 window. If Tkinter is already imported or not available, this
500 window. If Tkinter is already imported or not available, this
501 returns None. This function calls `hijack_tk` underneath.
501 returns None. This function calls `hijack_tk` underneath.
502 """
502 """
503 if not USE_TK or sys.modules.has_key('Tkinter'):
503 if not USE_TK or sys.modules.has_key('Tkinter'):
504 return None
504 return None
505 else:
505 else:
506 try:
506 try:
507 import Tkinter
507 import Tkinter
508 except ImportError:
508 except ImportError:
509 return None
509 return None
510 else:
510 else:
511 hijack_tk()
511 hijack_tk()
512 r = Tkinter.Tk()
512 r = Tkinter.Tk()
513 r.withdraw()
513 r.withdraw()
514 return r
514 return r
515
515
516 def hijack_tk():
516 def hijack_tk():
517 """Modifies Tkinter's mainloop with a dummy so when a module calls
517 """Modifies Tkinter's mainloop with a dummy so when a module calls
518 mainloop, it does not block.
518 mainloop, it does not block.
519
519
520 """
520 """
521 def misc_mainloop(self, n=0):
521 def misc_mainloop(self, n=0):
522 pass
522 pass
523 def tkinter_mainloop(n=0):
523 def tkinter_mainloop(n=0):
524 pass
524 pass
525
525
526 import Tkinter
526 import Tkinter
527 Tkinter.Misc.mainloop = misc_mainloop
527 Tkinter.Misc.mainloop = misc_mainloop
528 Tkinter.mainloop = tkinter_mainloop
528 Tkinter.mainloop = tkinter_mainloop
529
529
530 def update_tk(tk):
530 def update_tk(tk):
531 """Updates the Tkinter event loop. This is typically called from
531 """Updates the Tkinter event loop. This is typically called from
532 the respective WX or GTK mainloops.
532 the respective WX or GTK mainloops.
533 """
533 """
534 if tk:
534 if tk:
535 tk.update()
535 tk.update()
536
536
537 def hijack_wx():
537 def hijack_wx():
538 """Modifies wxPython's MainLoop with a dummy so user code does not
538 """Modifies wxPython's MainLoop with a dummy so user code does not
539 block IPython. The hijacked mainloop function is returned.
539 block IPython. The hijacked mainloop function is returned.
540 """
540 """
541 def dummy_mainloop(*args, **kw):
541 def dummy_mainloop(*args, **kw):
542 pass
542 pass
543 import wxPython
543 import wxPython
544 ver = wxPython.__version__
544 ver = wxPython.__version__
545 orig_mainloop = None
545 orig_mainloop = None
546 if ver[:3] >= '2.5':
546 if ver[:3] >= '2.5':
547 import wx
547 import wx
548 if hasattr(wx, '_core_'): core = getattr(wx, '_core_')
548 if hasattr(wx, '_core_'): core = getattr(wx, '_core_')
549 elif hasattr(wx, '_core'): core = getattr(wx, '_core')
549 elif hasattr(wx, '_core'): core = getattr(wx, '_core')
550 else: raise AttributeError('Could not find wx core module')
550 else: raise AttributeError('Could not find wx core module')
551 orig_mainloop = core.PyApp_MainLoop
551 orig_mainloop = core.PyApp_MainLoop
552 core.PyApp_MainLoop = dummy_mainloop
552 core.PyApp_MainLoop = dummy_mainloop
553 elif ver[:3] == '2.4':
553 elif ver[:3] == '2.4':
554 orig_mainloop = wxPython.wxc.wxPyApp_MainLoop
554 orig_mainloop = wxPython.wxc.wxPyApp_MainLoop
555 wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop
555 wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop
556 else:
556 else:
557 warn("Unable to find either wxPython version 2.4 or >= 2.5.")
557 warn("Unable to find either wxPython version 2.4 or >= 2.5.")
558 return orig_mainloop
558 return orig_mainloop
559
559
560 def hijack_gtk():
560 def hijack_gtk():
561 """Modifies pyGTK's mainloop with a dummy so user code does not
561 """Modifies pyGTK's mainloop with a dummy so user code does not
562 block IPython. This function returns the original `gtk.mainloop`
562 block IPython. This function returns the original `gtk.mainloop`
563 function that has been hijacked.
563 function that has been hijacked.
564
565 NOTE: Make sure you import this *AFTER* you call
566 pygtk.require(...).
567 """
564 """
568 def dummy_mainloop(*args, **kw):
565 def dummy_mainloop(*args, **kw):
569 pass
566 pass
570 import gtk
567 import gtk
571 if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main
568 if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main
572 else: orig_mainloop = gtk.mainloop
569 else: orig_mainloop = gtk.mainloop
573 gtk.mainloop = dummy_mainloop
570 gtk.mainloop = dummy_mainloop
574 gtk.main = dummy_mainloop
571 gtk.main = dummy_mainloop
575 return orig_mainloop
572 return orig_mainloop
576
573
577 #-----------------------------------------------------------------------------
574 #-----------------------------------------------------------------------------
578 # The IPShell* classes below are the ones meant to be run by external code as
575 # The IPShell* classes below are the ones meant to be run by external code as
579 # IPython instances. Note that unless a specific threading strategy is
576 # IPython instances. Note that unless a specific threading strategy is
580 # desired, the factory function start() below should be used instead (it
577 # desired, the factory function start() below should be used instead (it
581 # selects the proper threaded class).
578 # selects the proper threaded class).
582
579
583 class IPShellGTK(threading.Thread):
580 class IPShellGTK(threading.Thread):
584 """Run a gtk mainloop() in a separate thread.
581 """Run a gtk mainloop() in a separate thread.
585
582
586 Python commands can be passed to the thread where they will be executed.
583 Python commands can be passed to the thread where they will be executed.
587 This is implemented by periodically checking for passed code using a
584 This is implemented by periodically checking for passed code using a
588 GTK timeout callback."""
585 GTK timeout callback."""
589
586
590 TIMEOUT = 100 # Millisecond interval between timeouts.
587 TIMEOUT = 100 # Millisecond interval between timeouts.
591
588
592 def __init__(self,argv=None,user_ns=None,debug=1,
589 def __init__(self,argv=None,user_ns=None,debug=1,
593 shell_class=MTInteractiveShell):
590 shell_class=MTInteractiveShell):
594
591
595 import pygtk
596 pygtk.require("2.0")
597 import gtk
592 import gtk
598
593
599 self.gtk = gtk
594 self.gtk = gtk
600 self.gtk_mainloop = hijack_gtk()
595 self.gtk_mainloop = hijack_gtk()
601
596
602 # Allows us to use both Tk and GTK.
597 # Allows us to use both Tk and GTK.
603 self.tk = get_tk()
598 self.tk = get_tk()
604
599
605 if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit
600 if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit
606 else: mainquit = self.gtk.mainquit
601 else: mainquit = self.gtk.mainquit
607
602
608 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
603 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
609 shell_class=shell_class,
604 shell_class=shell_class,
610 on_kill=[mainquit])
605 on_kill=[mainquit])
611 threading.Thread.__init__(self)
606 threading.Thread.__init__(self)
612
607
613 def run(self):
608 def run(self):
614 self.IP.mainloop()
609 self.IP.mainloop()
615 self.IP.kill()
610 self.IP.kill()
616
611
617 def mainloop(self):
612 def mainloop(self):
618
613
619 if self.gtk.pygtk_version >= (2,4,0):
614 if self.gtk.pygtk_version >= (2,4,0):
620 import gobject
615 import gobject
621 gobject.timeout_add(self.TIMEOUT, self.on_timer)
616 gobject.timeout_add(self.TIMEOUT, self.on_timer)
622 else:
617 else:
623 self.gtk.timeout_add(self.TIMEOUT, self.on_timer)
618 self.gtk.timeout_add(self.TIMEOUT, self.on_timer)
624
619
625 if sys.platform != 'win32':
620 if sys.platform != 'win32':
626 try:
621 try:
627 if self.gtk.gtk_version[0] >= 2:
622 if self.gtk.gtk_version[0] >= 2:
628 self.gtk.threads_init()
623 self.gtk.threads_init()
629 except AttributeError:
624 except AttributeError:
630 pass
625 pass
631 except RuntimeError:
626 except RuntimeError:
632 error('Your pyGTK likely has not been compiled with '
627 error('Your pyGTK likely has not been compiled with '
633 'threading support.\n'
628 'threading support.\n'
634 'The exception printout is below.\n'
629 'The exception printout is below.\n'
635 'You can either rebuild pyGTK with threads, or '
630 'You can either rebuild pyGTK with threads, or '
636 'try using \n'
631 'try using \n'
637 'matplotlib with a different backend (like Tk or WX).\n'
632 'matplotlib with a different backend (like Tk or WX).\n'
638 'Note that matplotlib will most likely not work in its '
633 'Note that matplotlib will most likely not work in its '
639 'current state!')
634 'current state!')
640 self.IP.InteractiveTB()
635 self.IP.InteractiveTB()
641 self.start()
636 self.start()
642 self.gtk.threads_enter()
637 self.gtk.threads_enter()
643 self.gtk_mainloop()
638 self.gtk_mainloop()
644 self.gtk.threads_leave()
639 self.gtk.threads_leave()
645 self.join()
640 self.join()
646
641
647 def on_timer(self):
642 def on_timer(self):
648 update_tk(self.tk)
643 update_tk(self.tk)
649 return self.IP.runcode()
644 return self.IP.runcode()
650
645
651
646
652 class IPShellWX(threading.Thread):
647 class IPShellWX(threading.Thread):
653 """Run a wx mainloop() in a separate thread.
648 """Run a wx mainloop() in a separate thread.
654
649
655 Python commands can be passed to the thread where they will be executed.
650 Python commands can be passed to the thread where they will be executed.
656 This is implemented by periodically checking for passed code using a
651 This is implemented by periodically checking for passed code using a
657 GTK timeout callback."""
652 GTK timeout callback."""
658
653
659 TIMEOUT = 100 # Millisecond interval between timeouts.
654 TIMEOUT = 100 # Millisecond interval between timeouts.
660
655
661 def __init__(self,argv=None,user_ns=None,debug=1,
656 def __init__(self,argv=None,user_ns=None,debug=1,
662 shell_class=MTInteractiveShell):
657 shell_class=MTInteractiveShell):
663
658
664 import wxPython.wx as wx
659 import wxPython.wx as wx
665
660
666 threading.Thread.__init__(self)
661 threading.Thread.__init__(self)
667 self.wx = wx
662 self.wx = wx
668 self.wx_mainloop = hijack_wx()
663 self.wx_mainloop = hijack_wx()
669
664
670 # Allows us to use both Tk and GTK.
665 # Allows us to use both Tk and GTK.
671 self.tk = get_tk()
666 self.tk = get_tk()
672
667
673 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
668 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
674 shell_class=shell_class,
669 shell_class=shell_class,
675 on_kill=[self.wxexit])
670 on_kill=[self.wxexit])
676 self.app = None
671 self.app = None
677
672
678 def wxexit(self, *args):
673 def wxexit(self, *args):
679 if self.app is not None:
674 if self.app is not None:
680 self.app.agent.timer.Stop()
675 self.app.agent.timer.Stop()
681 self.app.ExitMainLoop()
676 self.app.ExitMainLoop()
682
677
683 def run(self):
678 def run(self):
684 self.IP.mainloop()
679 self.IP.mainloop()
685 self.IP.kill()
680 self.IP.kill()
686
681
687 def mainloop(self):
682 def mainloop(self):
688
683
689 self.start()
684 self.start()
690
685
691 class TimerAgent(self.wx.wxMiniFrame):
686 class TimerAgent(self.wx.wxMiniFrame):
692 wx = self.wx
687 wx = self.wx
693 IP = self.IP
688 IP = self.IP
694 tk = self.tk
689 tk = self.tk
695 def __init__(self, parent, interval):
690 def __init__(self, parent, interval):
696 style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ
691 style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ
697 self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200),
692 self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200),
698 size=(100, 100),style=style)
693 size=(100, 100),style=style)
699 self.Show(False)
694 self.Show(False)
700 self.interval = interval
695 self.interval = interval
701 self.timerId = self.wx.wxNewId()
696 self.timerId = self.wx.wxNewId()
702
697
703 def StartWork(self):
698 def StartWork(self):
704 self.timer = self.wx.wxTimer(self, self.timerId)
699 self.timer = self.wx.wxTimer(self, self.timerId)
705 self.wx.EVT_TIMER(self, self.timerId, self.OnTimer)
700 self.wx.EVT_TIMER(self, self.timerId, self.OnTimer)
706 self.timer.Start(self.interval)
701 self.timer.Start(self.interval)
707
702
708 def OnTimer(self, event):
703 def OnTimer(self, event):
709 update_tk(self.tk)
704 update_tk(self.tk)
710 self.IP.runcode()
705 self.IP.runcode()
711
706
712 class App(self.wx.wxApp):
707 class App(self.wx.wxApp):
713 wx = self.wx
708 wx = self.wx
714 TIMEOUT = self.TIMEOUT
709 TIMEOUT = self.TIMEOUT
715 def OnInit(self):
710 def OnInit(self):
716 'Create the main window and insert the custom frame'
711 'Create the main window and insert the custom frame'
717 self.agent = TimerAgent(None, self.TIMEOUT)
712 self.agent = TimerAgent(None, self.TIMEOUT)
718 self.agent.Show(self.wx.false)
713 self.agent.Show(self.wx.false)
719 self.agent.StartWork()
714 self.agent.StartWork()
720 return self.wx.true
715 return self.wx.true
721
716
722 self.app = App(redirect=False)
717 self.app = App(redirect=False)
723 self.wx_mainloop(self.app)
718 self.wx_mainloop(self.app)
724 self.join()
719 self.join()
725
720
726
721
727 class IPShellQt(threading.Thread):
722 class IPShellQt(threading.Thread):
728 """Run a Qt event loop in a separate thread.
723 """Run a Qt event loop in a separate thread.
729
724
730 Python commands can be passed to the thread where they will be executed.
725 Python commands can be passed to the thread where they will be executed.
731 This is implemented by periodically checking for passed code using a
726 This is implemented by periodically checking for passed code using a
732 Qt timer / slot."""
727 Qt timer / slot."""
733
728
734 TIMEOUT = 100 # Millisecond interval between timeouts.
729 TIMEOUT = 100 # Millisecond interval between timeouts.
735
730
736 def __init__(self,argv=None,user_ns=None,debug=0,
731 def __init__(self,argv=None,user_ns=None,debug=0,
737 shell_class=MTInteractiveShell):
732 shell_class=MTInteractiveShell):
738
733
739 import qt
734 import qt
740
735
741 class newQApplication:
736 class newQApplication:
742 def __init__( self ):
737 def __init__( self ):
743 self.QApplication = qt.QApplication
738 self.QApplication = qt.QApplication
744
739
745 def __call__( *args, **kwargs ):
740 def __call__( *args, **kwargs ):
746 return qt.qApp
741 return qt.qApp
747
742
748 def exec_loop( *args, **kwargs ):
743 def exec_loop( *args, **kwargs ):
749 pass
744 pass
750
745
751 def __getattr__( self, name ):
746 def __getattr__( self, name ):
752 return getattr( self.QApplication, name )
747 return getattr( self.QApplication, name )
753
748
754 qt.QApplication = newQApplication()
749 qt.QApplication = newQApplication()
755
750
756 # Allows us to use both Tk and QT.
751 # Allows us to use both Tk and QT.
757 self.tk = get_tk()
752 self.tk = get_tk()
758
753
759 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
754 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
760 shell_class=shell_class,
755 shell_class=shell_class,
761 on_kill=[qt.qApp.exit])
756 on_kill=[qt.qApp.exit])
762
757
763 threading.Thread.__init__(self)
758 threading.Thread.__init__(self)
764
759
765 def run(self):
760 def run(self):
766 #sys.excepthook = self.IP.excepthook # dbg
761 #sys.excepthook = self.IP.excepthook # dbg
767 self.IP.mainloop()
762 self.IP.mainloop()
768 self.IP.kill()
763 self.IP.kill()
769
764
770 def mainloop(self):
765 def mainloop(self):
771 import qt, sys
766 import qt, sys
772 if qt.QApplication.startingUp():
767 if qt.QApplication.startingUp():
773 a = qt.QApplication.QApplication( sys.argv )
768 a = qt.QApplication.QApplication( sys.argv )
774 self.timer = qt.QTimer()
769 self.timer = qt.QTimer()
775 qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer )
770 qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer )
776
771
777 self.start()
772 self.start()
778 self.timer.start( self.TIMEOUT, True )
773 self.timer.start( self.TIMEOUT, True )
779 while True:
774 while True:
780 if self.IP._kill: break
775 if self.IP._kill: break
781 qt.qApp.exec_loop()
776 qt.qApp.exec_loop()
782 self.join()
777 self.join()
783
778
784 def on_timer(self):
779 def on_timer(self):
785 update_tk(self.tk)
780 update_tk(self.tk)
786 result = self.IP.runcode()
781 result = self.IP.runcode()
787 self.timer.start( self.TIMEOUT, True )
782 self.timer.start( self.TIMEOUT, True )
788 return result
783 return result
789
784
790 # A set of matplotlib public IPython shell classes, for single-threaded
785 # A set of matplotlib public IPython shell classes, for single-threaded
791 # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use.
786 # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use.
792 class IPShellMatplotlib(IPShell):
787 class IPShellMatplotlib(IPShell):
793 """Subclass IPShell with MatplotlibShell as the internal shell.
788 """Subclass IPShell with MatplotlibShell as the internal shell.
794
789
795 Single-threaded class, meant for the Tk* and FLTK* backends.
790 Single-threaded class, meant for the Tk* and FLTK* backends.
796
791
797 Having this on a separate class simplifies the external driver code."""
792 Having this on a separate class simplifies the external driver code."""
798
793
799 def __init__(self,argv=None,user_ns=None,debug=1):
794 def __init__(self,argv=None,user_ns=None,debug=1):
800 IPShell.__init__(self,argv,user_ns,debug,shell_class=MatplotlibShell)
795 IPShell.__init__(self,argv,user_ns,debug,shell_class=MatplotlibShell)
801
796
802 class IPShellMatplotlibGTK(IPShellGTK):
797 class IPShellMatplotlibGTK(IPShellGTK):
803 """Subclass IPShellGTK with MatplotlibMTShell as the internal shell.
798 """Subclass IPShellGTK with MatplotlibMTShell as the internal shell.
804
799
805 Multi-threaded class, meant for the GTK* backends."""
800 Multi-threaded class, meant for the GTK* backends."""
806
801
807 def __init__(self,argv=None,user_ns=None,debug=1):
802 def __init__(self,argv=None,user_ns=None,debug=1):
808 IPShellGTK.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
803 IPShellGTK.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
809
804
810 class IPShellMatplotlibWX(IPShellWX):
805 class IPShellMatplotlibWX(IPShellWX):
811 """Subclass IPShellWX with MatplotlibMTShell as the internal shell.
806 """Subclass IPShellWX with MatplotlibMTShell as the internal shell.
812
807
813 Multi-threaded class, meant for the WX* backends."""
808 Multi-threaded class, meant for the WX* backends."""
814
809
815 def __init__(self,argv=None,user_ns=None,debug=1):
810 def __init__(self,argv=None,user_ns=None,debug=1):
816 IPShellWX.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
811 IPShellWX.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
817
812
818 class IPShellMatplotlibQt(IPShellQt):
813 class IPShellMatplotlibQt(IPShellQt):
819 """Subclass IPShellQt with MatplotlibMTShell as the internal shell.
814 """Subclass IPShellQt with MatplotlibMTShell as the internal shell.
820
815
821 Multi-threaded class, meant for the Qt* backends."""
816 Multi-threaded class, meant for the Qt* backends."""
822
817
823 def __init__(self,argv=None,user_ns=None,debug=1):
818 def __init__(self,argv=None,user_ns=None,debug=1):
824 IPShellQt.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
819 IPShellQt.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
825
820
826 #-----------------------------------------------------------------------------
821 #-----------------------------------------------------------------------------
827 # Factory functions to actually start the proper thread-aware shell
822 # Factory functions to actually start the proper thread-aware shell
828
823
829 def _matplotlib_shell_class():
824 def _matplotlib_shell_class():
830 """Factory function to handle shell class selection for matplotlib.
825 """Factory function to handle shell class selection for matplotlib.
831
826
832 The proper shell class to use depends on the matplotlib backend, since
827 The proper shell class to use depends on the matplotlib backend, since
833 each backend requires a different threading strategy."""
828 each backend requires a different threading strategy."""
834
829
835 try:
830 try:
836 import matplotlib
831 import matplotlib
837 except ImportError:
832 except ImportError:
838 error('matplotlib could NOT be imported! Starting normal IPython.')
833 error('matplotlib could NOT be imported! Starting normal IPython.')
839 sh_class = IPShell
834 sh_class = IPShell
840 else:
835 else:
841 backend = matplotlib.rcParams['backend']
836 backend = matplotlib.rcParams['backend']
842 if backend.startswith('GTK'):
837 if backend.startswith('GTK'):
843 sh_class = IPShellMatplotlibGTK
838 sh_class = IPShellMatplotlibGTK
844 elif backend.startswith('WX'):
839 elif backend.startswith('WX'):
845 sh_class = IPShellMatplotlibWX
840 sh_class = IPShellMatplotlibWX
846 elif backend.startswith('Qt'):
841 elif backend.startswith('Qt'):
847 sh_class = IPShellMatplotlibQt
842 sh_class = IPShellMatplotlibQt
848 else:
843 else:
849 sh_class = IPShellMatplotlib
844 sh_class = IPShellMatplotlib
850 #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg
845 #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg
851 return sh_class
846 return sh_class
852
847
853 # This is the one which should be called by external code.
848 # This is the one which should be called by external code.
854 def start():
849 def start():
855 """Return a running shell instance, dealing with threading options.
850 """Return a running shell instance, dealing with threading options.
856
851
857 This is a factory function which will instantiate the proper IPython shell
852 This is a factory function which will instantiate the proper IPython shell
858 based on the user's threading choice. Such a selector is needed because
853 based on the user's threading choice. Such a selector is needed because
859 different GUI toolkits require different thread handling details."""
854 different GUI toolkits require different thread handling details."""
860
855
861 global USE_TK
856 global USE_TK
862 # Crude sys.argv hack to extract the threading options.
857 # Crude sys.argv hack to extract the threading options.
863 if len(sys.argv) > 1:
858 if len(sys.argv) > 1:
864 if len(sys.argv) > 2:
859 if len(sys.argv) > 2:
865 arg2 = sys.argv[2]
860 arg2 = sys.argv[2]
866 if arg2.endswith('-tk'):
861 if arg2.endswith('-tk'):
867 USE_TK = True
862 USE_TK = True
868 arg1 = sys.argv[1]
863 arg1 = sys.argv[1]
869 if arg1.endswith('-gthread'):
864 if arg1.endswith('-gthread'):
870 shell = IPShellGTK
865 shell = IPShellGTK
871 elif arg1.endswith( '-qthread' ):
866 elif arg1.endswith( '-qthread' ):
872 shell = IPShellQt
867 shell = IPShellQt
873 elif arg1.endswith('-wthread'):
868 elif arg1.endswith('-wthread'):
874 shell = IPShellWX
869 shell = IPShellWX
875 elif arg1.endswith('-pylab'):
870 elif arg1.endswith('-pylab'):
876 shell = _matplotlib_shell_class()
871 shell = _matplotlib_shell_class()
877 else:
872 else:
878 shell = IPShell
873 shell = IPShell
879 else:
874 else:
880 shell = IPShell
875 shell = IPShell
881 return shell()
876 return shell()
882
877
883 # Some aliases for backwards compatibility
878 # Some aliases for backwards compatibility
884 IPythonShell = IPShell
879 IPythonShell = IPShell
885 IPythonShellEmbed = IPShellEmbed
880 IPythonShellEmbed = IPShellEmbed
886 #************************ End of file <Shell.py> ***************************
881 #************************ End of file <Shell.py> ***************************
@@ -1,2041 +1,2047
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.1 or newer.
5 Requires Python 2.1 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 774 2005-09-01 00:27:53Z fperez $
9 $Id: iplib.py 802 2005-09-06 03:49:12Z fperez $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
14 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
18 #
18 #
19 # Note: this code originally subclassed code.InteractiveConsole from the
19 # Note: this code originally subclassed code.InteractiveConsole from the
20 # Python standard library. Over time, much of that class has been copied
20 # Python standard library. Over time, much of that class has been copied
21 # verbatim here for modifications which could not be accomplished by
21 # verbatim here for modifications which could not be accomplished by
22 # subclassing. The Python License (sec. 2) allows for this, but it's always
22 # subclassing. The Python License (sec. 2) allows for this, but it's always
23 # nice to acknowledge credit where credit is due.
23 # nice to acknowledge credit where credit is due.
24 #*****************************************************************************
24 #*****************************************************************************
25
25
26 #****************************************************************************
26 #****************************************************************************
27 # Modules and globals
27 # Modules and globals
28
28
29 from __future__ import generators # for 2.2 backwards-compatibility
29 from __future__ import generators # for 2.2 backwards-compatibility
30
30
31 from IPython import Release
31 from IPython import Release
32 __author__ = '%s <%s>\n%s <%s>' % \
32 __author__ = '%s <%s>\n%s <%s>' % \
33 ( Release.authors['Janko'] + Release.authors['Fernando'] )
33 ( Release.authors['Janko'] + Release.authors['Fernando'] )
34 __license__ = Release.license
34 __license__ = Release.license
35 __version__ = Release.version
35 __version__ = Release.version
36
36
37 # Python standard modules
37 # Python standard modules
38 import __main__
38 import __main__
39 import __builtin__
39 import __builtin__
40 import exceptions
40 import exceptions
41 import keyword
41 import keyword
42 import new
42 import new
43 import os, sys, shutil
43 import os, sys, shutil
44 import code, glob, types, re
44 import code, glob, types, re
45 import string, StringIO
45 import string, StringIO
46 import inspect, pydoc
46 import inspect, pydoc
47 import bdb, pdb
47 import bdb, pdb
48 import UserList # don't subclass list so this works with Python2.1
48 import UserList # don't subclass list so this works with Python2.1
49 from pprint import pprint, pformat
49 from pprint import pprint, pformat
50 import cPickle as pickle
50 import cPickle as pickle
51 import traceback
51 import traceback
52
52
53 # IPython's own modules
53 # IPython's own modules
54 import IPython
54 import IPython
55 from IPython import OInspect,PyColorize,ultraTB
55 from IPython import OInspect,PyColorize,ultraTB
56 from IPython.ultraTB import ColorScheme,ColorSchemeTable # too long names
56 from IPython.ultraTB import ColorScheme,ColorSchemeTable # too long names
57 from IPython.Logger import Logger
57 from IPython.Logger import Logger
58 from IPython.Magic import Magic,magic2python,shlex_split
58 from IPython.Magic import Magic,magic2python,shlex_split
59 from IPython.usage import cmd_line_usage,interactive_usage
59 from IPython.usage import cmd_line_usage,interactive_usage
60 from IPython.Struct import Struct
60 from IPython.Struct import Struct
61 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
61 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
62 from IPython.FakeModule import FakeModule
62 from IPython.FakeModule import FakeModule
63 from IPython.background_jobs import BackgroundJobManager
63 from IPython.background_jobs import BackgroundJobManager
64 from IPython.genutils import *
64 from IPython.genutils import *
65
65
66 # Global pointer to the running
66 # Global pointer to the running
67
67
68 # store the builtin raw_input globally, and use this always, in case user code
68 # store the builtin raw_input globally, and use this always, in case user code
69 # overwrites it (like wx.py.PyShell does)
69 # overwrites it (like wx.py.PyShell does)
70 raw_input_original = raw_input
70 raw_input_original = raw_input
71
71
72 #****************************************************************************
72 #****************************************************************************
73 # Some utility function definitions
73 # Some utility function definitions
74
74
75 class Bunch: pass
75 class Bunch: pass
76
76
77 def esc_quotes(strng):
77 def esc_quotes(strng):
78 """Return the input string with single and double quotes escaped out"""
78 """Return the input string with single and double quotes escaped out"""
79
79
80 return strng.replace('"','\\"').replace("'","\\'")
80 return strng.replace('"','\\"').replace("'","\\'")
81
81
82 def import_fail_info(mod_name,fns=None):
82 def import_fail_info(mod_name,fns=None):
83 """Inform load failure for a module."""
83 """Inform load failure for a module."""
84
84
85 if fns == None:
85 if fns == None:
86 warn("Loading of %s failed.\n" % (mod_name,))
86 warn("Loading of %s failed.\n" % (mod_name,))
87 else:
87 else:
88 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
88 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
89
89
90 def qw_lol(indata):
90 def qw_lol(indata):
91 """qw_lol('a b') -> [['a','b']],
91 """qw_lol('a b') -> [['a','b']],
92 otherwise it's just a call to qw().
92 otherwise it's just a call to qw().
93
93
94 We need this to make sure the modules_some keys *always* end up as a
94 We need this to make sure the modules_some keys *always* end up as a
95 list of lists."""
95 list of lists."""
96
96
97 if type(indata) in StringTypes:
97 if type(indata) in StringTypes:
98 return [qw(indata)]
98 return [qw(indata)]
99 else:
99 else:
100 return qw(indata)
100 return qw(indata)
101
101
102 def ipmagic(arg_s):
102 def ipmagic(arg_s):
103 """Call a magic function by name.
103 """Call a magic function by name.
104
104
105 Input: a string containing the name of the magic function to call and any
105 Input: a string containing the name of the magic function to call and any
106 additional arguments to be passed to the magic.
106 additional arguments to be passed to the magic.
107
107
108 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
108 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
109 prompt:
109 prompt:
110
110
111 In[1]: %name -opt foo bar
111 In[1]: %name -opt foo bar
112
112
113 To call a magic without arguments, simply use ipmagic('name').
113 To call a magic without arguments, simply use ipmagic('name').
114
114
115 This provides a proper Python function to call IPython's magics in any
115 This provides a proper Python function to call IPython's magics in any
116 valid Python code you can type at the interpreter, including loops and
116 valid Python code you can type at the interpreter, including loops and
117 compound statements. It is added by IPython to the Python builtin
117 compound statements. It is added by IPython to the Python builtin
118 namespace upon initialization."""
118 namespace upon initialization."""
119
119
120 args = arg_s.split(' ',1)
120 args = arg_s.split(' ',1)
121 magic_name = args[0]
121 magic_name = args[0]
122 if magic_name.startswith(__IPYTHON__.ESC_MAGIC):
122 if magic_name.startswith(__IPYTHON__.ESC_MAGIC):
123 magic_name = magic_name[1:]
123 magic_name = magic_name[1:]
124 try:
124 try:
125 magic_args = args[1]
125 magic_args = args[1]
126 except IndexError:
126 except IndexError:
127 magic_args = ''
127 magic_args = ''
128 fn = getattr(__IPYTHON__,'magic_'+magic_name,None)
128 fn = getattr(__IPYTHON__,'magic_'+magic_name,None)
129 if fn is None:
129 if fn is None:
130 error("Magic function `%s` not found." % magic_name)
130 error("Magic function `%s` not found." % magic_name)
131 else:
131 else:
132 magic_args = __IPYTHON__.var_expand(magic_args)
132 magic_args = __IPYTHON__.var_expand(magic_args)
133 return fn(magic_args)
133 return fn(magic_args)
134
134
135 def ipalias(arg_s):
135 def ipalias(arg_s):
136 """Call an alias by name.
136 """Call an alias by name.
137
137
138 Input: a string containing the name of the alias to call and any
138 Input: a string containing the name of the alias to call and any
139 additional arguments to be passed to the magic.
139 additional arguments to be passed to the magic.
140
140
141 ipalias('name -opt foo bar') is equivalent to typing at the ipython
141 ipalias('name -opt foo bar') is equivalent to typing at the ipython
142 prompt:
142 prompt:
143
143
144 In[1]: name -opt foo bar
144 In[1]: name -opt foo bar
145
145
146 To call an alias without arguments, simply use ipalias('name').
146 To call an alias without arguments, simply use ipalias('name').
147
147
148 This provides a proper Python function to call IPython's aliases in any
148 This provides a proper Python function to call IPython's aliases in any
149 valid Python code you can type at the interpreter, including loops and
149 valid Python code you can type at the interpreter, including loops and
150 compound statements. It is added by IPython to the Python builtin
150 compound statements. It is added by IPython to the Python builtin
151 namespace upon initialization."""
151 namespace upon initialization."""
152
152
153 args = arg_s.split(' ',1)
153 args = arg_s.split(' ',1)
154 alias_name = args[0]
154 alias_name = args[0]
155 try:
155 try:
156 alias_args = args[1]
156 alias_args = args[1]
157 except IndexError:
157 except IndexError:
158 alias_args = ''
158 alias_args = ''
159 if alias_name in __IPYTHON__.alias_table:
159 if alias_name in __IPYTHON__.alias_table:
160 __IPYTHON__.call_alias(alias_name,alias_args)
160 __IPYTHON__.call_alias(alias_name,alias_args)
161 else:
161 else:
162 error("Alias `%s` not found." % alias_name)
162 error("Alias `%s` not found." % alias_name)
163
163
164 #-----------------------------------------------------------------------------
164 #-----------------------------------------------------------------------------
165 # Local use classes
165 # Local use classes
166 try:
166 try:
167 from IPython import FlexCompleter
167 from IPython import FlexCompleter
168
168
169 class MagicCompleter(FlexCompleter.Completer):
169 class MagicCompleter(FlexCompleter.Completer):
170 """Extension of the completer class to work on %-prefixed lines."""
170 """Extension of the completer class to work on %-prefixed lines."""
171
171
172 def __init__(self,shell,namespace=None,omit__names=0,alias_table=None):
172 def __init__(self,shell,namespace=None,omit__names=0,alias_table=None):
173 """MagicCompleter() -> completer
173 """MagicCompleter() -> completer
174
174
175 Return a completer object suitable for use by the readline library
175 Return a completer object suitable for use by the readline library
176 via readline.set_completer().
176 via readline.set_completer().
177
177
178 Inputs:
178 Inputs:
179
179
180 - shell: a pointer to the ipython shell itself. This is needed
180 - shell: a pointer to the ipython shell itself. This is needed
181 because this completer knows about magic functions, and those can
181 because this completer knows about magic functions, and those can
182 only be accessed via the ipython instance.
182 only be accessed via the ipython instance.
183
183
184 - namespace: an optional dict where completions are performed.
184 - namespace: an optional dict where completions are performed.
185
185
186 - The optional omit__names parameter sets the completer to omit the
186 - The optional omit__names parameter sets the completer to omit the
187 'magic' names (__magicname__) for python objects unless the text
187 'magic' names (__magicname__) for python objects unless the text
188 to be completed explicitly starts with one or more underscores.
188 to be completed explicitly starts with one or more underscores.
189
189
190 - If alias_table is supplied, it should be a dictionary of aliases
190 - If alias_table is supplied, it should be a dictionary of aliases
191 to complete. """
191 to complete. """
192
192
193 FlexCompleter.Completer.__init__(self,namespace)
193 FlexCompleter.Completer.__init__(self,namespace)
194 self.magic_prefix = shell.name+'.magic_'
194 self.magic_prefix = shell.name+'.magic_'
195 self.magic_escape = shell.ESC_MAGIC
195 self.magic_escape = shell.ESC_MAGIC
196 self.readline = FlexCompleter.readline
196 self.readline = FlexCompleter.readline
197 delims = self.readline.get_completer_delims()
197 delims = self.readline.get_completer_delims()
198 delims = delims.replace(self.magic_escape,'')
198 delims = delims.replace(self.magic_escape,'')
199 self.readline.set_completer_delims(delims)
199 self.readline.set_completer_delims(delims)
200 self.get_line_buffer = self.readline.get_line_buffer
200 self.get_line_buffer = self.readline.get_line_buffer
201 self.omit__names = omit__names
201 self.omit__names = omit__names
202 self.merge_completions = shell.rc.readline_merge_completions
202 self.merge_completions = shell.rc.readline_merge_completions
203
203
204 if alias_table is None:
204 if alias_table is None:
205 alias_table = {}
205 alias_table = {}
206 self.alias_table = alias_table
206 self.alias_table = alias_table
207 # Regexp to split filenames with spaces in them
207 # Regexp to split filenames with spaces in them
208 self.space_name_re = re.compile(r'([^\\] )')
208 self.space_name_re = re.compile(r'([^\\] )')
209 # Hold a local ref. to glob.glob for speed
209 # Hold a local ref. to glob.glob for speed
210 self.glob = glob.glob
210 self.glob = glob.glob
211 # Special handling of backslashes needed in win32 platforms
211 # Special handling of backslashes needed in win32 platforms
212 if sys.platform == "win32":
212 if sys.platform == "win32":
213 self.clean_glob = self._clean_glob_win32
213 self.clean_glob = self._clean_glob_win32
214 else:
214 else:
215 self.clean_glob = self._clean_glob
215 self.clean_glob = self._clean_glob
216 self.matchers = [self.python_matches,
216 self.matchers = [self.python_matches,
217 self.file_matches,
217 self.file_matches,
218 self.alias_matches,
218 self.alias_matches,
219 self.python_func_kw_matches]
219 self.python_func_kw_matches]
220
220
221 # Code contributed by Alex Schmolck, for ipython/emacs integration
221 # Code contributed by Alex Schmolck, for ipython/emacs integration
222 def all_completions(self, text):
222 def all_completions(self, text):
223 """Return all possible completions for the benefit of emacs."""
223 """Return all possible completions for the benefit of emacs."""
224
224
225 completions = []
225 completions = []
226 try:
226 try:
227 for i in xrange(sys.maxint):
227 for i in xrange(sys.maxint):
228 res = self.complete(text, i)
228 res = self.complete(text, i)
229
229
230 if not res: break
230 if not res: break
231
231
232 completions.append(res)
232 completions.append(res)
233 #XXX workaround for ``notDefined.<tab>``
233 #XXX workaround for ``notDefined.<tab>``
234 except NameError:
234 except NameError:
235 pass
235 pass
236 return completions
236 return completions
237 # /end Alex Schmolck code.
237 # /end Alex Schmolck code.
238
238
239 def _clean_glob(self,text):
239 def _clean_glob(self,text):
240 return self.glob("%s*" % text)
240 return self.glob("%s*" % text)
241
241
242 def _clean_glob_win32(self,text):
242 def _clean_glob_win32(self,text):
243 return [f.replace("\\","/")
243 return [f.replace("\\","/")
244 for f in self.glob("%s*" % text)]
244 for f in self.glob("%s*" % text)]
245
245
246 def file_matches(self, text):
246 def file_matches(self, text):
247 """Match filneames, expanding ~USER type strings.
247 """Match filneames, expanding ~USER type strings.
248
248
249 Most of the seemingly convoluted logic in this completer is an
249 Most of the seemingly convoluted logic in this completer is an
250 attempt to handle filenames with spaces in them. And yet it's not
250 attempt to handle filenames with spaces in them. And yet it's not
251 quite perfect, because Python's readline doesn't expose all of the
251 quite perfect, because Python's readline doesn't expose all of the
252 GNU readline details needed for this to be done correctly.
252 GNU readline details needed for this to be done correctly.
253
253
254 For a filename with a space in it, the printed completions will be
254 For a filename with a space in it, the printed completions will be
255 only the parts after what's already been typed (instead of the
255 only the parts after what's already been typed (instead of the
256 full completions, as is normally done). I don't think with the
256 full completions, as is normally done). I don't think with the
257 current (as of Python 2.3) Python readline it's possible to do
257 current (as of Python 2.3) Python readline it's possible to do
258 better."""
258 better."""
259
259
260 #print 'Completer->file_matches: <%s>' % text # dbg
260 #print 'Completer->file_matches: <%s>' % text # dbg
261
261
262 # chars that require escaping with backslash - i.e. chars
262 # chars that require escaping with backslash - i.e. chars
263 # that readline treats incorrectly as delimiters, but we
263 # that readline treats incorrectly as delimiters, but we
264 # don't want to treat as delimiters in filename matching
264 # don't want to treat as delimiters in filename matching
265 # when escaped with backslash
265 # when escaped with backslash
266
266
267 protectables = ' ()[]{}'
267 protectables = ' ()[]{}'
268
268
269 def protect_filename(s):
269 def protect_filename(s):
270 return "".join([(ch in protectables and '\\' + ch or ch)
270 return "".join([(ch in protectables and '\\' + ch or ch)
271 for ch in s])
271 for ch in s])
272
272
273 lbuf = self.get_line_buffer()[:self.readline.get_endidx()]
273 lbuf = self.get_line_buffer()[:self.readline.get_endidx()]
274 open_quotes = 0 # track strings with open quotes
274 open_quotes = 0 # track strings with open quotes
275 try:
275 try:
276 lsplit = shlex_split(lbuf)[-1]
276 lsplit = shlex_split(lbuf)[-1]
277 except ValueError:
277 except ValueError:
278 # typically an unmatched ", or backslash without escaped char.
278 # typically an unmatched ", or backslash without escaped char.
279 if lbuf.count('"')==1:
279 if lbuf.count('"')==1:
280 open_quotes = 1
280 open_quotes = 1
281 lsplit = lbuf.split('"')[-1]
281 lsplit = lbuf.split('"')[-1]
282 elif lbuf.count("'")==1:
282 elif lbuf.count("'")==1:
283 open_quotes = 1
283 open_quotes = 1
284 lsplit = lbuf.split("'")[-1]
284 lsplit = lbuf.split("'")[-1]
285 else:
285 else:
286 return None
286 return None
287 except IndexError:
287 except IndexError:
288 # tab pressed on empty line
288 # tab pressed on empty line
289 lsplit = ""
289 lsplit = ""
290
290
291 if lsplit != protect_filename(lsplit):
291 if lsplit != protect_filename(lsplit):
292 # if protectables are found, do matching on the whole escaped
292 # if protectables are found, do matching on the whole escaped
293 # name
293 # name
294 has_protectables = 1
294 has_protectables = 1
295 text0,text = text,lsplit
295 text0,text = text,lsplit
296 else:
296 else:
297 has_protectables = 0
297 has_protectables = 0
298 text = os.path.expanduser(text)
298 text = os.path.expanduser(text)
299
299
300 if text == "":
300 if text == "":
301 return [protect_filename(f) for f in self.glob("*")]
301 return [protect_filename(f) for f in self.glob("*")]
302
302
303 m0 = self.clean_glob(text.replace('\\',''))
303 m0 = self.clean_glob(text.replace('\\',''))
304 if has_protectables:
304 if has_protectables:
305 # If we had protectables, we need to revert our changes to the
305 # If we had protectables, we need to revert our changes to the
306 # beginning of filename so that we don't double-write the part
306 # beginning of filename so that we don't double-write the part
307 # of the filename we have so far
307 # of the filename we have so far
308 len_lsplit = len(lsplit)
308 len_lsplit = len(lsplit)
309 matches = [text0 + protect_filename(f[len_lsplit:]) for f in m0]
309 matches = [text0 + protect_filename(f[len_lsplit:]) for f in m0]
310 else:
310 else:
311 if open_quotes:
311 if open_quotes:
312 # if we have a string with an open quote, we don't need to
312 # if we have a string with an open quote, we don't need to
313 # protect the names at all (and we _shouldn't_, as it
313 # protect the names at all (and we _shouldn't_, as it
314 # would cause bugs when the filesystem call is made).
314 # would cause bugs when the filesystem call is made).
315 matches = m0
315 matches = m0
316 else:
316 else:
317 matches = [protect_filename(f) for f in m0]
317 matches = [protect_filename(f) for f in m0]
318 if len(matches) == 1 and os.path.isdir(matches[0]):
318 if len(matches) == 1 and os.path.isdir(matches[0]):
319 # Takes care of links to directories also. Use '/'
319 # Takes care of links to directories also. Use '/'
320 # explicitly, even under Windows, so that name completions
320 # explicitly, even under Windows, so that name completions
321 # don't end up escaped.
321 # don't end up escaped.
322 matches[0] += '/'
322 matches[0] += '/'
323 return matches
323 return matches
324
324
325 def alias_matches(self, text):
325 def alias_matches(self, text):
326 """Match internal system aliases"""
326 """Match internal system aliases"""
327 #print 'Completer->alias_matches:',text # dbg
327 #print 'Completer->alias_matches:',text # dbg
328 text = os.path.expanduser(text)
328 text = os.path.expanduser(text)
329 aliases = self.alias_table.keys()
329 aliases = self.alias_table.keys()
330 if text == "":
330 if text == "":
331 return aliases
331 return aliases
332 else:
332 else:
333 return [alias for alias in aliases if alias.startswith(text)]
333 return [alias for alias in aliases if alias.startswith(text)]
334
334
335 def python_matches(self,text):
335 def python_matches(self,text):
336 """Match attributes or global python names"""
336 """Match attributes or global python names"""
337 #print 'Completer->python_matches' # dbg
337 #print 'Completer->python_matches' # dbg
338 if "." in text:
338 if "." in text:
339 try:
339 try:
340 matches = self.attr_matches(text)
340 matches = self.attr_matches(text)
341 if text.endswith('.') and self.omit__names:
341 if text.endswith('.') and self.omit__names:
342 if self.omit__names == 1:
342 if self.omit__names == 1:
343 # true if txt is _not_ a __ name, false otherwise:
343 # true if txt is _not_ a __ name, false otherwise:
344 no__name = (lambda txt:
344 no__name = (lambda txt:
345 re.match(r'.*\.__.*?__',txt) is None)
345 re.match(r'.*\.__.*?__',txt) is None)
346 else:
346 else:
347 # true if txt is _not_ a _ name, false otherwise:
347 # true if txt is _not_ a _ name, false otherwise:
348 no__name = (lambda txt:
348 no__name = (lambda txt:
349 re.match(r'.*\._.*?',txt) is None)
349 re.match(r'.*\._.*?',txt) is None)
350 matches = filter(no__name, matches)
350 matches = filter(no__name, matches)
351 except NameError:
351 except NameError:
352 # catches <undefined attributes>.<tab>
352 # catches <undefined attributes>.<tab>
353 matches = []
353 matches = []
354 else:
354 else:
355 matches = self.global_matches(text)
355 matches = self.global_matches(text)
356 # this is so completion finds magics when automagic is on:
356 # this is so completion finds magics when automagic is on:
357 if matches == [] and not text.startswith(os.sep):
357 if matches == [] and not text.startswith(os.sep):
358 matches = self.attr_matches(self.magic_prefix+text)
358 matches = self.attr_matches(self.magic_prefix+text)
359 return matches
359 return matches
360
360
361 def _default_arguments(self, obj):
361 def _default_arguments(self, obj):
362 """Return the list of default arguments of obj if it is callable,
362 """Return the list of default arguments of obj if it is callable,
363 or empty list otherwise."""
363 or empty list otherwise."""
364
364
365 if not (inspect.isfunction(obj) or inspect.ismethod(obj)):
365 if not (inspect.isfunction(obj) or inspect.ismethod(obj)):
366 # for classes, check for __init__,__new__
366 # for classes, check for __init__,__new__
367 if inspect.isclass(obj):
367 if inspect.isclass(obj):
368 obj = (getattr(obj,'__init__',None) or
368 obj = (getattr(obj,'__init__',None) or
369 getattr(obj,'__new__',None))
369 getattr(obj,'__new__',None))
370 # for all others, check if they are __call__able
370 # for all others, check if they are __call__able
371 elif hasattr(obj, '__call__'):
371 elif hasattr(obj, '__call__'):
372 obj = obj.__call__
372 obj = obj.__call__
373 # XXX: is there a way to handle the builtins ?
373 # XXX: is there a way to handle the builtins ?
374 try:
374 try:
375 args,_,_1,defaults = inspect.getargspec(obj)
375 args,_,_1,defaults = inspect.getargspec(obj)
376 if defaults:
376 if defaults:
377 return args[-len(defaults):]
377 return args[-len(defaults):]
378 except TypeError: pass
378 except TypeError: pass
379 return []
379 return []
380
380
381 def python_func_kw_matches(self,text):
381 def python_func_kw_matches(self,text):
382 """Match named parameters (kwargs) of the last open function"""
382 """Match named parameters (kwargs) of the last open function"""
383
383
384 if "." in text: # a parameter cannot be dotted
384 if "." in text: # a parameter cannot be dotted
385 return []
385 return []
386 try: regexp = self.__funcParamsRegex
386 try: regexp = self.__funcParamsRegex
387 except AttributeError:
387 except AttributeError:
388 regexp = self.__funcParamsRegex = re.compile(r'''
388 regexp = self.__funcParamsRegex = re.compile(r'''
389 '.*?' | # single quoted strings or
389 '.*?' | # single quoted strings or
390 ".*?" | # double quoted strings or
390 ".*?" | # double quoted strings or
391 \w+ | # identifier
391 \w+ | # identifier
392 \S # other characters
392 \S # other characters
393 ''', re.VERBOSE | re.DOTALL)
393 ''', re.VERBOSE | re.DOTALL)
394 # 1. find the nearest identifier that comes before an unclosed
394 # 1. find the nearest identifier that comes before an unclosed
395 # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo"
395 # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo"
396 tokens = regexp.findall(self.get_line_buffer())
396 tokens = regexp.findall(self.get_line_buffer())
397 tokens.reverse()
397 tokens.reverse()
398 iterTokens = iter(tokens); openPar = 0
398 iterTokens = iter(tokens); openPar = 0
399 for token in iterTokens:
399 for token in iterTokens:
400 if token == ')':
400 if token == ')':
401 openPar -= 1
401 openPar -= 1
402 elif token == '(':
402 elif token == '(':
403 openPar += 1
403 openPar += 1
404 if openPar > 0:
404 if openPar > 0:
405 # found the last unclosed parenthesis
405 # found the last unclosed parenthesis
406 break
406 break
407 else:
407 else:
408 return []
408 return []
409 # 2. Concatenate any dotted names (e.g. "foo.bar" for "foo.bar(x, pa" )
409 # 2. Concatenate any dotted names (e.g. "foo.bar" for "foo.bar(x, pa" )
410 ids = []
410 ids = []
411 isId = re.compile(r'\w+$').match
411 isId = re.compile(r'\w+$').match
412 while True:
412 while True:
413 try:
413 try:
414 ids.append(iterTokens.next())
414 ids.append(iterTokens.next())
415 if not isId(ids[-1]):
415 if not isId(ids[-1]):
416 ids.pop(); break
416 ids.pop(); break
417 if not iterTokens.next() == '.':
417 if not iterTokens.next() == '.':
418 break
418 break
419 except StopIteration:
419 except StopIteration:
420 break
420 break
421 # lookup the candidate callable matches either using global_matches
421 # lookup the candidate callable matches either using global_matches
422 # or attr_matches for dotted names
422 # or attr_matches for dotted names
423 if len(ids) == 1:
423 if len(ids) == 1:
424 callableMatches = self.global_matches(ids[0])
424 callableMatches = self.global_matches(ids[0])
425 else:
425 else:
426 callableMatches = self.attr_matches('.'.join(ids[::-1]))
426 callableMatches = self.attr_matches('.'.join(ids[::-1]))
427 argMatches = []
427 argMatches = []
428 for callableMatch in callableMatches:
428 for callableMatch in callableMatches:
429 try: namedArgs = self._default_arguments(eval(callableMatch,
429 try: namedArgs = self._default_arguments(eval(callableMatch,
430 self.namespace))
430 self.namespace))
431 except: continue
431 except: continue
432 for namedArg in namedArgs:
432 for namedArg in namedArgs:
433 if namedArg.startswith(text):
433 if namedArg.startswith(text):
434 argMatches.append("%s=" %namedArg)
434 argMatches.append("%s=" %namedArg)
435 return argMatches
435 return argMatches
436
436
437 def complete(self, text, state):
437 def complete(self, text, state):
438 """Return the next possible completion for 'text'.
438 """Return the next possible completion for 'text'.
439
439
440 This is called successively with state == 0, 1, 2, ... until it
440 This is called successively with state == 0, 1, 2, ... until it
441 returns None. The completion should begin with 'text'. """
441 returns None. The completion should begin with 'text'. """
442
442
443 #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg
443 #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg
444 magic_escape = self.magic_escape
444 magic_escape = self.magic_escape
445 magic_prefix = self.magic_prefix
445 magic_prefix = self.magic_prefix
446
446
447 try:
447 try:
448 if text.startswith(magic_escape):
448 if text.startswith(magic_escape):
449 text = text.replace(magic_escape,magic_prefix)
449 text = text.replace(magic_escape,magic_prefix)
450 elif text.startswith('~'):
450 elif text.startswith('~'):
451 text = os.path.expanduser(text)
451 text = os.path.expanduser(text)
452 if state == 0:
452 if state == 0:
453 # Extend the list of completions with the results of each
453 # Extend the list of completions with the results of each
454 # matcher, so we return results to the user from all
454 # matcher, so we return results to the user from all
455 # namespaces.
455 # namespaces.
456 if self.merge_completions:
456 if self.merge_completions:
457 self.matches = []
457 self.matches = []
458 for matcher in self.matchers:
458 for matcher in self.matchers:
459 self.matches.extend(matcher(text))
459 self.matches.extend(matcher(text))
460 else:
460 else:
461 for matcher in self.matchers:
461 for matcher in self.matchers:
462 self.matches = matcher(text)
462 self.matches = matcher(text)
463 if self.matches:
463 if self.matches:
464 break
464 break
465
465
466 try:
466 try:
467 return self.matches[state].replace(magic_prefix,magic_escape)
467 return self.matches[state].replace(magic_prefix,magic_escape)
468 except IndexError:
468 except IndexError:
469 return None
469 return None
470 except:
470 except:
471 # If completion fails, don't annoy the user.
471 # If completion fails, don't annoy the user.
472 pass
472 pass
473
473
474 except ImportError:
474 except ImportError:
475 pass # no readline support
475 pass # no readline support
476
476
477 except KeyError:
477 except KeyError:
478 pass # Windows doesn't set TERM, it doesn't matter
478 pass # Windows doesn't set TERM, it doesn't matter
479
479
480
480
481 class InputList(UserList.UserList):
481 class InputList(UserList.UserList):
482 """Class to store user input.
482 """Class to store user input.
483
483
484 It's basically a list, but slices return a string instead of a list, thus
484 It's basically a list, but slices return a string instead of a list, thus
485 allowing things like (assuming 'In' is an instance):
485 allowing things like (assuming 'In' is an instance):
486
486
487 exec In[4:7]
487 exec In[4:7]
488
488
489 or
489 or
490
490
491 exec In[5:9] + In[14] + In[21:25]"""
491 exec In[5:9] + In[14] + In[21:25]"""
492
492
493 def __getslice__(self,i,j):
493 def __getslice__(self,i,j):
494 return ''.join(UserList.UserList.__getslice__(self,i,j))
494 return ''.join(UserList.UserList.__getslice__(self,i,j))
495
495
496 #****************************************************************************
496 #****************************************************************************
497 # Local use exceptions
497 # Local use exceptions
498 class SpaceInInput(exceptions.Exception):
498 class SpaceInInput(exceptions.Exception):
499 pass
499 pass
500
500
501 #****************************************************************************
501 #****************************************************************************
502 # Main IPython class
502 # Main IPython class
503
503
504 class InteractiveShell(code.InteractiveConsole, Logger, Magic):
504 class InteractiveShell(code.InteractiveConsole, Logger, Magic):
505 """An enhanced console for Python."""
505 """An enhanced console for Python."""
506
506
507 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
507 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
508 user_ns = None,banner2='',
508 user_ns = None,banner2='',
509 custom_exceptions=((),None)):
509 custom_exceptions=((),None)):
510
510
511 # Put a reference to self in builtins so that any form of embedded or
511 # Put a reference to self in builtins so that any form of embedded or
512 # imported code can test for being inside IPython.
512 # imported code can test for being inside IPython.
513 __builtin__.__IPYTHON__ = self
513 __builtin__.__IPYTHON__ = self
514
514
515 # And load into builtins ipmagic/ipalias as well
515 # And load into builtins ipmagic/ipalias as well
516 __builtin__.ipmagic = ipmagic
516 __builtin__.ipmagic = ipmagic
517 __builtin__.ipalias = ipalias
517 __builtin__.ipalias = ipalias
518
518
519 # Add to __builtin__ other parts of IPython's public API
519 # Add to __builtin__ other parts of IPython's public API
520 __builtin__.ip_set_hook = self.set_hook
520 __builtin__.ip_set_hook = self.set_hook
521
521
522 # Keep in the builtins a flag for when IPython is active. We set it
522 # Keep in the builtins a flag for when IPython is active. We set it
523 # with setdefault so that multiple nested IPythons don't clobber one
523 # with setdefault so that multiple nested IPythons don't clobber one
524 # another. Each will increase its value by one upon being activated,
524 # another. Each will increase its value by one upon being activated,
525 # which also gives us a way to determine the nesting level.
525 # which also gives us a way to determine the nesting level.
526 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
526 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
527
527
528 # Inform the user of ipython's fast exit magics.
528 # Inform the user of ipython's fast exit magics.
529 _exit = ' Use %Exit or %Quit to exit without confirmation.'
529 _exit = ' Use %Exit or %Quit to exit without confirmation.'
530 __builtin__.exit += _exit
530 __builtin__.exit += _exit
531 __builtin__.quit += _exit
531 __builtin__.quit += _exit
532
532
533 # Create the namespace where the user will operate:
533 # Create the namespace where the user will operate:
534
534
535 # FIXME. For some strange reason, __builtins__ is showing up at user
535 # FIXME. For some strange reason, __builtins__ is showing up at user
536 # level as a dict instead of a module. This is a manual fix, but I
536 # level as a dict instead of a module. This is a manual fix, but I
537 # should really track down where the problem is coming from. Alex
537 # should really track down where the problem is coming from. Alex
538 # Schmolck reported this problem first.
538 # Schmolck reported this problem first.
539
539
540 # A useful post by Alex Martelli on this topic:
540 # A useful post by Alex Martelli on this topic:
541 # Re: inconsistent value from __builtins__
541 # Re: inconsistent value from __builtins__
542 # Von: Alex Martelli <aleaxit@yahoo.com>
542 # Von: Alex Martelli <aleaxit@yahoo.com>
543 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
543 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
544 # Gruppen: comp.lang.python
544 # Gruppen: comp.lang.python
545 # Referenzen: 1
545 # Referenzen: 1
546
546
547 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
547 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
548 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
548 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
549 # > <type 'dict'>
549 # > <type 'dict'>
550 # > >>> print type(__builtins__)
550 # > >>> print type(__builtins__)
551 # > <type 'module'>
551 # > <type 'module'>
552 # > Is this difference in return value intentional?
552 # > Is this difference in return value intentional?
553
553
554 # Well, it's documented that '__builtins__' can be either a dictionary
554 # Well, it's documented that '__builtins__' can be either a dictionary
555 # or a module, and it's been that way for a long time. Whether it's
555 # or a module, and it's been that way for a long time. Whether it's
556 # intentional (or sensible), I don't know. In any case, the idea is that
556 # intentional (or sensible), I don't know. In any case, the idea is that
557 # if you need to access the built-in namespace directly, you should start
557 # if you need to access the built-in namespace directly, you should start
558 # with "import __builtin__" (note, no 's') which will definitely give you
558 # with "import __builtin__" (note, no 's') which will definitely give you
559 # a module. Yeah, it's somewhatΒ confusing:-(.
559 # a module. Yeah, it's somewhatΒ confusing:-(.
560
560
561 if user_ns is None:
561 if user_ns is None:
562 # Set __name__ to __main__ to better match the behavior of the
562 # Set __name__ to __main__ to better match the behavior of the
563 # normal interpreter.
563 # normal interpreter.
564 self.user_ns = {'__name__' :'__main__',
564 self.user_ns = {'__name__' :'__main__',
565 '__builtins__' : __builtin__,
565 '__builtins__' : __builtin__,
566 }
566 }
567 else:
567 else:
568 self.user_ns = user_ns
568 self.user_ns = user_ns
569
569
570 # The user namespace MUST have a pointer to the shell itself.
570 # The user namespace MUST have a pointer to the shell itself.
571 self.user_ns[name] = self
571 self.user_ns[name] = self
572
572
573 # We need to insert into sys.modules something that looks like a
573 # We need to insert into sys.modules something that looks like a
574 # module but which accesses the IPython namespace, for shelve and
574 # module but which accesses the IPython namespace, for shelve and
575 # pickle to work interactively. Normally they rely on getting
575 # pickle to work interactively. Normally they rely on getting
576 # everything out of __main__, but for embedding purposes each IPython
576 # everything out of __main__, but for embedding purposes each IPython
577 # instance has its own private namespace, so we can't go shoving
577 # instance has its own private namespace, so we can't go shoving
578 # everything into __main__.
578 # everything into __main__.
579
579
580 try:
580 try:
581 main_name = self.user_ns['__name__']
581 main_name = self.user_ns['__name__']
582 except KeyError:
582 except KeyError:
583 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
583 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
584 else:
584 else:
585 #print "pickle hack in place" # dbg
585 #print "pickle hack in place" # dbg
586 sys.modules[main_name] = FakeModule(self.user_ns)
586 sys.modules[main_name] = FakeModule(self.user_ns)
587
587
588 # List of input with multi-line handling.
588 # List of input with multi-line handling.
589 # Fill its zero entry, user counter starts at 1
589 # Fill its zero entry, user counter starts at 1
590 self.input_hist = InputList(['\n'])
590 self.input_hist = InputList(['\n'])
591
591
592 # list of visited directories
592 # list of visited directories
593 self.dir_hist = [os.getcwd()]
593 try:
594 self.dir_hist = [os.getcwd()]
595 except IOError, e:
596 self.dir_hist = []
594
597
595 # dict of output history
598 # dict of output history
596 self.output_hist = {}
599 self.output_hist = {}
597
600
598 # dict of names to be treated as system aliases. Each entry in the
601 # dict of names to be treated as system aliases. Each entry in the
599 # alias table must be a 2-tuple of the form (N,name), where N is the
602 # alias table must be a 2-tuple of the form (N,name), where N is the
600 # number of positional arguments of the alias.
603 # number of positional arguments of the alias.
601 self.alias_table = {}
604 self.alias_table = {}
602
605
603 # dict of things NOT to alias (keywords and builtins)
606 # dict of things NOT to alias (keywords, builtins and some special magics)
604 self.no_alias = {}
607 no_alias = {}
605 for key in keyword.kwlist:
608 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
606 self.no_alias[key] = 1
609 for key in keyword.kwlist + no_alias_magics:
607 self.no_alias.update(__builtin__.__dict__)
610 no_alias[key] = 1
611 no_alias.update(__builtin__.__dict__)
612 self.no_alias = no_alias
613
608
614
609 # make global variables for user access to these
615 # make global variables for user access to these
610 self.user_ns['_ih'] = self.input_hist
616 self.user_ns['_ih'] = self.input_hist
611 self.user_ns['_oh'] = self.output_hist
617 self.user_ns['_oh'] = self.output_hist
612 self.user_ns['_dh'] = self.dir_hist
618 self.user_ns['_dh'] = self.dir_hist
613
619
614 # user aliases to input and output histories
620 # user aliases to input and output histories
615 self.user_ns['In'] = self.input_hist
621 self.user_ns['In'] = self.input_hist
616 self.user_ns['Out'] = self.output_hist
622 self.user_ns['Out'] = self.output_hist
617
623
618 # Store the actual shell's name
624 # Store the actual shell's name
619 self.name = name
625 self.name = name
620
626
621 # Object variable to store code object waiting execution. This is
627 # Object variable to store code object waiting execution. This is
622 # used mainly by the multithreaded shells, but it can come in handy in
628 # used mainly by the multithreaded shells, but it can come in handy in
623 # other situations. No need to use a Queue here, since it's a single
629 # other situations. No need to use a Queue here, since it's a single
624 # item which gets cleared once run.
630 # item which gets cleared once run.
625 self.code_to_run = None
631 self.code_to_run = None
626
632
627 # Job manager (for jobs run as background threads)
633 # Job manager (for jobs run as background threads)
628 self.jobs = BackgroundJobManager()
634 self.jobs = BackgroundJobManager()
629 # Put the job manager into builtins so it's always there.
635 # Put the job manager into builtins so it's always there.
630 __builtin__.jobs = self.jobs
636 __builtin__.jobs = self.jobs
631
637
632 # escapes for automatic behavior on the command line
638 # escapes for automatic behavior on the command line
633 self.ESC_SHELL = '!'
639 self.ESC_SHELL = '!'
634 self.ESC_HELP = '?'
640 self.ESC_HELP = '?'
635 self.ESC_MAGIC = '%'
641 self.ESC_MAGIC = '%'
636 self.ESC_QUOTE = ','
642 self.ESC_QUOTE = ','
637 self.ESC_QUOTE2 = ';'
643 self.ESC_QUOTE2 = ';'
638 self.ESC_PAREN = '/'
644 self.ESC_PAREN = '/'
639
645
640 # And their associated handlers
646 # And their associated handlers
641 self.esc_handlers = {self.ESC_PAREN:self.handle_auto,
647 self.esc_handlers = {self.ESC_PAREN:self.handle_auto,
642 self.ESC_QUOTE:self.handle_auto,
648 self.ESC_QUOTE:self.handle_auto,
643 self.ESC_QUOTE2:self.handle_auto,
649 self.ESC_QUOTE2:self.handle_auto,
644 self.ESC_MAGIC:self.handle_magic,
650 self.ESC_MAGIC:self.handle_magic,
645 self.ESC_HELP:self.handle_help,
651 self.ESC_HELP:self.handle_help,
646 self.ESC_SHELL:self.handle_shell_escape,
652 self.ESC_SHELL:self.handle_shell_escape,
647 }
653 }
648
654
649 # class initializations
655 # class initializations
650 code.InteractiveConsole.__init__(self,locals = self.user_ns)
656 code.InteractiveConsole.__init__(self,locals = self.user_ns)
651 Logger.__init__(self,log_ns = self.user_ns)
657 Logger.__init__(self,log_ns = self.user_ns)
652 Magic.__init__(self,self)
658 Magic.__init__(self,self)
653
659
654 # an ugly hack to get a pointer to the shell, so I can start writing
660 # an ugly hack to get a pointer to the shell, so I can start writing
655 # magic code via this pointer instead of the current mixin salad.
661 # magic code via this pointer instead of the current mixin salad.
656 Magic.set_shell(self,self)
662 Magic.set_shell(self,self)
657
663
658 # hooks holds pointers used for user-side customizations
664 # hooks holds pointers used for user-side customizations
659 self.hooks = Struct()
665 self.hooks = Struct()
660
666
661 # Set all default hooks, defined in the IPython.hooks module.
667 # Set all default hooks, defined in the IPython.hooks module.
662 hooks = IPython.hooks
668 hooks = IPython.hooks
663 for hook_name in hooks.__all__:
669 for hook_name in hooks.__all__:
664 self.set_hook(hook_name,getattr(hooks,hook_name))
670 self.set_hook(hook_name,getattr(hooks,hook_name))
665
671
666 # Flag to mark unconditional exit
672 # Flag to mark unconditional exit
667 self.exit_now = False
673 self.exit_now = False
668
674
669 self.usage_min = """\
675 self.usage_min = """\
670 An enhanced console for Python.
676 An enhanced console for Python.
671 Some of its features are:
677 Some of its features are:
672 - Readline support if the readline library is present.
678 - Readline support if the readline library is present.
673 - Tab completion in the local namespace.
679 - Tab completion in the local namespace.
674 - Logging of input, see command-line options.
680 - Logging of input, see command-line options.
675 - System shell escape via ! , eg !ls.
681 - System shell escape via ! , eg !ls.
676 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
682 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
677 - Keeps track of locally defined variables via %who, %whos.
683 - Keeps track of locally defined variables via %who, %whos.
678 - Show object information with a ? eg ?x or x? (use ?? for more info).
684 - Show object information with a ? eg ?x or x? (use ?? for more info).
679 """
685 """
680 if usage: self.usage = usage
686 if usage: self.usage = usage
681 else: self.usage = self.usage_min
687 else: self.usage = self.usage_min
682
688
683 # Storage
689 # Storage
684 self.rc = rc # This will hold all configuration information
690 self.rc = rc # This will hold all configuration information
685 self.inputcache = []
691 self.inputcache = []
686 self._boundcache = []
692 self._boundcache = []
687 self.pager = 'less'
693 self.pager = 'less'
688 # temporary files used for various purposes. Deleted at exit.
694 # temporary files used for various purposes. Deleted at exit.
689 self.tempfiles = []
695 self.tempfiles = []
690
696
691 # Keep track of readline usage (later set by init_readline)
697 # Keep track of readline usage (later set by init_readline)
692 self.has_readline = 0
698 self.has_readline = 0
693
699
694 # for pushd/popd management
700 # for pushd/popd management
695 try:
701 try:
696 self.home_dir = get_home_dir()
702 self.home_dir = get_home_dir()
697 except HomeDirError,msg:
703 except HomeDirError,msg:
698 fatal(msg)
704 fatal(msg)
699
705
700 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
706 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
701
707
702 # Functions to call the underlying shell.
708 # Functions to call the underlying shell.
703
709
704 # utility to expand user variables via Itpl
710 # utility to expand user variables via Itpl
705 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
711 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
706 self.user_ns))
712 self.user_ns))
707 # The first is similar to os.system, but it doesn't return a value,
713 # The first is similar to os.system, but it doesn't return a value,
708 # and it allows interpolation of variables in the user's namespace.
714 # and it allows interpolation of variables in the user's namespace.
709 self.system = lambda cmd: shell(self.var_expand(cmd),
715 self.system = lambda cmd: shell(self.var_expand(cmd),
710 header='IPython system call: ',
716 header='IPython system call: ',
711 verbose=self.rc.system_verbose)
717 verbose=self.rc.system_verbose)
712 # These are for getoutput and getoutputerror:
718 # These are for getoutput and getoutputerror:
713 self.getoutput = lambda cmd: \
719 self.getoutput = lambda cmd: \
714 getoutput(self.var_expand(cmd),
720 getoutput(self.var_expand(cmd),
715 header='IPython system call: ',
721 header='IPython system call: ',
716 verbose=self.rc.system_verbose)
722 verbose=self.rc.system_verbose)
717 self.getoutputerror = lambda cmd: \
723 self.getoutputerror = lambda cmd: \
718 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
724 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
719 self.user_ns)),
725 self.user_ns)),
720 header='IPython system call: ',
726 header='IPython system call: ',
721 verbose=self.rc.system_verbose)
727 verbose=self.rc.system_verbose)
722
728
723 # RegExp for splitting line contents into pre-char//first
729 # RegExp for splitting line contents into pre-char//first
724 # word-method//rest. For clarity, each group in on one line.
730 # word-method//rest. For clarity, each group in on one line.
725
731
726 # WARNING: update the regexp if the above escapes are changed, as they
732 # WARNING: update the regexp if the above escapes are changed, as they
727 # are hardwired in.
733 # are hardwired in.
728
734
729 # Don't get carried away with trying to make the autocalling catch too
735 # Don't get carried away with trying to make the autocalling catch too
730 # much: it's better to be conservative rather than to trigger hidden
736 # much: it's better to be conservative rather than to trigger hidden
731 # evals() somewhere and end up causing side effects.
737 # evals() somewhere and end up causing side effects.
732
738
733 self.line_split = re.compile(r'^([\s*,;/])'
739 self.line_split = re.compile(r'^([\s*,;/])'
734 r'([\?\w\.]+\w*\s*)'
740 r'([\?\w\.]+\w*\s*)'
735 r'(\(?.*$)')
741 r'(\(?.*$)')
736
742
737 # Original re, keep around for a while in case changes break something
743 # Original re, keep around for a while in case changes break something
738 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
744 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
739 # r'(\s*[\?\w\.]+\w*\s*)'
745 # r'(\s*[\?\w\.]+\w*\s*)'
740 # r'(\(?.*$)')
746 # r'(\(?.*$)')
741
747
742 # RegExp to identify potential function names
748 # RegExp to identify potential function names
743 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
749 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
744 # RegExp to exclude strings with this start from autocalling
750 # RegExp to exclude strings with this start from autocalling
745 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
751 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
746 # try to catch also methods for stuff in lists/tuples/dicts: off
752 # try to catch also methods for stuff in lists/tuples/dicts: off
747 # (experimental). For this to work, the line_split regexp would need
753 # (experimental). For this to work, the line_split regexp would need
748 # to be modified so it wouldn't break things at '['. That line is
754 # to be modified so it wouldn't break things at '['. That line is
749 # nasty enough that I shouldn't change it until I can test it _well_.
755 # nasty enough that I shouldn't change it until I can test it _well_.
750 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
756 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
751
757
752 # keep track of where we started running (mainly for crash post-mortem)
758 # keep track of where we started running (mainly for crash post-mortem)
753 self.starting_dir = os.getcwd()
759 self.starting_dir = os.getcwd()
754
760
755 # Attributes for Logger mixin class, make defaults here
761 # Attributes for Logger mixin class, make defaults here
756 self._dolog = 0
762 self._dolog = 0
757 self.LOG = ''
763 self.LOG = ''
758 self.LOGDEF = '.InteractiveShell.log'
764 self.LOGDEF = '.InteractiveShell.log'
759 self.LOGMODE = 'over'
765 self.LOGMODE = 'over'
760 self.LOGHEAD = Itpl(
766 self.LOGHEAD = Itpl(
761 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
767 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
762 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
768 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
763 #log# opts = $self.rc.opts
769 #log# opts = $self.rc.opts
764 #log# args = $self.rc.args
770 #log# args = $self.rc.args
765 #log# It is safe to make manual edits below here.
771 #log# It is safe to make manual edits below here.
766 #log#-----------------------------------------------------------------------
772 #log#-----------------------------------------------------------------------
767 """)
773 """)
768 # Various switches which can be set
774 # Various switches which can be set
769 self.CACHELENGTH = 5000 # this is cheap, it's just text
775 self.CACHELENGTH = 5000 # this is cheap, it's just text
770 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
776 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
771 self.banner2 = banner2
777 self.banner2 = banner2
772
778
773 # TraceBack handlers:
779 # TraceBack handlers:
774 # Need two, one for syntax errors and one for other exceptions.
780 # Need two, one for syntax errors and one for other exceptions.
775 self.SyntaxTB = ultraTB.ListTB(color_scheme='NoColor')
781 self.SyntaxTB = ultraTB.ListTB(color_scheme='NoColor')
776 # This one is initialized with an offset, meaning we always want to
782 # This one is initialized with an offset, meaning we always want to
777 # remove the topmost item in the traceback, which is our own internal
783 # remove the topmost item in the traceback, which is our own internal
778 # code. Valid modes: ['Plain','Context','Verbose']
784 # code. Valid modes: ['Plain','Context','Verbose']
779 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
785 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
780 color_scheme='NoColor',
786 color_scheme='NoColor',
781 tb_offset = 1)
787 tb_offset = 1)
782 # and add any custom exception handlers the user may have specified
788 # and add any custom exception handlers the user may have specified
783 self.set_custom_exc(*custom_exceptions)
789 self.set_custom_exc(*custom_exceptions)
784
790
785 # Object inspector
791 # Object inspector
786 ins_colors = OInspect.InspectColors
792 ins_colors = OInspect.InspectColors
787 code_colors = PyColorize.ANSICodeColors
793 code_colors = PyColorize.ANSICodeColors
788 self.inspector = OInspect.Inspector(ins_colors,code_colors,'NoColor')
794 self.inspector = OInspect.Inspector(ins_colors,code_colors,'NoColor')
789 self.autoindent = 0
795 self.autoindent = 0
790
796
791 # Make some aliases automatically
797 # Make some aliases automatically
792 # Prepare list of shell aliases to auto-define
798 # Prepare list of shell aliases to auto-define
793 if os.name == 'posix':
799 if os.name == 'posix':
794 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
800 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
795 'mv mv -i','rm rm -i','cp cp -i',
801 'mv mv -i','rm rm -i','cp cp -i',
796 'cat cat','less less','clear clear',
802 'cat cat','less less','clear clear',
797 # a better ls
803 # a better ls
798 'ls ls -F',
804 'ls ls -F',
799 # long ls
805 # long ls
800 'll ls -lF',
806 'll ls -lF',
801 # color ls
807 # color ls
802 'lc ls -F -o --color',
808 'lc ls -F -o --color',
803 # ls normal files only
809 # ls normal files only
804 'lf ls -F -o --color %l | grep ^-',
810 'lf ls -F -o --color %l | grep ^-',
805 # ls symbolic links
811 # ls symbolic links
806 'lk ls -F -o --color %l | grep ^l',
812 'lk ls -F -o --color %l | grep ^l',
807 # directories or links to directories,
813 # directories or links to directories,
808 'ldir ls -F -o --color %l | grep /$',
814 'ldir ls -F -o --color %l | grep /$',
809 # things which are executable
815 # things which are executable
810 'lx ls -F -o --color %l | grep ^-..x',
816 'lx ls -F -o --color %l | grep ^-..x',
811 )
817 )
812 elif os.name in ['nt','dos']:
818 elif os.name in ['nt','dos']:
813 auto_alias = ('dir dir /on', 'ls dir /on',
819 auto_alias = ('dir dir /on', 'ls dir /on',
814 'ddir dir /ad /on', 'ldir dir /ad /on',
820 'ddir dir /ad /on', 'ldir dir /ad /on',
815 'mkdir mkdir','rmdir rmdir','echo echo',
821 'mkdir mkdir','rmdir rmdir','echo echo',
816 'ren ren','cls cls','copy copy')
822 'ren ren','cls cls','copy copy')
817 else:
823 else:
818 auto_alias = ()
824 auto_alias = ()
819 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
825 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
820 # Call the actual (public) initializer
826 # Call the actual (public) initializer
821 self.init_auto_alias()
827 self.init_auto_alias()
822 # end __init__
828 # end __init__
823
829
824 def set_hook(self,name,hook):
830 def set_hook(self,name,hook):
825 """set_hook(name,hook) -> sets an internal IPython hook.
831 """set_hook(name,hook) -> sets an internal IPython hook.
826
832
827 IPython exposes some of its internal API as user-modifiable hooks. By
833 IPython exposes some of its internal API as user-modifiable hooks. By
828 resetting one of these hooks, you can modify IPython's behavior to
834 resetting one of these hooks, you can modify IPython's behavior to
829 call at runtime your own routines."""
835 call at runtime your own routines."""
830
836
831 # At some point in the future, this should validate the hook before it
837 # At some point in the future, this should validate the hook before it
832 # accepts it. Probably at least check that the hook takes the number
838 # accepts it. Probably at least check that the hook takes the number
833 # of args it's supposed to.
839 # of args it's supposed to.
834 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
840 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
835
841
836 def set_custom_exc(self,exc_tuple,handler):
842 def set_custom_exc(self,exc_tuple,handler):
837 """set_custom_exc(exc_tuple,handler)
843 """set_custom_exc(exc_tuple,handler)
838
844
839 Set a custom exception handler, which will be called if any of the
845 Set a custom exception handler, which will be called if any of the
840 exceptions in exc_tuple occur in the mainloop (specifically, in the
846 exceptions in exc_tuple occur in the mainloop (specifically, in the
841 runcode() method.
847 runcode() method.
842
848
843 Inputs:
849 Inputs:
844
850
845 - exc_tuple: a *tuple* of valid exceptions to call the defined
851 - exc_tuple: a *tuple* of valid exceptions to call the defined
846 handler for. It is very important that you use a tuple, and NOT A
852 handler for. It is very important that you use a tuple, and NOT A
847 LIST here, because of the way Python's except statement works. If
853 LIST here, because of the way Python's except statement works. If
848 you only want to trap a single exception, use a singleton tuple:
854 you only want to trap a single exception, use a singleton tuple:
849
855
850 exc_tuple == (MyCustomException,)
856 exc_tuple == (MyCustomException,)
851
857
852 - handler: this must be defined as a function with the following
858 - handler: this must be defined as a function with the following
853 basic interface: def my_handler(self,etype,value,tb).
859 basic interface: def my_handler(self,etype,value,tb).
854
860
855 This will be made into an instance method (via new.instancemethod)
861 This will be made into an instance method (via new.instancemethod)
856 of IPython itself, and it will be called if any of the exceptions
862 of IPython itself, and it will be called if any of the exceptions
857 listed in the exc_tuple are caught. If the handler is None, an
863 listed in the exc_tuple are caught. If the handler is None, an
858 internal basic one is used, which just prints basic info.
864 internal basic one is used, which just prints basic info.
859
865
860 WARNING: by putting in your own exception handler into IPython's main
866 WARNING: by putting in your own exception handler into IPython's main
861 execution loop, you run a very good chance of nasty crashes. This
867 execution loop, you run a very good chance of nasty crashes. This
862 facility should only be used if you really know what you are doing."""
868 facility should only be used if you really know what you are doing."""
863
869
864 assert type(exc_tuple)==type(()) , \
870 assert type(exc_tuple)==type(()) , \
865 "The custom exceptions must be given AS A TUPLE."
871 "The custom exceptions must be given AS A TUPLE."
866
872
867 def dummy_handler(self,etype,value,tb):
873 def dummy_handler(self,etype,value,tb):
868 print '*** Simple custom exception handler ***'
874 print '*** Simple custom exception handler ***'
869 print 'Exception type :',etype
875 print 'Exception type :',etype
870 print 'Exception value:',value
876 print 'Exception value:',value
871 print 'Traceback :',tb
877 print 'Traceback :',tb
872 print 'Source code :','\n'.join(self.buffer)
878 print 'Source code :','\n'.join(self.buffer)
873
879
874 if handler is None: handler = dummy_handler
880 if handler is None: handler = dummy_handler
875
881
876 self.CustomTB = new.instancemethod(handler,self,self.__class__)
882 self.CustomTB = new.instancemethod(handler,self,self.__class__)
877 self.custom_exceptions = exc_tuple
883 self.custom_exceptions = exc_tuple
878
884
879 def set_custom_completer(self,completer,pos=0):
885 def set_custom_completer(self,completer,pos=0):
880 """set_custom_completer(completer,pos=0)
886 """set_custom_completer(completer,pos=0)
881
887
882 Adds a new custom completer function.
888 Adds a new custom completer function.
883
889
884 The position argument (defaults to 0) is the index in the completers
890 The position argument (defaults to 0) is the index in the completers
885 list where you want the completer to be inserted."""
891 list where you want the completer to be inserted."""
886
892
887 newcomp = new.instancemethod(completer,self.Completer,
893 newcomp = new.instancemethod(completer,self.Completer,
888 self.Completer.__class__)
894 self.Completer.__class__)
889 self.Completer.matchers.insert(pos,newcomp)
895 self.Completer.matchers.insert(pos,newcomp)
890
896
891 def complete(self,text):
897 def complete(self,text):
892 """Return a sorted list of all possible completions on text.
898 """Return a sorted list of all possible completions on text.
893
899
894 Inputs:
900 Inputs:
895
901
896 - text: a string of text to be completed on.
902 - text: a string of text to be completed on.
897
903
898 This is a wrapper around the completion mechanism, similar to what
904 This is a wrapper around the completion mechanism, similar to what
899 readline does at the command line when the TAB key is hit. By
905 readline does at the command line when the TAB key is hit. By
900 exposing it as a method, it can be used by other non-readline
906 exposing it as a method, it can be used by other non-readline
901 environments (such as GUIs) for text completion.
907 environments (such as GUIs) for text completion.
902
908
903 Simple usage example:
909 Simple usage example:
904
910
905 In [1]: x = 'hello'
911 In [1]: x = 'hello'
906
912
907 In [2]: __IP.complete('x.l')
913 In [2]: __IP.complete('x.l')
908 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
914 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
909
915
910 complete = self.Completer.complete
916 complete = self.Completer.complete
911 state = 0
917 state = 0
912 # use a dict so we get unique keys, since ipyhton's multiple
918 # use a dict so we get unique keys, since ipyhton's multiple
913 # completers can return duplicates.
919 # completers can return duplicates.
914 comps = {}
920 comps = {}
915 while True:
921 while True:
916 newcomp = complete(text,state)
922 newcomp = complete(text,state)
917 if newcomp is None:
923 if newcomp is None:
918 break
924 break
919 comps[newcomp] = 1
925 comps[newcomp] = 1
920 state += 1
926 state += 1
921 outcomps = comps.keys()
927 outcomps = comps.keys()
922 outcomps.sort()
928 outcomps.sort()
923 return outcomps
929 return outcomps
924
930
925 def post_config_initialization(self):
931 def post_config_initialization(self):
926 """Post configuration init method
932 """Post configuration init method
927
933
928 This is called after the configuration files have been processed to
934 This is called after the configuration files have been processed to
929 'finalize' the initialization."""
935 'finalize' the initialization."""
930
936
931 # dynamic data that survives through sessions
937 # dynamic data that survives through sessions
932 # XXX make the filename a config option?
938 # XXX make the filename a config option?
933 persist_base = 'persist'
939 persist_base = 'persist'
934 if self.rc.profile:
940 if self.rc.profile:
935 persist_base += '_%s' % self.rc.profile
941 persist_base += '_%s' % self.rc.profile
936 self.persist_fname = os.path.join(self.rc.ipythondir,persist_base)
942 self.persist_fname = os.path.join(self.rc.ipythondir,persist_base)
937
943
938 try:
944 try:
939 self.persist = pickle.load(file(self.persist_fname))
945 self.persist = pickle.load(file(self.persist_fname))
940 except:
946 except:
941 self.persist = {}
947 self.persist = {}
942
948
943 def init_auto_alias(self):
949 def init_auto_alias(self):
944 """Define some aliases automatically.
950 """Define some aliases automatically.
945
951
946 These are ALL parameter-less aliases"""
952 These are ALL parameter-less aliases"""
947 for alias,cmd in self.auto_alias:
953 for alias,cmd in self.auto_alias:
948 self.alias_table[alias] = (0,cmd)
954 self.alias_table[alias] = (0,cmd)
949
955
950 def alias_table_validate(self,verbose=0):
956 def alias_table_validate(self,verbose=0):
951 """Update information about the alias table.
957 """Update information about the alias table.
952
958
953 In particular, make sure no Python keywords/builtins are in it."""
959 In particular, make sure no Python keywords/builtins are in it."""
954
960
955 no_alias = self.no_alias
961 no_alias = self.no_alias
956 for k in self.alias_table.keys():
962 for k in self.alias_table:
957 if k in no_alias:
963 if k in no_alias:
958 del self.alias_table[k]
964 del self.alias_table[k]
959 if verbose:
965 if verbose:
960 print ("Deleting alias <%s>, it's a Python "
966 print ("Deleting alias <%s>, it's a Python "
961 "keyword or builtin." % k)
967 "keyword or builtin." % k)
962
968
963 def set_autoindent(self,value=None):
969 def set_autoindent(self,value=None):
964 """Set the autoindent flag, checking for readline support.
970 """Set the autoindent flag, checking for readline support.
965
971
966 If called with no arguments, it acts as a toggle."""
972 If called with no arguments, it acts as a toggle."""
967
973
968 if not self.has_readline:
974 if not self.has_readline:
969 if os.name == 'posix':
975 if os.name == 'posix':
970 warn("The auto-indent feature requires the readline library")
976 warn("The auto-indent feature requires the readline library")
971 self.autoindent = 0
977 self.autoindent = 0
972 return
978 return
973 if value is None:
979 if value is None:
974 self.autoindent = not self.autoindent
980 self.autoindent = not self.autoindent
975 else:
981 else:
976 self.autoindent = value
982 self.autoindent = value
977
983
978 def rc_set_toggle(self,rc_field,value=None):
984 def rc_set_toggle(self,rc_field,value=None):
979 """Set or toggle a field in IPython's rc config. structure.
985 """Set or toggle a field in IPython's rc config. structure.
980
986
981 If called with no arguments, it acts as a toggle.
987 If called with no arguments, it acts as a toggle.
982
988
983 If called with a non-existent field, the resulting AttributeError
989 If called with a non-existent field, the resulting AttributeError
984 exception will propagate out."""
990 exception will propagate out."""
985
991
986 rc_val = getattr(self.rc,rc_field)
992 rc_val = getattr(self.rc,rc_field)
987 if value is None:
993 if value is None:
988 value = not rc_val
994 value = not rc_val
989 setattr(self.rc,rc_field,value)
995 setattr(self.rc,rc_field,value)
990
996
991 def user_setup(self,ipythondir,rc_suffix,mode='install'):
997 def user_setup(self,ipythondir,rc_suffix,mode='install'):
992 """Install the user configuration directory.
998 """Install the user configuration directory.
993
999
994 Can be called when running for the first time or to upgrade the user's
1000 Can be called when running for the first time or to upgrade the user's
995 .ipython/ directory with the mode parameter. Valid modes are 'install'
1001 .ipython/ directory with the mode parameter. Valid modes are 'install'
996 and 'upgrade'."""
1002 and 'upgrade'."""
997
1003
998 def wait():
1004 def wait():
999 try:
1005 try:
1000 raw_input("Please press <RETURN> to start IPython.")
1006 raw_input("Please press <RETURN> to start IPython.")
1001 except EOFError:
1007 except EOFError:
1002 print >> Term.cout
1008 print >> Term.cout
1003 print '*'*70
1009 print '*'*70
1004
1010
1005 cwd = os.getcwd() # remember where we started
1011 cwd = os.getcwd() # remember where we started
1006 glb = glob.glob
1012 glb = glob.glob
1007 print '*'*70
1013 print '*'*70
1008 if mode == 'install':
1014 if mode == 'install':
1009 print \
1015 print \
1010 """Welcome to IPython. I will try to create a personal configuration directory
1016 """Welcome to IPython. I will try to create a personal configuration directory
1011 where you can customize many aspects of IPython's functionality in:\n"""
1017 where you can customize many aspects of IPython's functionality in:\n"""
1012 else:
1018 else:
1013 print 'I am going to upgrade your configuration in:'
1019 print 'I am going to upgrade your configuration in:'
1014
1020
1015 print ipythondir
1021 print ipythondir
1016
1022
1017 rcdirend = os.path.join('IPython','UserConfig')
1023 rcdirend = os.path.join('IPython','UserConfig')
1018 cfg = lambda d: os.path.join(d,rcdirend)
1024 cfg = lambda d: os.path.join(d,rcdirend)
1019 try:
1025 try:
1020 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1026 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1021 except IOError:
1027 except IOError:
1022 warning = """
1028 warning = """
1023 Installation error. IPython's directory was not found.
1029 Installation error. IPython's directory was not found.
1024
1030
1025 Check the following:
1031 Check the following:
1026
1032
1027 The ipython/IPython directory should be in a directory belonging to your
1033 The ipython/IPython directory should be in a directory belonging to your
1028 PYTHONPATH environment variable (that is, it should be in a directory
1034 PYTHONPATH environment variable (that is, it should be in a directory
1029 belonging to sys.path). You can copy it explicitly there or just link to it.
1035 belonging to sys.path). You can copy it explicitly there or just link to it.
1030
1036
1031 IPython will proceed with builtin defaults.
1037 IPython will proceed with builtin defaults.
1032 """
1038 """
1033 warn(warning)
1039 warn(warning)
1034 wait()
1040 wait()
1035 return
1041 return
1036
1042
1037 if mode == 'install':
1043 if mode == 'install':
1038 try:
1044 try:
1039 shutil.copytree(rcdir,ipythondir)
1045 shutil.copytree(rcdir,ipythondir)
1040 os.chdir(ipythondir)
1046 os.chdir(ipythondir)
1041 rc_files = glb("ipythonrc*")
1047 rc_files = glb("ipythonrc*")
1042 for rc_file in rc_files:
1048 for rc_file in rc_files:
1043 os.rename(rc_file,rc_file+rc_suffix)
1049 os.rename(rc_file,rc_file+rc_suffix)
1044 except:
1050 except:
1045 warning = """
1051 warning = """
1046
1052
1047 There was a problem with the installation:
1053 There was a problem with the installation:
1048 %s
1054 %s
1049 Try to correct it or contact the developers if you think it's a bug.
1055 Try to correct it or contact the developers if you think it's a bug.
1050 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1056 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1051 warn(warning)
1057 warn(warning)
1052 wait()
1058 wait()
1053 return
1059 return
1054
1060
1055 elif mode == 'upgrade':
1061 elif mode == 'upgrade':
1056 try:
1062 try:
1057 os.chdir(ipythondir)
1063 os.chdir(ipythondir)
1058 except:
1064 except:
1059 print """
1065 print """
1060 Can not upgrade: changing to directory %s failed. Details:
1066 Can not upgrade: changing to directory %s failed. Details:
1061 %s
1067 %s
1062 """ % (ipythondir,sys.exc_info()[1])
1068 """ % (ipythondir,sys.exc_info()[1])
1063 wait()
1069 wait()
1064 return
1070 return
1065 else:
1071 else:
1066 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1072 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1067 for new_full_path in sources:
1073 for new_full_path in sources:
1068 new_filename = os.path.basename(new_full_path)
1074 new_filename = os.path.basename(new_full_path)
1069 if new_filename.startswith('ipythonrc'):
1075 if new_filename.startswith('ipythonrc'):
1070 new_filename = new_filename + rc_suffix
1076 new_filename = new_filename + rc_suffix
1071 # The config directory should only contain files, skip any
1077 # The config directory should only contain files, skip any
1072 # directories which may be there (like CVS)
1078 # directories which may be there (like CVS)
1073 if os.path.isdir(new_full_path):
1079 if os.path.isdir(new_full_path):
1074 continue
1080 continue
1075 if os.path.exists(new_filename):
1081 if os.path.exists(new_filename):
1076 old_file = new_filename+'.old'
1082 old_file = new_filename+'.old'
1077 if os.path.exists(old_file):
1083 if os.path.exists(old_file):
1078 os.remove(old_file)
1084 os.remove(old_file)
1079 os.rename(new_filename,old_file)
1085 os.rename(new_filename,old_file)
1080 shutil.copy(new_full_path,new_filename)
1086 shutil.copy(new_full_path,new_filename)
1081 else:
1087 else:
1082 raise ValueError,'unrecognized mode for install:',`mode`
1088 raise ValueError,'unrecognized mode for install:',`mode`
1083
1089
1084 # Fix line-endings to those native to each platform in the config
1090 # Fix line-endings to those native to each platform in the config
1085 # directory.
1091 # directory.
1086 try:
1092 try:
1087 os.chdir(ipythondir)
1093 os.chdir(ipythondir)
1088 except:
1094 except:
1089 print """
1095 print """
1090 Problem: changing to directory %s failed.
1096 Problem: changing to directory %s failed.
1091 Details:
1097 Details:
1092 %s
1098 %s
1093
1099
1094 Some configuration files may have incorrect line endings. This should not
1100 Some configuration files may have incorrect line endings. This should not
1095 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1101 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1096 wait()
1102 wait()
1097 else:
1103 else:
1098 for fname in glb('ipythonrc*'):
1104 for fname in glb('ipythonrc*'):
1099 try:
1105 try:
1100 native_line_ends(fname,backup=0)
1106 native_line_ends(fname,backup=0)
1101 except IOError:
1107 except IOError:
1102 pass
1108 pass
1103
1109
1104 if mode == 'install':
1110 if mode == 'install':
1105 print """
1111 print """
1106 Successful installation!
1112 Successful installation!
1107
1113
1108 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1114 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1109 IPython manual (there are both HTML and PDF versions supplied with the
1115 IPython manual (there are both HTML and PDF versions supplied with the
1110 distribution) to make sure that your system environment is properly configured
1116 distribution) to make sure that your system environment is properly configured
1111 to take advantage of IPython's features."""
1117 to take advantage of IPython's features."""
1112 else:
1118 else:
1113 print """
1119 print """
1114 Successful upgrade!
1120 Successful upgrade!
1115
1121
1116 All files in your directory:
1122 All files in your directory:
1117 %(ipythondir)s
1123 %(ipythondir)s
1118 which would have been overwritten by the upgrade were backed up with a .old
1124 which would have been overwritten by the upgrade were backed up with a .old
1119 extension. If you had made particular customizations in those files you may
1125 extension. If you had made particular customizations in those files you may
1120 want to merge them back into the new files.""" % locals()
1126 want to merge them back into the new files.""" % locals()
1121 wait()
1127 wait()
1122 os.chdir(cwd)
1128 os.chdir(cwd)
1123 # end user_setup()
1129 # end user_setup()
1124
1130
1125 def atexit_operations(self):
1131 def atexit_operations(self):
1126 """This will be executed at the time of exit.
1132 """This will be executed at the time of exit.
1127
1133
1128 Saving of persistent data should be performed here. """
1134 Saving of persistent data should be performed here. """
1129
1135
1130 # input history
1136 # input history
1131 self.savehist()
1137 self.savehist()
1132
1138
1133 # Cleanup all tempfiles left around
1139 # Cleanup all tempfiles left around
1134 for tfile in self.tempfiles:
1140 for tfile in self.tempfiles:
1135 try:
1141 try:
1136 os.unlink(tfile)
1142 os.unlink(tfile)
1137 except OSError:
1143 except OSError:
1138 pass
1144 pass
1139
1145
1140 # save the "persistent data" catch-all dictionary
1146 # save the "persistent data" catch-all dictionary
1141 try:
1147 try:
1142 pickle.dump(self.persist, open(self.persist_fname,"w"))
1148 pickle.dump(self.persist, open(self.persist_fname,"w"))
1143 except:
1149 except:
1144 print "*** ERROR *** persistent data saving failed."
1150 print "*** ERROR *** persistent data saving failed."
1145
1151
1146 def savehist(self):
1152 def savehist(self):
1147 """Save input history to a file (via readline library)."""
1153 """Save input history to a file (via readline library)."""
1148 try:
1154 try:
1149 self.readline.write_history_file(self.histfile)
1155 self.readline.write_history_file(self.histfile)
1150 except:
1156 except:
1151 print 'Unable to save IPython command history to file: ' + \
1157 print 'Unable to save IPython command history to file: ' + \
1152 `self.histfile`
1158 `self.histfile`
1153
1159
1154 def pre_readline(self):
1160 def pre_readline(self):
1155 """readline hook to be used at the start of each line.
1161 """readline hook to be used at the start of each line.
1156
1162
1157 Currently it handles auto-indent only."""
1163 Currently it handles auto-indent only."""
1158
1164
1159 self.readline.insert_text(' '* self.readline_indent)
1165 self.readline.insert_text(' '* self.readline_indent)
1160
1166
1161 def init_readline(self):
1167 def init_readline(self):
1162 """Command history completion/saving/reloading."""
1168 """Command history completion/saving/reloading."""
1163 try:
1169 try:
1164 import readline
1170 import readline
1165 self.Completer = MagicCompleter(self,
1171 self.Completer = MagicCompleter(self,
1166 self.user_ns,
1172 self.user_ns,
1167 self.rc.readline_omit__names,
1173 self.rc.readline_omit__names,
1168 self.alias_table)
1174 self.alias_table)
1169 except ImportError,NameError:
1175 except ImportError,NameError:
1170 # If FlexCompleter failed to import, MagicCompleter won't be
1176 # If FlexCompleter failed to import, MagicCompleter won't be
1171 # defined. This can happen because of a problem with readline
1177 # defined. This can happen because of a problem with readline
1172 self.has_readline = 0
1178 self.has_readline = 0
1173 # no point in bugging windows users with this every time:
1179 # no point in bugging windows users with this every time:
1174 if os.name == 'posix':
1180 if os.name == 'posix':
1175 warn('Readline services not available on this platform.')
1181 warn('Readline services not available on this platform.')
1176 else:
1182 else:
1177 import atexit
1183 import atexit
1178
1184
1179 # Platform-specific configuration
1185 # Platform-specific configuration
1180 if os.name == 'nt':
1186 if os.name == 'nt':
1181 # readline under Windows modifies the default exit behavior
1187 # readline under Windows modifies the default exit behavior
1182 # from being Ctrl-Z/Return to the Unix Ctrl-D one.
1188 # from being Ctrl-Z/Return to the Unix Ctrl-D one.
1183 __builtin__.exit = __builtin__.quit = \
1189 __builtin__.exit = __builtin__.quit = \
1184 ('Use Ctrl-D (i.e. EOF) to exit. '
1190 ('Use Ctrl-D (i.e. EOF) to exit. '
1185 'Use %Exit or %Quit to exit without confirmation.')
1191 'Use %Exit or %Quit to exit without confirmation.')
1186 self.readline_startup_hook = readline.set_pre_input_hook
1192 self.readline_startup_hook = readline.set_pre_input_hook
1187 else:
1193 else:
1188 self.readline_startup_hook = readline.set_startup_hook
1194 self.readline_startup_hook = readline.set_startup_hook
1189
1195
1190 # Load user's initrc file (readline config)
1196 # Load user's initrc file (readline config)
1191 inputrc_name = os.environ.get('INPUTRC')
1197 inputrc_name = os.environ.get('INPUTRC')
1192 if inputrc_name is None:
1198 if inputrc_name is None:
1193 home_dir = get_home_dir()
1199 home_dir = get_home_dir()
1194 if home_dir is not None:
1200 if home_dir is not None:
1195 inputrc_name = os.path.join(home_dir,'.inputrc')
1201 inputrc_name = os.path.join(home_dir,'.inputrc')
1196 if os.path.isfile(inputrc_name):
1202 if os.path.isfile(inputrc_name):
1197 try:
1203 try:
1198 readline.read_init_file(inputrc_name)
1204 readline.read_init_file(inputrc_name)
1199 except:
1205 except:
1200 warn('Problems reading readline initialization file <%s>'
1206 warn('Problems reading readline initialization file <%s>'
1201 % inputrc_name)
1207 % inputrc_name)
1202
1208
1203 self.has_readline = 1
1209 self.has_readline = 1
1204 self.readline = readline
1210 self.readline = readline
1205 self.readline_indent = 0 # for auto-indenting via readline
1211 self.readline_indent = 0 # for auto-indenting via readline
1206 # save this in sys so embedded copies can restore it properly
1212 # save this in sys so embedded copies can restore it properly
1207 sys.ipcompleter = self.Completer.complete
1213 sys.ipcompleter = self.Completer.complete
1208 readline.set_completer(self.Completer.complete)
1214 readline.set_completer(self.Completer.complete)
1209
1215
1210 # Configure readline according to user's prefs
1216 # Configure readline according to user's prefs
1211 for rlcommand in self.rc.readline_parse_and_bind:
1217 for rlcommand in self.rc.readline_parse_and_bind:
1212 readline.parse_and_bind(rlcommand)
1218 readline.parse_and_bind(rlcommand)
1213
1219
1214 # remove some chars from the delimiters list
1220 # remove some chars from the delimiters list
1215 delims = readline.get_completer_delims()
1221 delims = readline.get_completer_delims()
1216 delims = delims.translate(string._idmap,
1222 delims = delims.translate(string._idmap,
1217 self.rc.readline_remove_delims)
1223 self.rc.readline_remove_delims)
1218 readline.set_completer_delims(delims)
1224 readline.set_completer_delims(delims)
1219 # otherwise we end up with a monster history after a while:
1225 # otherwise we end up with a monster history after a while:
1220 readline.set_history_length(1000)
1226 readline.set_history_length(1000)
1221 try:
1227 try:
1222 #print '*** Reading readline history' # dbg
1228 #print '*** Reading readline history' # dbg
1223 readline.read_history_file(self.histfile)
1229 readline.read_history_file(self.histfile)
1224 except IOError:
1230 except IOError:
1225 pass # It doesn't exist yet.
1231 pass # It doesn't exist yet.
1226
1232
1227 atexit.register(self.atexit_operations)
1233 atexit.register(self.atexit_operations)
1228 del atexit
1234 del atexit
1229
1235
1230 # Configure auto-indent for all platforms
1236 # Configure auto-indent for all platforms
1231 self.set_autoindent(self.rc.autoindent)
1237 self.set_autoindent(self.rc.autoindent)
1232
1238
1233 def showsyntaxerror(self, filename=None):
1239 def showsyntaxerror(self, filename=None):
1234 """Display the syntax error that just occurred.
1240 """Display the syntax error that just occurred.
1235
1241
1236 This doesn't display a stack trace because there isn't one.
1242 This doesn't display a stack trace because there isn't one.
1237
1243
1238 If a filename is given, it is stuffed in the exception instead
1244 If a filename is given, it is stuffed in the exception instead
1239 of what was there before (because Python's parser always uses
1245 of what was there before (because Python's parser always uses
1240 "<string>" when reading from a string).
1246 "<string>" when reading from a string).
1241 """
1247 """
1242 type, value, sys.last_traceback = sys.exc_info()
1248 type, value, sys.last_traceback = sys.exc_info()
1243 sys.last_type = type
1249 sys.last_type = type
1244 sys.last_value = value
1250 sys.last_value = value
1245 if filename and type is SyntaxError:
1251 if filename and type is SyntaxError:
1246 # Work hard to stuff the correct filename in the exception
1252 # Work hard to stuff the correct filename in the exception
1247 try:
1253 try:
1248 msg, (dummy_filename, lineno, offset, line) = value
1254 msg, (dummy_filename, lineno, offset, line) = value
1249 except:
1255 except:
1250 # Not the format we expect; leave it alone
1256 # Not the format we expect; leave it alone
1251 pass
1257 pass
1252 else:
1258 else:
1253 # Stuff in the right filename
1259 # Stuff in the right filename
1254 try:
1260 try:
1255 # Assume SyntaxError is a class exception
1261 # Assume SyntaxError is a class exception
1256 value = SyntaxError(msg, (filename, lineno, offset, line))
1262 value = SyntaxError(msg, (filename, lineno, offset, line))
1257 except:
1263 except:
1258 # If that failed, assume SyntaxError is a string
1264 # If that failed, assume SyntaxError is a string
1259 value = msg, (filename, lineno, offset, line)
1265 value = msg, (filename, lineno, offset, line)
1260 self.SyntaxTB(type,value,[])
1266 self.SyntaxTB(type,value,[])
1261
1267
1262 def debugger(self):
1268 def debugger(self):
1263 """Call the pdb debugger."""
1269 """Call the pdb debugger."""
1264
1270
1265 if not self.rc.pdb:
1271 if not self.rc.pdb:
1266 return
1272 return
1267 pdb.pm()
1273 pdb.pm()
1268
1274
1269 def showtraceback(self,exc_tuple = None):
1275 def showtraceback(self,exc_tuple = None):
1270 """Display the exception that just occurred."""
1276 """Display the exception that just occurred."""
1271
1277
1272 # Though this won't be called by syntax errors in the input line,
1278 # Though this won't be called by syntax errors in the input line,
1273 # there may be SyntaxError cases whith imported code.
1279 # there may be SyntaxError cases whith imported code.
1274 if exc_tuple is None:
1280 if exc_tuple is None:
1275 type, value, tb = sys.exc_info()
1281 type, value, tb = sys.exc_info()
1276 else:
1282 else:
1277 type, value, tb = exc_tuple
1283 type, value, tb = exc_tuple
1278 if type is SyntaxError:
1284 if type is SyntaxError:
1279 self.showsyntaxerror()
1285 self.showsyntaxerror()
1280 else:
1286 else:
1281 sys.last_type = type
1287 sys.last_type = type
1282 sys.last_value = value
1288 sys.last_value = value
1283 sys.last_traceback = tb
1289 sys.last_traceback = tb
1284 self.InteractiveTB()
1290 self.InteractiveTB()
1285 if self.InteractiveTB.call_pdb and self.has_readline:
1291 if self.InteractiveTB.call_pdb and self.has_readline:
1286 # pdb mucks up readline, fix it back
1292 # pdb mucks up readline, fix it back
1287 self.readline.set_completer(self.Completer.complete)
1293 self.readline.set_completer(self.Completer.complete)
1288
1294
1289 def update_cache(self, line):
1295 def update_cache(self, line):
1290 """puts line into cache"""
1296 """puts line into cache"""
1291 self.inputcache.insert(0, line) # This copies the cache every time ... :-(
1297 self.inputcache.insert(0, line) # This copies the cache every time ... :-(
1292 if len(self.inputcache) >= self.CACHELENGTH:
1298 if len(self.inputcache) >= self.CACHELENGTH:
1293 self.inputcache.pop() # This not :-)
1299 self.inputcache.pop() # This not :-)
1294
1300
1295 def name_space_init(self):
1301 def name_space_init(self):
1296 """Create local namespace."""
1302 """Create local namespace."""
1297 # We want this to be a method to facilitate embedded initialization.
1303 # We want this to be a method to facilitate embedded initialization.
1298 code.InteractiveConsole.__init__(self,self.user_ns)
1304 code.InteractiveConsole.__init__(self,self.user_ns)
1299
1305
1300 def mainloop(self,banner=None):
1306 def mainloop(self,banner=None):
1301 """Creates the local namespace and starts the mainloop.
1307 """Creates the local namespace and starts the mainloop.
1302
1308
1303 If an optional banner argument is given, it will override the
1309 If an optional banner argument is given, it will override the
1304 internally created default banner."""
1310 internally created default banner."""
1305
1311
1306 self.name_space_init()
1312 self.name_space_init()
1307 if self.rc.c: # Emulate Python's -c option
1313 if self.rc.c: # Emulate Python's -c option
1308 self.exec_init_cmd()
1314 self.exec_init_cmd()
1309 if banner is None:
1315 if banner is None:
1310 if self.rc.banner:
1316 if self.rc.banner:
1311 banner = self.BANNER+self.banner2
1317 banner = self.BANNER+self.banner2
1312 else:
1318 else:
1313 banner = ''
1319 banner = ''
1314 self.interact(banner)
1320 self.interact(banner)
1315
1321
1316 def exec_init_cmd(self):
1322 def exec_init_cmd(self):
1317 """Execute a command given at the command line.
1323 """Execute a command given at the command line.
1318
1324
1319 This emulates Python's -c option."""
1325 This emulates Python's -c option."""
1320
1326
1321 sys.argv = ['-c']
1327 sys.argv = ['-c']
1322 self.push(self.rc.c)
1328 self.push(self.rc.c)
1323
1329
1324 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1330 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1325 """Embeds IPython into a running python program.
1331 """Embeds IPython into a running python program.
1326
1332
1327 Input:
1333 Input:
1328
1334
1329 - header: An optional header message can be specified.
1335 - header: An optional header message can be specified.
1330
1336
1331 - local_ns, global_ns: working namespaces. If given as None, the
1337 - local_ns, global_ns: working namespaces. If given as None, the
1332 IPython-initialized one is updated with __main__.__dict__, so that
1338 IPython-initialized one is updated with __main__.__dict__, so that
1333 program variables become visible but user-specific configuration
1339 program variables become visible but user-specific configuration
1334 remains possible.
1340 remains possible.
1335
1341
1336 - stack_depth: specifies how many levels in the stack to go to
1342 - stack_depth: specifies how many levels in the stack to go to
1337 looking for namespaces (when local_ns and global_ns are None). This
1343 looking for namespaces (when local_ns and global_ns are None). This
1338 allows an intermediate caller to make sure that this function gets
1344 allows an intermediate caller to make sure that this function gets
1339 the namespace from the intended level in the stack. By default (0)
1345 the namespace from the intended level in the stack. By default (0)
1340 it will get its locals and globals from the immediate caller.
1346 it will get its locals and globals from the immediate caller.
1341
1347
1342 Warning: it's possible to use this in a program which is being run by
1348 Warning: it's possible to use this in a program which is being run by
1343 IPython itself (via %run), but some funny things will happen (a few
1349 IPython itself (via %run), but some funny things will happen (a few
1344 globals get overwritten). In the future this will be cleaned up, as
1350 globals get overwritten). In the future this will be cleaned up, as
1345 there is no fundamental reason why it can't work perfectly."""
1351 there is no fundamental reason why it can't work perfectly."""
1346
1352
1347 # Patch for global embedding to make sure that things don't overwrite
1353 # Patch for global embedding to make sure that things don't overwrite
1348 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1354 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1349 # FIXME. Test this a bit more carefully (the if.. is new)
1355 # FIXME. Test this a bit more carefully (the if.. is new)
1350 if local_ns is None and global_ns is None:
1356 if local_ns is None and global_ns is None:
1351 self.user_ns.update(__main__.__dict__)
1357 self.user_ns.update(__main__.__dict__)
1352
1358
1353 # Get locals and globals from caller
1359 # Get locals and globals from caller
1354 if local_ns is None or global_ns is None:
1360 if local_ns is None or global_ns is None:
1355 call_frame = sys._getframe(stack_depth).f_back
1361 call_frame = sys._getframe(stack_depth).f_back
1356
1362
1357 if local_ns is None:
1363 if local_ns is None:
1358 local_ns = call_frame.f_locals
1364 local_ns = call_frame.f_locals
1359 if global_ns is None:
1365 if global_ns is None:
1360 global_ns = call_frame.f_globals
1366 global_ns = call_frame.f_globals
1361
1367
1362 # Update namespaces and fire up interpreter
1368 # Update namespaces and fire up interpreter
1363 self.user_ns.update(local_ns)
1369 self.user_ns.update(local_ns)
1364 self.interact(header)
1370 self.interact(header)
1365
1371
1366 # Remove locals from namespace
1372 # Remove locals from namespace
1367 for k in local_ns:
1373 for k in local_ns:
1368 del self.user_ns[k]
1374 del self.user_ns[k]
1369
1375
1370 def interact(self, banner=None):
1376 def interact(self, banner=None):
1371 """Closely emulate the interactive Python console.
1377 """Closely emulate the interactive Python console.
1372
1378
1373 The optional banner argument specify the banner to print
1379 The optional banner argument specify the banner to print
1374 before the first interaction; by default it prints a banner
1380 before the first interaction; by default it prints a banner
1375 similar to the one printed by the real Python interpreter,
1381 similar to the one printed by the real Python interpreter,
1376 followed by the current class name in parentheses (so as not
1382 followed by the current class name in parentheses (so as not
1377 to confuse this with the real interpreter -- since it's so
1383 to confuse this with the real interpreter -- since it's so
1378 close!).
1384 close!).
1379
1385
1380 """
1386 """
1381 cprt = 'Type "copyright", "credits" or "license" for more information.'
1387 cprt = 'Type "copyright", "credits" or "license" for more information.'
1382 if banner is None:
1388 if banner is None:
1383 self.write("Python %s on %s\n%s\n(%s)\n" %
1389 self.write("Python %s on %s\n%s\n(%s)\n" %
1384 (sys.version, sys.platform, cprt,
1390 (sys.version, sys.platform, cprt,
1385 self.__class__.__name__))
1391 self.__class__.__name__))
1386 else:
1392 else:
1387 self.write(banner)
1393 self.write(banner)
1388
1394
1389 more = 0
1395 more = 0
1390
1396
1391 # Mark activity in the builtins
1397 # Mark activity in the builtins
1392 __builtin__.__dict__['__IPYTHON__active'] += 1
1398 __builtin__.__dict__['__IPYTHON__active'] += 1
1393
1399
1394 # exit_now is set by a call to %Exit or %Quit
1400 # exit_now is set by a call to %Exit or %Quit
1395 while not self.exit_now:
1401 while not self.exit_now:
1396 try:
1402 try:
1397 if more:
1403 if more:
1398 prompt = self.outputcache.prompt2
1404 prompt = self.outputcache.prompt2
1399 if self.autoindent:
1405 if self.autoindent:
1400 self.readline_startup_hook(self.pre_readline)
1406 self.readline_startup_hook(self.pre_readline)
1401 else:
1407 else:
1402 prompt = self.outputcache.prompt1
1408 prompt = self.outputcache.prompt1
1403 try:
1409 try:
1404 line = self.raw_input(prompt)
1410 line = self.raw_input(prompt)
1405 if self.autoindent:
1411 if self.autoindent:
1406 self.readline_startup_hook(None)
1412 self.readline_startup_hook(None)
1407 except EOFError:
1413 except EOFError:
1408 if self.autoindent:
1414 if self.autoindent:
1409 self.readline_startup_hook(None)
1415 self.readline_startup_hook(None)
1410 self.write("\n")
1416 self.write("\n")
1411 if self.rc.confirm_exit:
1417 if self.rc.confirm_exit:
1412 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
1418 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
1413 break
1419 break
1414 else:
1420 else:
1415 break
1421 break
1416 else:
1422 else:
1417 more = self.push(line)
1423 more = self.push(line)
1418 # Auto-indent management
1424 # Auto-indent management
1419 if self.autoindent:
1425 if self.autoindent:
1420 if line:
1426 if line:
1421 ini_spaces = re.match('^(\s+)',line)
1427 ini_spaces = re.match('^(\s+)',line)
1422 if ini_spaces:
1428 if ini_spaces:
1423 nspaces = ini_spaces.end()
1429 nspaces = ini_spaces.end()
1424 else:
1430 else:
1425 nspaces = 0
1431 nspaces = 0
1426 self.readline_indent = nspaces
1432 self.readline_indent = nspaces
1427
1433
1428 if line[-1] == ':':
1434 if line[-1] == ':':
1429 self.readline_indent += 4
1435 self.readline_indent += 4
1430 elif re.match(r'^\s+raise|^\s+return',line):
1436 elif re.match(r'^\s+raise|^\s+return',line):
1431 self.readline_indent -= 4
1437 self.readline_indent -= 4
1432 else:
1438 else:
1433 self.readline_indent = 0
1439 self.readline_indent = 0
1434
1440
1435 except KeyboardInterrupt:
1441 except KeyboardInterrupt:
1436 self.write("\nKeyboardInterrupt\n")
1442 self.write("\nKeyboardInterrupt\n")
1437 self.resetbuffer()
1443 self.resetbuffer()
1438 more = 0
1444 more = 0
1439 # keep cache in sync with the prompt counter:
1445 # keep cache in sync with the prompt counter:
1440 self.outputcache.prompt_count -= 1
1446 self.outputcache.prompt_count -= 1
1441
1447
1442 if self.autoindent:
1448 if self.autoindent:
1443 self.readline_indent = 0
1449 self.readline_indent = 0
1444
1450
1445 except bdb.BdbQuit:
1451 except bdb.BdbQuit:
1446 warn("The Python debugger has exited with a BdbQuit exception.\n"
1452 warn("The Python debugger has exited with a BdbQuit exception.\n"
1447 "Because of how pdb handles the stack, it is impossible\n"
1453 "Because of how pdb handles the stack, it is impossible\n"
1448 "for IPython to properly format this particular exception.\n"
1454 "for IPython to properly format this particular exception.\n"
1449 "IPython will resume normal operation.")
1455 "IPython will resume normal operation.")
1450
1456
1451 # We are off again...
1457 # We are off again...
1452 __builtin__.__dict__['__IPYTHON__active'] -= 1
1458 __builtin__.__dict__['__IPYTHON__active'] -= 1
1453
1459
1454 def excepthook(self, type, value, tb):
1460 def excepthook(self, type, value, tb):
1455 """One more defense for GUI apps that call sys.excepthook.
1461 """One more defense for GUI apps that call sys.excepthook.
1456
1462
1457 GUI frameworks like wxPython trap exceptions and call
1463 GUI frameworks like wxPython trap exceptions and call
1458 sys.excepthook themselves. I guess this is a feature that
1464 sys.excepthook themselves. I guess this is a feature that
1459 enables them to keep running after exceptions that would
1465 enables them to keep running after exceptions that would
1460 otherwise kill their mainloop. This is a bother for IPython
1466 otherwise kill their mainloop. This is a bother for IPython
1461 which excepts to catch all of the program exceptions with a try:
1467 which excepts to catch all of the program exceptions with a try:
1462 except: statement.
1468 except: statement.
1463
1469
1464 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1470 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1465 any app directly invokes sys.excepthook, it will look to the user like
1471 any app directly invokes sys.excepthook, it will look to the user like
1466 IPython crashed. In order to work around this, we can disable the
1472 IPython crashed. In order to work around this, we can disable the
1467 CrashHandler and replace it with this excepthook instead, which prints a
1473 CrashHandler and replace it with this excepthook instead, which prints a
1468 regular traceback using our InteractiveTB. In this fashion, apps which
1474 regular traceback using our InteractiveTB. In this fashion, apps which
1469 call sys.excepthook will generate a regular-looking exception from
1475 call sys.excepthook will generate a regular-looking exception from
1470 IPython, and the CrashHandler will only be triggered by real IPython
1476 IPython, and the CrashHandler will only be triggered by real IPython
1471 crashes.
1477 crashes.
1472
1478
1473 This hook should be used sparingly, only in places which are not likely
1479 This hook should be used sparingly, only in places which are not likely
1474 to be true IPython errors.
1480 to be true IPython errors.
1475 """
1481 """
1476
1482
1477 self.InteractiveTB(type, value, tb, tb_offset=0)
1483 self.InteractiveTB(type, value, tb, tb_offset=0)
1478 if self.InteractiveTB.call_pdb and self.has_readline:
1484 if self.InteractiveTB.call_pdb and self.has_readline:
1479 self.readline.set_completer(self.Completer.complete)
1485 self.readline.set_completer(self.Completer.complete)
1480
1486
1481 def call_alias(self,alias,rest=''):
1487 def call_alias(self,alias,rest=''):
1482 """Call an alias given its name and the rest of the line.
1488 """Call an alias given its name and the rest of the line.
1483
1489
1484 This function MUST be given a proper alias, because it doesn't make
1490 This function MUST be given a proper alias, because it doesn't make
1485 any checks when looking up into the alias table. The caller is
1491 any checks when looking up into the alias table. The caller is
1486 responsible for invoking it only with a valid alias."""
1492 responsible for invoking it only with a valid alias."""
1487
1493
1488 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1494 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1489 nargs,cmd = self.alias_table[alias]
1495 nargs,cmd = self.alias_table[alias]
1490 # Expand the %l special to be the user's input line
1496 # Expand the %l special to be the user's input line
1491 if cmd.find('%l') >= 0:
1497 if cmd.find('%l') >= 0:
1492 cmd = cmd.replace('%l',rest)
1498 cmd = cmd.replace('%l',rest)
1493 rest = ''
1499 rest = ''
1494 if nargs==0:
1500 if nargs==0:
1495 # Simple, argument-less aliases
1501 # Simple, argument-less aliases
1496 cmd = '%s %s' % (cmd,rest)
1502 cmd = '%s %s' % (cmd,rest)
1497 else:
1503 else:
1498 # Handle aliases with positional arguments
1504 # Handle aliases with positional arguments
1499 args = rest.split(None,nargs)
1505 args = rest.split(None,nargs)
1500 if len(args)< nargs:
1506 if len(args)< nargs:
1501 error('Alias <%s> requires %s arguments, %s given.' %
1507 error('Alias <%s> requires %s arguments, %s given.' %
1502 (alias,nargs,len(args)))
1508 (alias,nargs,len(args)))
1503 return
1509 return
1504 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1510 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1505 # Now call the macro, evaluating in the user's namespace
1511 # Now call the macro, evaluating in the user's namespace
1506 try:
1512 try:
1507 self.system(cmd)
1513 self.system(cmd)
1508 except:
1514 except:
1509 self.showtraceback()
1515 self.showtraceback()
1510
1516
1511 def runlines(self,lines):
1517 def runlines(self,lines):
1512 """Run a string of one or more lines of source.
1518 """Run a string of one or more lines of source.
1513
1519
1514 This method is capable of running a string containing multiple source
1520 This method is capable of running a string containing multiple source
1515 lines, as if they had been entered at the IPython prompt. Since it
1521 lines, as if they had been entered at the IPython prompt. Since it
1516 exposes IPython's processing machinery, the given strings can contain
1522 exposes IPython's processing machinery, the given strings can contain
1517 magic calls (%magic), special shell access (!cmd), etc."""
1523 magic calls (%magic), special shell access (!cmd), etc."""
1518
1524
1519 # We must start with a clean buffer, in case this is run from an
1525 # We must start with a clean buffer, in case this is run from an
1520 # interactive IPython session (via a magic, for example).
1526 # interactive IPython session (via a magic, for example).
1521 self.resetbuffer()
1527 self.resetbuffer()
1522 lines = lines.split('\n')
1528 lines = lines.split('\n')
1523 more = 0
1529 more = 0
1524 for line in lines:
1530 for line in lines:
1525 # skip blank lines so we don't mess up the prompt counter, but do
1531 # skip blank lines so we don't mess up the prompt counter, but do
1526 # NOT skip even a blank line if we are in a code block (more is
1532 # NOT skip even a blank line if we are in a code block (more is
1527 # true)
1533 # true)
1528 if line or more:
1534 if line or more:
1529 more = self.push((self.prefilter(line,more)))
1535 more = self.push((self.prefilter(line,more)))
1530 # IPython's runsource returns None if there was an error
1536 # IPython's runsource returns None if there was an error
1531 # compiling the code. This allows us to stop processing right
1537 # compiling the code. This allows us to stop processing right
1532 # away, so the user gets the error message at the right place.
1538 # away, so the user gets the error message at the right place.
1533 if more is None:
1539 if more is None:
1534 break
1540 break
1535 # final newline in case the input didn't have it, so that the code
1541 # final newline in case the input didn't have it, so that the code
1536 # actually does get executed
1542 # actually does get executed
1537 if more:
1543 if more:
1538 self.push('\n')
1544 self.push('\n')
1539
1545
1540 def runsource(self, source, filename="<input>", symbol="single"):
1546 def runsource(self, source, filename="<input>", symbol="single"):
1541 """Compile and run some source in the interpreter.
1547 """Compile and run some source in the interpreter.
1542
1548
1543 Arguments are as for compile_command().
1549 Arguments are as for compile_command().
1544
1550
1545 One several things can happen:
1551 One several things can happen:
1546
1552
1547 1) The input is incorrect; compile_command() raised an
1553 1) The input is incorrect; compile_command() raised an
1548 exception (SyntaxError or OverflowError). A syntax traceback
1554 exception (SyntaxError or OverflowError). A syntax traceback
1549 will be printed by calling the showsyntaxerror() method.
1555 will be printed by calling the showsyntaxerror() method.
1550
1556
1551 2) The input is incomplete, and more input is required;
1557 2) The input is incomplete, and more input is required;
1552 compile_command() returned None. Nothing happens.
1558 compile_command() returned None. Nothing happens.
1553
1559
1554 3) The input is complete; compile_command() returned a code
1560 3) The input is complete; compile_command() returned a code
1555 object. The code is executed by calling self.runcode() (which
1561 object. The code is executed by calling self.runcode() (which
1556 also handles run-time exceptions, except for SystemExit).
1562 also handles run-time exceptions, except for SystemExit).
1557
1563
1558 The return value is:
1564 The return value is:
1559
1565
1560 - True in case 2
1566 - True in case 2
1561
1567
1562 - False in the other cases, unless an exception is raised, where
1568 - False in the other cases, unless an exception is raised, where
1563 None is returned instead. This can be used by external callers to
1569 None is returned instead. This can be used by external callers to
1564 know whether to continue feeding input or not.
1570 know whether to continue feeding input or not.
1565
1571
1566 The return value can be used to decide whether to use sys.ps1 or
1572 The return value can be used to decide whether to use sys.ps1 or
1567 sys.ps2 to prompt the next line."""
1573 sys.ps2 to prompt the next line."""
1568
1574
1569 try:
1575 try:
1570 code = self.compile(source, filename, symbol)
1576 code = self.compile(source, filename, symbol)
1571 except (OverflowError, SyntaxError, ValueError):
1577 except (OverflowError, SyntaxError, ValueError):
1572 # Case 1
1578 # Case 1
1573 self.showsyntaxerror(filename)
1579 self.showsyntaxerror(filename)
1574 return None
1580 return None
1575
1581
1576 if code is None:
1582 if code is None:
1577 # Case 2
1583 # Case 2
1578 return True
1584 return True
1579
1585
1580 # Case 3
1586 # Case 3
1581 # We store the code object so that threaded shells and
1587 # We store the code object so that threaded shells and
1582 # custom exception handlers can access all this info if needed.
1588 # custom exception handlers can access all this info if needed.
1583 # The source corresponding to this can be obtained from the
1589 # The source corresponding to this can be obtained from the
1584 # buffer attribute as '\n'.join(self.buffer).
1590 # buffer attribute as '\n'.join(self.buffer).
1585 self.code_to_run = code
1591 self.code_to_run = code
1586 # now actually execute the code object
1592 # now actually execute the code object
1587 if self.runcode(code) == 0:
1593 if self.runcode(code) == 0:
1588 return False
1594 return False
1589 else:
1595 else:
1590 return None
1596 return None
1591
1597
1592 def runcode(self,code_obj):
1598 def runcode(self,code_obj):
1593 """Execute a code object.
1599 """Execute a code object.
1594
1600
1595 When an exception occurs, self.showtraceback() is called to display a
1601 When an exception occurs, self.showtraceback() is called to display a
1596 traceback.
1602 traceback.
1597
1603
1598 Return value: a flag indicating whether the code to be run completed
1604 Return value: a flag indicating whether the code to be run completed
1599 successfully:
1605 successfully:
1600
1606
1601 - 0: successful execution.
1607 - 0: successful execution.
1602 - 1: an error occurred.
1608 - 1: an error occurred.
1603 """
1609 """
1604
1610
1605 # Set our own excepthook in case the user code tries to call it
1611 # Set our own excepthook in case the user code tries to call it
1606 # directly, so that the IPython crash handler doesn't get triggered
1612 # directly, so that the IPython crash handler doesn't get triggered
1607 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1613 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1608 outflag = 1 # happens in more places, so it's easier as default
1614 outflag = 1 # happens in more places, so it's easier as default
1609 try:
1615 try:
1610 try:
1616 try:
1611 exec code_obj in self.locals
1617 exec code_obj in self.locals
1612 finally:
1618 finally:
1613 # Reset our crash handler in place
1619 # Reset our crash handler in place
1614 sys.excepthook = old_excepthook
1620 sys.excepthook = old_excepthook
1615 except SystemExit:
1621 except SystemExit:
1616 self.resetbuffer()
1622 self.resetbuffer()
1617 self.showtraceback()
1623 self.showtraceback()
1618 warn( __builtin__.exit,level=1)
1624 warn( __builtin__.exit,level=1)
1619 except self.custom_exceptions:
1625 except self.custom_exceptions:
1620 etype,value,tb = sys.exc_info()
1626 etype,value,tb = sys.exc_info()
1621 self.CustomTB(etype,value,tb)
1627 self.CustomTB(etype,value,tb)
1622 except:
1628 except:
1623 self.showtraceback()
1629 self.showtraceback()
1624 else:
1630 else:
1625 outflag = 0
1631 outflag = 0
1626 if code.softspace(sys.stdout, 0):
1632 if code.softspace(sys.stdout, 0):
1627 print
1633 print
1628 # Flush out code object which has been run (and source)
1634 # Flush out code object which has been run (and source)
1629 self.code_to_run = None
1635 self.code_to_run = None
1630 return outflag
1636 return outflag
1631
1637
1632 def raw_input(self, prompt=""):
1638 def raw_input(self, prompt=""):
1633 """Write a prompt and read a line.
1639 """Write a prompt and read a line.
1634
1640
1635 The returned line does not include the trailing newline.
1641 The returned line does not include the trailing newline.
1636 When the user enters the EOF key sequence, EOFError is raised.
1642 When the user enters the EOF key sequence, EOFError is raised.
1637
1643
1638 The base implementation uses the built-in function
1644 The base implementation uses the built-in function
1639 raw_input(); a subclass may replace this with a different
1645 raw_input(); a subclass may replace this with a different
1640 implementation.
1646 implementation.
1641 """
1647 """
1642 return self.prefilter(raw_input_original(prompt),
1648 return self.prefilter(raw_input_original(prompt),
1643 prompt==self.outputcache.prompt2)
1649 prompt==self.outputcache.prompt2)
1644
1650
1645 def split_user_input(self,line):
1651 def split_user_input(self,line):
1646 """Split user input into pre-char, function part and rest."""
1652 """Split user input into pre-char, function part and rest."""
1647
1653
1648 lsplit = self.line_split.match(line)
1654 lsplit = self.line_split.match(line)
1649 if lsplit is None: # no regexp match returns None
1655 if lsplit is None: # no regexp match returns None
1650 try:
1656 try:
1651 iFun,theRest = line.split(None,1)
1657 iFun,theRest = line.split(None,1)
1652 except ValueError:
1658 except ValueError:
1653 iFun,theRest = line,''
1659 iFun,theRest = line,''
1654 pre = re.match('^(\s*)(.*)',line).groups()[0]
1660 pre = re.match('^(\s*)(.*)',line).groups()[0]
1655 else:
1661 else:
1656 pre,iFun,theRest = lsplit.groups()
1662 pre,iFun,theRest = lsplit.groups()
1657
1663
1658 #print 'line:<%s>' % line # dbg
1664 #print 'line:<%s>' % line # dbg
1659 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1665 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1660 return pre,iFun.strip(),theRest
1666 return pre,iFun.strip(),theRest
1661
1667
1662 def _prefilter(self, line, continue_prompt):
1668 def _prefilter(self, line, continue_prompt):
1663 """Calls different preprocessors, depending on the form of line."""
1669 """Calls different preprocessors, depending on the form of line."""
1664
1670
1665 # All handlers *must* return a value, even if it's blank ('').
1671 # All handlers *must* return a value, even if it's blank ('').
1666
1672
1667 # Lines are NOT logged here. Handlers should process the line as
1673 # Lines are NOT logged here. Handlers should process the line as
1668 # needed, update the cache AND log it (so that the input cache array
1674 # needed, update the cache AND log it (so that the input cache array
1669 # stays synced).
1675 # stays synced).
1670
1676
1671 # This function is _very_ delicate, and since it's also the one which
1677 # This function is _very_ delicate, and since it's also the one which
1672 # determines IPython's response to user input, it must be as efficient
1678 # determines IPython's response to user input, it must be as efficient
1673 # as possible. For this reason it has _many_ returns in it, trying
1679 # as possible. For this reason it has _many_ returns in it, trying
1674 # always to exit as quickly as it can figure out what it needs to do.
1680 # always to exit as quickly as it can figure out what it needs to do.
1675
1681
1676 # This function is the main responsible for maintaining IPython's
1682 # This function is the main responsible for maintaining IPython's
1677 # behavior respectful of Python's semantics. So be _very_ careful if
1683 # behavior respectful of Python's semantics. So be _very_ careful if
1678 # making changes to anything here.
1684 # making changes to anything here.
1679
1685
1680 #.....................................................................
1686 #.....................................................................
1681 # Code begins
1687 # Code begins
1682
1688
1683 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1689 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1684
1690
1685 # save the line away in case we crash, so the post-mortem handler can
1691 # save the line away in case we crash, so the post-mortem handler can
1686 # record it
1692 # record it
1687 self._last_input_line = line
1693 self._last_input_line = line
1688
1694
1689 #print '***line: <%s>' % line # dbg
1695 #print '***line: <%s>' % line # dbg
1690
1696
1691 # the input history needs to track even empty lines
1697 # the input history needs to track even empty lines
1692 if not line.strip():
1698 if not line.strip():
1693 if not continue_prompt:
1699 if not continue_prompt:
1694 self.outputcache.prompt_count -= 1
1700 self.outputcache.prompt_count -= 1
1695 return self.handle_normal('',continue_prompt)
1701 return self.handle_normal('',continue_prompt)
1696
1702
1697 # print '***cont',continue_prompt # dbg
1703 # print '***cont',continue_prompt # dbg
1698 # special handlers are only allowed for single line statements
1704 # special handlers are only allowed for single line statements
1699 if continue_prompt and not self.rc.multi_line_specials:
1705 if continue_prompt and not self.rc.multi_line_specials:
1700 return self.handle_normal(line,continue_prompt)
1706 return self.handle_normal(line,continue_prompt)
1701
1707
1702 # For the rest, we need the structure of the input
1708 # For the rest, we need the structure of the input
1703 pre,iFun,theRest = self.split_user_input(line)
1709 pre,iFun,theRest = self.split_user_input(line)
1704 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1710 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1705
1711
1706 # First check for explicit escapes in the last/first character
1712 # First check for explicit escapes in the last/first character
1707 handler = None
1713 handler = None
1708 if line[-1] == self.ESC_HELP:
1714 if line[-1] == self.ESC_HELP:
1709 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1715 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1710 if handler is None:
1716 if handler is None:
1711 # look at the first character of iFun, NOT of line, so we skip
1717 # look at the first character of iFun, NOT of line, so we skip
1712 # leading whitespace in multiline input
1718 # leading whitespace in multiline input
1713 handler = self.esc_handlers.get(iFun[0:1])
1719 handler = self.esc_handlers.get(iFun[0:1])
1714 if handler is not None:
1720 if handler is not None:
1715 return handler(line,continue_prompt,pre,iFun,theRest)
1721 return handler(line,continue_prompt,pre,iFun,theRest)
1716 # Emacs ipython-mode tags certain input lines
1722 # Emacs ipython-mode tags certain input lines
1717 if line.endswith('# PYTHON-MODE'):
1723 if line.endswith('# PYTHON-MODE'):
1718 return self.handle_emacs(line,continue_prompt)
1724 return self.handle_emacs(line,continue_prompt)
1719
1725
1720 # Next, check if we can automatically execute this thing
1726 # Next, check if we can automatically execute this thing
1721
1727
1722 # Allow ! in multi-line statements if multi_line_specials is on:
1728 # Allow ! in multi-line statements if multi_line_specials is on:
1723 if continue_prompt and self.rc.multi_line_specials and \
1729 if continue_prompt and self.rc.multi_line_specials and \
1724 iFun.startswith(self.ESC_SHELL):
1730 iFun.startswith(self.ESC_SHELL):
1725 return self.handle_shell_escape(line,continue_prompt,
1731 return self.handle_shell_escape(line,continue_prompt,
1726 pre=pre,iFun=iFun,
1732 pre=pre,iFun=iFun,
1727 theRest=theRest)
1733 theRest=theRest)
1728
1734
1729 # Let's try to find if the input line is a magic fn
1735 # Let's try to find if the input line is a magic fn
1730 oinfo = None
1736 oinfo = None
1731 if hasattr(self,'magic_'+iFun):
1737 if hasattr(self,'magic_'+iFun):
1732 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1738 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1733 if oinfo['ismagic']:
1739 if oinfo['ismagic']:
1734 # Be careful not to call magics when a variable assignment is
1740 # Be careful not to call magics when a variable assignment is
1735 # being made (ls='hi', for example)
1741 # being made (ls='hi', for example)
1736 if self.rc.automagic and \
1742 if self.rc.automagic and \
1737 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1743 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1738 (self.rc.multi_line_specials or not continue_prompt):
1744 (self.rc.multi_line_specials or not continue_prompt):
1739 return self.handle_magic(line,continue_prompt,
1745 return self.handle_magic(line,continue_prompt,
1740 pre,iFun,theRest)
1746 pre,iFun,theRest)
1741 else:
1747 else:
1742 return self.handle_normal(line,continue_prompt)
1748 return self.handle_normal(line,continue_prompt)
1743
1749
1744 # If the rest of the line begins with an (in)equality, assginment or
1750 # If the rest of the line begins with an (in)equality, assginment or
1745 # function call, we should not call _ofind but simply execute it.
1751 # function call, we should not call _ofind but simply execute it.
1746 # This avoids spurious geattr() accesses on objects upon assignment.
1752 # This avoids spurious geattr() accesses on objects upon assignment.
1747 #
1753 #
1748 # It also allows users to assign to either alias or magic names true
1754 # It also allows users to assign to either alias or magic names true
1749 # python variables (the magic/alias systems always take second seat to
1755 # python variables (the magic/alias systems always take second seat to
1750 # true python code).
1756 # true python code).
1751 if theRest and theRest[0] in '!=()':
1757 if theRest and theRest[0] in '!=()':
1752 return self.handle_normal(line,continue_prompt)
1758 return self.handle_normal(line,continue_prompt)
1753
1759
1754 if oinfo is None:
1760 if oinfo is None:
1755 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1761 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1756
1762
1757 if not oinfo['found']:
1763 if not oinfo['found']:
1758 return self.handle_normal(line,continue_prompt)
1764 return self.handle_normal(line,continue_prompt)
1759 else:
1765 else:
1760 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1766 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1761 if oinfo['isalias']:
1767 if oinfo['isalias']:
1762 return self.handle_alias(line,continue_prompt,
1768 return self.handle_alias(line,continue_prompt,
1763 pre,iFun,theRest)
1769 pre,iFun,theRest)
1764
1770
1765 if self.rc.autocall and \
1771 if self.rc.autocall and \
1766 not self.re_exclude_auto.match(theRest) and \
1772 not self.re_exclude_auto.match(theRest) and \
1767 self.re_fun_name.match(iFun) and \
1773 self.re_fun_name.match(iFun) and \
1768 callable(oinfo['obj']) :
1774 callable(oinfo['obj']) :
1769 #print 'going auto' # dbg
1775 #print 'going auto' # dbg
1770 return self.handle_auto(line,continue_prompt,pre,iFun,theRest)
1776 return self.handle_auto(line,continue_prompt,pre,iFun,theRest)
1771 else:
1777 else:
1772 #print 'was callable?', callable(oinfo['obj']) # dbg
1778 #print 'was callable?', callable(oinfo['obj']) # dbg
1773 return self.handle_normal(line,continue_prompt)
1779 return self.handle_normal(line,continue_prompt)
1774
1780
1775 # If we get here, we have a normal Python line. Log and return.
1781 # If we get here, we have a normal Python line. Log and return.
1776 return self.handle_normal(line,continue_prompt)
1782 return self.handle_normal(line,continue_prompt)
1777
1783
1778 def _prefilter_dumb(self, line, continue_prompt):
1784 def _prefilter_dumb(self, line, continue_prompt):
1779 """simple prefilter function, for debugging"""
1785 """simple prefilter function, for debugging"""
1780 return self.handle_normal(line,continue_prompt)
1786 return self.handle_normal(line,continue_prompt)
1781
1787
1782 # Set the default prefilter() function (this can be user-overridden)
1788 # Set the default prefilter() function (this can be user-overridden)
1783 prefilter = _prefilter
1789 prefilter = _prefilter
1784
1790
1785 def handle_normal(self,line,continue_prompt=None,
1791 def handle_normal(self,line,continue_prompt=None,
1786 pre=None,iFun=None,theRest=None):
1792 pre=None,iFun=None,theRest=None):
1787 """Handle normal input lines. Use as a template for handlers."""
1793 """Handle normal input lines. Use as a template for handlers."""
1788
1794
1789 self.log(line,continue_prompt)
1795 self.log(line,continue_prompt)
1790 self.update_cache(line)
1796 self.update_cache(line)
1791 return line
1797 return line
1792
1798
1793 def handle_alias(self,line,continue_prompt=None,
1799 def handle_alias(self,line,continue_prompt=None,
1794 pre=None,iFun=None,theRest=None):
1800 pre=None,iFun=None,theRest=None):
1795 """Handle alias input lines. """
1801 """Handle alias input lines. """
1796
1802
1797 theRest = esc_quotes(theRest)
1803 theRest = esc_quotes(theRest)
1798 line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest)
1804 line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest)
1799 self.log(line_out,continue_prompt)
1805 self.log(line_out,continue_prompt)
1800 self.update_cache(line_out)
1806 self.update_cache(line_out)
1801 return line_out
1807 return line_out
1802
1808
1803 def handle_shell_escape(self, line, continue_prompt=None,
1809 def handle_shell_escape(self, line, continue_prompt=None,
1804 pre=None,iFun=None,theRest=None):
1810 pre=None,iFun=None,theRest=None):
1805 """Execute the line in a shell, empty return value"""
1811 """Execute the line in a shell, empty return value"""
1806
1812
1807 #print 'line in :', `line` # dbg
1813 #print 'line in :', `line` # dbg
1808 # Example of a special handler. Others follow a similar pattern.
1814 # Example of a special handler. Others follow a similar pattern.
1809 if continue_prompt: # multi-line statements
1815 if continue_prompt: # multi-line statements
1810 if iFun.startswith('!!'):
1816 if iFun.startswith('!!'):
1811 print 'SyntaxError: !! is not allowed in multiline statements'
1817 print 'SyntaxError: !! is not allowed in multiline statements'
1812 return pre
1818 return pre
1813 else:
1819 else:
1814 cmd = ("%s %s" % (iFun[1:],theRest)).replace('"','\\"')
1820 cmd = ("%s %s" % (iFun[1:],theRest)).replace('"','\\"')
1815 line_out = '%s%s.system("%s")' % (pre,self.name,cmd)
1821 line_out = '%s%s.system("%s")' % (pre,self.name,cmd)
1816 #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')'
1822 #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')'
1817 else: # single-line input
1823 else: # single-line input
1818 if line.startswith('!!'):
1824 if line.startswith('!!'):
1819 # rewrite iFun/theRest to properly hold the call to %sx and
1825 # rewrite iFun/theRest to properly hold the call to %sx and
1820 # the actual command to be executed, so handle_magic can work
1826 # the actual command to be executed, so handle_magic can work
1821 # correctly
1827 # correctly
1822 theRest = '%s %s' % (iFun[2:],theRest)
1828 theRest = '%s %s' % (iFun[2:],theRest)
1823 iFun = 'sx'
1829 iFun = 'sx'
1824 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1830 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1825 continue_prompt,pre,iFun,theRest)
1831 continue_prompt,pre,iFun,theRest)
1826 else:
1832 else:
1827 cmd = esc_quotes(line[1:])
1833 cmd = esc_quotes(line[1:])
1828 line_out = '%s.system("%s")' % (self.name,cmd)
1834 line_out = '%s.system("%s")' % (self.name,cmd)
1829 #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')'
1835 #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')'
1830 # update cache/log and return
1836 # update cache/log and return
1831 self.log(line_out,continue_prompt)
1837 self.log(line_out,continue_prompt)
1832 self.update_cache(line_out) # readline cache gets normal line
1838 self.update_cache(line_out) # readline cache gets normal line
1833 #print 'line out r:', `line_out` # dbg
1839 #print 'line out r:', `line_out` # dbg
1834 #print 'line out s:', line_out # dbg
1840 #print 'line out s:', line_out # dbg
1835 return line_out
1841 return line_out
1836
1842
1837 def handle_magic(self, line, continue_prompt=None,
1843 def handle_magic(self, line, continue_prompt=None,
1838 pre=None,iFun=None,theRest=None):
1844 pre=None,iFun=None,theRest=None):
1839 """Execute magic functions.
1845 """Execute magic functions.
1840
1846
1841 Also log them with a prepended # so the log is clean Python."""
1847 Also log them with a prepended # so the log is clean Python."""
1842
1848
1843 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1849 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1844 self.log(cmd,continue_prompt)
1850 self.log(cmd,continue_prompt)
1845 self.update_cache(line)
1851 self.update_cache(line)
1846 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1852 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1847 return cmd
1853 return cmd
1848
1854
1849 def handle_auto(self, line, continue_prompt=None,
1855 def handle_auto(self, line, continue_prompt=None,
1850 pre=None,iFun=None,theRest=None):
1856 pre=None,iFun=None,theRest=None):
1851 """Hande lines which can be auto-executed, quoting if requested."""
1857 """Hande lines which can be auto-executed, quoting if requested."""
1852
1858
1853 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1859 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1854
1860
1855 # This should only be active for single-line input!
1861 # This should only be active for single-line input!
1856 if continue_prompt:
1862 if continue_prompt:
1857 return line
1863 return line
1858
1864
1859 if pre == self.ESC_QUOTE:
1865 if pre == self.ESC_QUOTE:
1860 # Auto-quote splitting on whitespace
1866 # Auto-quote splitting on whitespace
1861 newcmd = '%s("%s")\n' % (iFun,'", "'.join(theRest.split()) )
1867 newcmd = '%s("%s")\n' % (iFun,'", "'.join(theRest.split()) )
1862 elif pre == self.ESC_QUOTE2:
1868 elif pre == self.ESC_QUOTE2:
1863 # Auto-quote whole string
1869 # Auto-quote whole string
1864 newcmd = '%s("%s")\n' % (iFun,theRest)
1870 newcmd = '%s("%s")\n' % (iFun,theRest)
1865 else:
1871 else:
1866 # Auto-paren
1872 # Auto-paren
1867 if theRest[0:1] in ('=','['):
1873 if theRest[0:1] in ('=','['):
1868 # Don't autocall in these cases. They can be either
1874 # Don't autocall in these cases. They can be either
1869 # rebindings of an existing callable's name, or item access
1875 # rebindings of an existing callable's name, or item access
1870 # for an object which is BOTH callable and implements
1876 # for an object which is BOTH callable and implements
1871 # __getitem__.
1877 # __getitem__.
1872 return '%s %s\n' % (iFun,theRest)
1878 return '%s %s\n' % (iFun,theRest)
1873 if theRest.endswith(';'):
1879 if theRest.endswith(';'):
1874 newcmd = '%s(%s);\n' % (iFun.rstrip(),theRest[:-1])
1880 newcmd = '%s(%s);\n' % (iFun.rstrip(),theRest[:-1])
1875 else:
1881 else:
1876 newcmd = '%s(%s)\n' % (iFun.rstrip(),theRest)
1882 newcmd = '%s(%s)\n' % (iFun.rstrip(),theRest)
1877
1883
1878 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd,
1884 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd,
1879 # log what is now valid Python, not the actual user input (without the
1885 # log what is now valid Python, not the actual user input (without the
1880 # final newline)
1886 # final newline)
1881 self.log(newcmd.strip(),continue_prompt)
1887 self.log(newcmd.strip(),continue_prompt)
1882 return newcmd
1888 return newcmd
1883
1889
1884 def handle_help(self, line, continue_prompt=None,
1890 def handle_help(self, line, continue_prompt=None,
1885 pre=None,iFun=None,theRest=None):
1891 pre=None,iFun=None,theRest=None):
1886 """Try to get some help for the object.
1892 """Try to get some help for the object.
1887
1893
1888 obj? or ?obj -> basic information.
1894 obj? or ?obj -> basic information.
1889 obj?? or ??obj -> more details.
1895 obj?? or ??obj -> more details.
1890 """
1896 """
1891
1897
1892 # We need to make sure that we don't process lines which would be
1898 # We need to make sure that we don't process lines which would be
1893 # otherwise valid python, such as "x=1 # what?"
1899 # otherwise valid python, such as "x=1 # what?"
1894 try:
1900 try:
1895 code.compile_command(line)
1901 code.compile_command(line)
1896 except SyntaxError:
1902 except SyntaxError:
1897 # We should only handle as help stuff which is NOT valid syntax
1903 # We should only handle as help stuff which is NOT valid syntax
1898 if line[0]==self.ESC_HELP:
1904 if line[0]==self.ESC_HELP:
1899 line = line[1:]
1905 line = line[1:]
1900 elif line[-1]==self.ESC_HELP:
1906 elif line[-1]==self.ESC_HELP:
1901 line = line[:-1]
1907 line = line[:-1]
1902 self.log('#?'+line)
1908 self.log('#?'+line)
1903 self.update_cache(line)
1909 self.update_cache(line)
1904 if line:
1910 if line:
1905 self.magic_pinfo(line)
1911 self.magic_pinfo(line)
1906 else:
1912 else:
1907 page(self.usage,screen_lines=self.rc.screen_length)
1913 page(self.usage,screen_lines=self.rc.screen_length)
1908 return '' # Empty string is needed here!
1914 return '' # Empty string is needed here!
1909 except:
1915 except:
1910 # Pass any other exceptions through to the normal handler
1916 # Pass any other exceptions through to the normal handler
1911 return self.handle_normal(line,continue_prompt)
1917 return self.handle_normal(line,continue_prompt)
1912 else:
1918 else:
1913 # If the code compiles ok, we should handle it normally
1919 # If the code compiles ok, we should handle it normally
1914 return self.handle_normal(line,continue_prompt)
1920 return self.handle_normal(line,continue_prompt)
1915
1921
1916 def handle_emacs(self,line,continue_prompt=None,
1922 def handle_emacs(self,line,continue_prompt=None,
1917 pre=None,iFun=None,theRest=None):
1923 pre=None,iFun=None,theRest=None):
1918 """Handle input lines marked by python-mode."""
1924 """Handle input lines marked by python-mode."""
1919
1925
1920 # Currently, nothing is done. Later more functionality can be added
1926 # Currently, nothing is done. Later more functionality can be added
1921 # here if needed.
1927 # here if needed.
1922
1928
1923 # The input cache shouldn't be updated
1929 # The input cache shouldn't be updated
1924
1930
1925 return line
1931 return line
1926
1932
1927 def write(self,data):
1933 def write(self,data):
1928 """Write a string to the default output"""
1934 """Write a string to the default output"""
1929 Term.cout.write(data)
1935 Term.cout.write(data)
1930
1936
1931 def write_err(self,data):
1937 def write_err(self,data):
1932 """Write a string to the default error output"""
1938 """Write a string to the default error output"""
1933 Term.cerr.write(data)
1939 Term.cerr.write(data)
1934
1940
1935 def safe_execfile(self,fname,*where,**kw):
1941 def safe_execfile(self,fname,*where,**kw):
1936 fname = os.path.expanduser(fname)
1942 fname = os.path.expanduser(fname)
1937
1943
1938 # find things also in current directory
1944 # find things also in current directory
1939 dname = os.path.dirname(fname)
1945 dname = os.path.dirname(fname)
1940 if not sys.path.count(dname):
1946 if not sys.path.count(dname):
1941 sys.path.append(dname)
1947 sys.path.append(dname)
1942
1948
1943 try:
1949 try:
1944 xfile = open(fname)
1950 xfile = open(fname)
1945 except:
1951 except:
1946 print >> Term.cerr, \
1952 print >> Term.cerr, \
1947 'Could not open file <%s> for safe execution.' % fname
1953 'Could not open file <%s> for safe execution.' % fname
1948 return None
1954 return None
1949
1955
1950 kw.setdefault('islog',0)
1956 kw.setdefault('islog',0)
1951 kw.setdefault('quiet',1)
1957 kw.setdefault('quiet',1)
1952 kw.setdefault('exit_ignore',0)
1958 kw.setdefault('exit_ignore',0)
1953 first = xfile.readline()
1959 first = xfile.readline()
1954 _LOGHEAD = str(self.LOGHEAD).split('\n',1)[0].strip()
1960 _LOGHEAD = str(self.LOGHEAD).split('\n',1)[0].strip()
1955 xfile.close()
1961 xfile.close()
1956 # line by line execution
1962 # line by line execution
1957 if first.startswith(_LOGHEAD) or kw['islog']:
1963 if first.startswith(_LOGHEAD) or kw['islog']:
1958 print 'Loading log file <%s> one line at a time...' % fname
1964 print 'Loading log file <%s> one line at a time...' % fname
1959 if kw['quiet']:
1965 if kw['quiet']:
1960 stdout_save = sys.stdout
1966 stdout_save = sys.stdout
1961 sys.stdout = StringIO.StringIO()
1967 sys.stdout = StringIO.StringIO()
1962 try:
1968 try:
1963 globs,locs = where[0:2]
1969 globs,locs = where[0:2]
1964 except:
1970 except:
1965 try:
1971 try:
1966 globs = locs = where[0]
1972 globs = locs = where[0]
1967 except:
1973 except:
1968 globs = locs = globals()
1974 globs = locs = globals()
1969 badblocks = []
1975 badblocks = []
1970
1976
1971 # we also need to identify indented blocks of code when replaying
1977 # we also need to identify indented blocks of code when replaying
1972 # logs and put them together before passing them to an exec
1978 # logs and put them together before passing them to an exec
1973 # statement. This takes a bit of regexp and look-ahead work in the
1979 # statement. This takes a bit of regexp and look-ahead work in the
1974 # file. It's easiest if we swallow the whole thing in memory
1980 # file. It's easiest if we swallow the whole thing in memory
1975 # first, and manually walk through the lines list moving the
1981 # first, and manually walk through the lines list moving the
1976 # counter ourselves.
1982 # counter ourselves.
1977 indent_re = re.compile('\s+\S')
1983 indent_re = re.compile('\s+\S')
1978 xfile = open(fname)
1984 xfile = open(fname)
1979 filelines = xfile.readlines()
1985 filelines = xfile.readlines()
1980 xfile.close()
1986 xfile.close()
1981 nlines = len(filelines)
1987 nlines = len(filelines)
1982 lnum = 0
1988 lnum = 0
1983 while lnum < nlines:
1989 while lnum < nlines:
1984 line = filelines[lnum]
1990 line = filelines[lnum]
1985 lnum += 1
1991 lnum += 1
1986 # don't re-insert logger status info into cache
1992 # don't re-insert logger status info into cache
1987 if line.startswith('#log#'):
1993 if line.startswith('#log#'):
1988 continue
1994 continue
1989 elif line.startswith('#%s'% self.ESC_MAGIC):
1995 elif line.startswith('#%s'% self.ESC_MAGIC):
1990 self.update_cache(line[1:])
1996 self.update_cache(line[1:])
1991 line = magic2python(line)
1997 line = magic2python(line)
1992 elif line.startswith('#!'):
1998 elif line.startswith('#!'):
1993 self.update_cache(line[1:])
1999 self.update_cache(line[1:])
1994 else:
2000 else:
1995 # build a block of code (maybe a single line) for execution
2001 # build a block of code (maybe a single line) for execution
1996 block = line
2002 block = line
1997 try:
2003 try:
1998 next = filelines[lnum] # lnum has already incremented
2004 next = filelines[lnum] # lnum has already incremented
1999 except:
2005 except:
2000 next = None
2006 next = None
2001 while next and indent_re.match(next):
2007 while next and indent_re.match(next):
2002 block += next
2008 block += next
2003 lnum += 1
2009 lnum += 1
2004 try:
2010 try:
2005 next = filelines[lnum]
2011 next = filelines[lnum]
2006 except:
2012 except:
2007 next = None
2013 next = None
2008 # now execute the block of one or more lines
2014 # now execute the block of one or more lines
2009 try:
2015 try:
2010 exec block in globs,locs
2016 exec block in globs,locs
2011 self.update_cache(block.rstrip())
2017 self.update_cache(block.rstrip())
2012 except SystemExit:
2018 except SystemExit:
2013 pass
2019 pass
2014 except:
2020 except:
2015 badblocks.append(block.rstrip())
2021 badblocks.append(block.rstrip())
2016 if kw['quiet']: # restore stdout
2022 if kw['quiet']: # restore stdout
2017 sys.stdout.close()
2023 sys.stdout.close()
2018 sys.stdout = stdout_save
2024 sys.stdout = stdout_save
2019 print 'Finished replaying log file <%s>' % fname
2025 print 'Finished replaying log file <%s>' % fname
2020 if badblocks:
2026 if badblocks:
2021 print >> sys.stderr, \
2027 print >> sys.stderr, \
2022 '\nThe following lines/blocks in file <%s> reported errors:' \
2028 '\nThe following lines/blocks in file <%s> reported errors:' \
2023 % fname
2029 % fname
2024 for badline in badblocks:
2030 for badline in badblocks:
2025 print >> sys.stderr, badline
2031 print >> sys.stderr, badline
2026 else: # regular file execution
2032 else: # regular file execution
2027 try:
2033 try:
2028 execfile(fname,*where)
2034 execfile(fname,*where)
2029 except SyntaxError:
2035 except SyntaxError:
2030 etype, evalue = sys.exc_info()[0:2]
2036 etype, evalue = sys.exc_info()[0:2]
2031 self.SyntaxTB(etype,evalue,[])
2037 self.SyntaxTB(etype,evalue,[])
2032 warn('Failure executing file: <%s>' % fname)
2038 warn('Failure executing file: <%s>' % fname)
2033 except SystemExit,status:
2039 except SystemExit,status:
2034 if not kw['exit_ignore']:
2040 if not kw['exit_ignore']:
2035 self.InteractiveTB()
2041 self.InteractiveTB()
2036 warn('Failure executing file: <%s>' % fname)
2042 warn('Failure executing file: <%s>' % fname)
2037 except:
2043 except:
2038 self.InteractiveTB()
2044 self.InteractiveTB()
2039 warn('Failure executing file: <%s>' % fname)
2045 warn('Failure executing file: <%s>' % fname)
2040
2046
2041 #************************* end of file <iplib.py> *****************************
2047 #************************* end of file <iplib.py> *****************************
@@ -1,725 +1,725
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.1 or better.
5 Requires Python 2.1 or better.
6
6
7 This file contains the main make_IPython() starter function.
7 This file contains the main make_IPython() starter function.
8
8
9 $Id: ipmaker.py 638 2005-07-18 03:01:41Z fperez $"""
9 $Id: ipmaker.py 802 2005-09-06 03:49:12Z fperez $"""
10
10
11 #*****************************************************************************
11 #*****************************************************************************
12 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
12 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
13 #
13 #
14 # Distributed under the terms of the BSD License. The full license is in
14 # Distributed under the terms of the BSD License. The full license is in
15 # the file COPYING, distributed as part of this software.
15 # the file COPYING, distributed as part of this software.
16 #*****************************************************************************
16 #*****************************************************************************
17
17
18 from IPython import Release
18 from IPython import Release
19 __author__ = '%s <%s>' % Release.authors['Fernando']
19 __author__ = '%s <%s>' % Release.authors['Fernando']
20 __license__ = Release.license
20 __license__ = Release.license
21 __version__ = Release.version
21 __version__ = Release.version
22
22
23 credits._Printer__data = """
23 credits._Printer__data = """
24 Python: %s
24 Python: %s
25
25
26 IPython: Fernando Perez, Janko Hauser, Nathan Gray, and many users.
26 IPython: Fernando Perez, Janko Hauser, Nathan Gray, and many users.
27 See http://ipython.scipy.org for more information.""" \
27 See http://ipython.scipy.org for more information.""" \
28 % credits._Printer__data
28 % credits._Printer__data
29
29
30 copyright._Printer__data += """
30 copyright._Printer__data += """
31
31
32 Copyright (c) 2001-2004 Fernando Perez, Janko Hauser, Nathan Gray.
32 Copyright (c) 2001-2004 Fernando Perez, Janko Hauser, Nathan Gray.
33 All Rights Reserved."""
33 All Rights Reserved."""
34
34
35 #****************************************************************************
35 #****************************************************************************
36 # Required modules
36 # Required modules
37
37
38 # From the standard library
38 # From the standard library
39 import __main__, __builtin__
39 import __main__, __builtin__
40 import os,sys,types,re
40 import os,sys,types,re
41 from pprint import pprint,pformat
41 from pprint import pprint,pformat
42
42
43 # Our own
43 # Our own
44 from IPython import DPyGetOpt
44 from IPython import DPyGetOpt
45 from IPython.Struct import Struct
45 from IPython.Struct import Struct
46 from IPython.OutputTrap import OutputTrap
46 from IPython.OutputTrap import OutputTrap
47 from IPython.ConfigLoader import ConfigLoader
47 from IPython.ConfigLoader import ConfigLoader
48 from IPython.iplib import InteractiveShell,qw_lol,import_fail_info
48 from IPython.iplib import InteractiveShell,qw_lol,import_fail_info
49 from IPython.usage import cmd_line_usage,interactive_usage
49 from IPython.usage import cmd_line_usage,interactive_usage
50 from IPython.Prompts import CachedOutput
50 from IPython.Prompts import CachedOutput
51 from IPython.genutils import *
51 from IPython.genutils import *
52
52
53 #-----------------------------------------------------------------------------
53 #-----------------------------------------------------------------------------
54 def make_IPython(argv=None,user_ns=None,debug=1,rc_override=None,
54 def make_IPython(argv=None,user_ns=None,debug=1,rc_override=None,
55 shell_class=InteractiveShell,embedded=False,**kw):
55 shell_class=InteractiveShell,embedded=False,**kw):
56 """This is a dump of IPython into a single function.
56 """This is a dump of IPython into a single function.
57
57
58 Later it will have to be broken up in a sensible manner.
58 Later it will have to be broken up in a sensible manner.
59
59
60 Arguments:
60 Arguments:
61
61
62 - argv: a list similar to sys.argv[1:]. It should NOT contain the desired
62 - argv: a list similar to sys.argv[1:]. It should NOT contain the desired
63 script name, b/c DPyGetOpt strips the first argument only for the real
63 script name, b/c DPyGetOpt strips the first argument only for the real
64 sys.argv.
64 sys.argv.
65
65
66 - user_ns: a dict to be used as the user's namespace."""
66 - user_ns: a dict to be used as the user's namespace."""
67
67
68 #----------------------------------------------------------------------
68 #----------------------------------------------------------------------
69 # Defaults and initialization
69 # Defaults and initialization
70
70
71 # For developer debugging, deactivates crash handler and uses pdb.
71 # For developer debugging, deactivates crash handler and uses pdb.
72 DEVDEBUG = False
72 DEVDEBUG = False
73
73
74 if argv is None:
74 if argv is None:
75 argv = sys.argv
75 argv = sys.argv
76
76
77 # __IP is the main global that lives throughout and represents the whole
77 # __IP is the main global that lives throughout and represents the whole
78 # application. If the user redefines it, all bets are off as to what
78 # application. If the user redefines it, all bets are off as to what
79 # happens.
79 # happens.
80
80
81 # __IP is the name of he global which the caller will have accessible as
81 # __IP is the name of he global which the caller will have accessible as
82 # __IP.name. We set its name via the first parameter passed to
82 # __IP.name. We set its name via the first parameter passed to
83 # InteractiveShell:
83 # InteractiveShell:
84
84
85 IP = shell_class('__IP',user_ns=user_ns,**kw)
85 IP = shell_class('__IP',user_ns=user_ns,**kw)
86
86
87 # Put 'help' in the user namespace
87 # Put 'help' in the user namespace
88 from site import _Helper
88 from site import _Helper
89 IP.user_ns['help'] = _Helper()
89 IP.user_ns['help'] = _Helper()
90
90
91 if DEVDEBUG:
91 if DEVDEBUG:
92 # For developer debugging only (global flag)
92 # For developer debugging only (global flag)
93 from IPython import ultraTB
93 from IPython import ultraTB
94 sys.excepthook = ultraTB.VerboseTB(call_pdb=1)
94 sys.excepthook = ultraTB.VerboseTB(call_pdb=1)
95 else:
95 else:
96 # IPython itself shouldn't crash. This will produce a detailed
96 # IPython itself shouldn't crash. This will produce a detailed
97 # post-mortem if it does
97 # post-mortem if it does
98 from IPython import CrashHandler
98 from IPython import CrashHandler
99 sys.excepthook = CrashHandler.CrashHandler(IP)
99 sys.excepthook = CrashHandler.CrashHandler(IP)
100
100
101 IP.BANNER_PARTS = ['Python %s\n'
101 IP.BANNER_PARTS = ['Python %s\n'
102 'Type "copyright", "credits" or "license" '
102 'Type "copyright", "credits" or "license" '
103 'for more information.\n'
103 'for more information.\n'
104 % (sys.version.split('\n')[0],),
104 % (sys.version.split('\n')[0],),
105 "IPython %s -- An enhanced Interactive Python."
105 "IPython %s -- An enhanced Interactive Python."
106 % (__version__,),
106 % (__version__,),
107 """? -> Introduction to IPython's features.
107 """? -> Introduction to IPython's features.
108 %magic -> Information about IPython's 'magic' % functions.
108 %magic -> Information about IPython's 'magic' % functions.
109 help -> Python's own help system.
109 help -> Python's own help system.
110 object? -> Details about 'object'. ?object also works, ?? prints more.
110 object? -> Details about 'object'. ?object also works, ?? prints more.
111 """ ]
111 """ ]
112
112
113 IP.usage = interactive_usage
113 IP.usage = interactive_usage
114
114
115 # Platform-dependent suffix and directory names
115 # Platform-dependent suffix and directory names
116 if os.name == 'posix':
116 if os.name == 'posix':
117 rc_suffix = ''
117 rc_suffix = ''
118 ipdir_def = '.ipython'
118 ipdir_def = '.ipython'
119 else:
119 else:
120 rc_suffix = '.ini'
120 rc_suffix = '.ini'
121 ipdir_def = '_ipython'
121 ipdir_def = '_ipython'
122
122
123 # default directory for configuration
123 # default directory for configuration
124 ipythondir = os.path.abspath(os.environ.get('IPYTHONDIR',
124 ipythondir = os.path.abspath(os.environ.get('IPYTHONDIR',
125 os.path.join(IP.home_dir,ipdir_def)))
125 os.path.join(IP.home_dir,ipdir_def)))
126
126
127 # we need the directory where IPython itself is installed
127 # we need the directory where IPython itself is installed
128 import IPython
128 import IPython
129 IPython_dir = os.path.dirname(IPython.__file__)
129 IPython_dir = os.path.dirname(IPython.__file__)
130 del IPython
130 del IPython
131
131
132 #-------------------------------------------------------------------------
132 #-------------------------------------------------------------------------
133 # Command line handling
133 # Command line handling
134
134
135 # Valid command line options (uses DPyGetOpt syntax, like Perl's
135 # Valid command line options (uses DPyGetOpt syntax, like Perl's
136 # GetOpt::Long)
136 # GetOpt::Long)
137
137
138 # Any key not listed here gets deleted even if in the file (like session
138 # Any key not listed here gets deleted even if in the file (like session
139 # or profile). That's deliberate, to maintain the rc namespace clean.
139 # or profile). That's deliberate, to maintain the rc namespace clean.
140
140
141 # Each set of options appears twice: under _conv only the names are
141 # Each set of options appears twice: under _conv only the names are
142 # listed, indicating which type they must be converted to when reading the
142 # listed, indicating which type they must be converted to when reading the
143 # ipythonrc file. And under DPyGetOpt they are listed with the regular
143 # ipythonrc file. And under DPyGetOpt they are listed with the regular
144 # DPyGetOpt syntax (=s,=i,:f,etc).
144 # DPyGetOpt syntax (=s,=i,:f,etc).
145
145
146 # Make sure there's a space before each end of line (they get auto-joined!)
146 # Make sure there's a space before each end of line (they get auto-joined!)
147 cmdline_opts = ('autocall! autoindent! automagic! banner! cache_size|cs=i '
147 cmdline_opts = ('autocall! autoindent! automagic! banner! cache_size|cs=i '
148 'c=s classic|cl color_info! colors=s confirm_exit! '
148 'c=s classic|cl color_info! colors=s confirm_exit! '
149 'debug! deep_reload! editor=s log|l messages! nosep pdb! '
149 'debug! deep_reload! editor=s log|l messages! nosep pdb! '
150 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s '
150 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s '
151 'quick screen_length|sl=i prompts_pad_left=i '
151 'quick screen_length|sl=i prompts_pad_left=i '
152 'logfile|lf=s logplay|lp=s profile|p=s '
152 'logfile|lf=s logplay|lp=s profile|p=s '
153 'readline! readline_merge_completions! '
153 'readline! readline_merge_completions! '
154 'readline_omit__names! '
154 'readline_omit__names! '
155 'rcfile=s separate_in|si=s separate_out|so=s '
155 'rcfile=s separate_in|si=s separate_out|so=s '
156 'separate_out2|so2=s xmode=s '
156 'separate_out2|so2=s xmode=s '
157 'magic_docstrings system_verbose! '
157 'magic_docstrings system_verbose! '
158 'multi_line_specials!')
158 'multi_line_specials!')
159
159
160 # Options that can *only* appear at the cmd line (not in rcfiles).
160 # Options that can *only* appear at the cmd line (not in rcfiles).
161
161
162 # The "ignore" option is a kludge so that Emacs buffers don't crash, since
162 # The "ignore" option is a kludge so that Emacs buffers don't crash, since
163 # the 'C-c !' command in emacs automatically appends a -i option at the end.
163 # the 'C-c !' command in emacs automatically appends a -i option at the end.
164 cmdline_only = ('help ignore|i ipythondir=s Version upgrade '
164 cmdline_only = ('help ignore|i ipythondir=s Version upgrade '
165 'gthread! qthread! wthread! pylab! tk!')
165 'gthread! qthread! wthread! pylab! tk!')
166
166
167 # Build the actual name list to be used by DPyGetOpt
167 # Build the actual name list to be used by DPyGetOpt
168 opts_names = qw(cmdline_opts) + qw(cmdline_only)
168 opts_names = qw(cmdline_opts) + qw(cmdline_only)
169
169
170 # Set sensible command line defaults.
170 # Set sensible command line defaults.
171 # This should have everything from cmdline_opts and cmdline_only
171 # This should have everything from cmdline_opts and cmdline_only
172 opts_def = Struct(autocall = 1,
172 opts_def = Struct(autocall = 1,
173 autoindent=0,
173 autoindent=0,
174 automagic = 1,
174 automagic = 1,
175 banner = 1,
175 banner = 1,
176 cache_size = 1000,
176 cache_size = 1000,
177 c = '',
177 c = '',
178 classic = 0,
178 classic = 0,
179 colors = 'NoColor',
179 colors = 'NoColor',
180 color_info = 0,
180 color_info = 0,
181 confirm_exit = 1,
181 confirm_exit = 1,
182 debug = 0,
182 debug = 0,
183 deep_reload = 0,
183 deep_reload = 0,
184 editor = '0',
184 editor = '0',
185 help = 0,
185 help = 0,
186 ignore = 0,
186 ignore = 0,
187 ipythondir = ipythondir,
187 ipythondir = ipythondir,
188 log = 0,
188 log = 0,
189 logfile = '',
189 logfile = '',
190 logplay = '',
190 logplay = '',
191 multi_line_specials = 1,
191 multi_line_specials = 1,
192 messages = 1,
192 messages = 1,
193 nosep = 0,
193 nosep = 0,
194 pdb = 0,
194 pdb = 0,
195 pprint = 0,
195 pprint = 0,
196 profile = '',
196 profile = '',
197 prompt_in1 = 'In [\\#]:',
197 prompt_in1 = 'In [\\#]: ',
198 prompt_in2 = ' .\\D.:',
198 prompt_in2 = ' .\\D.: ',
199 prompt_out = 'Out[\\#]:',
199 prompt_out = 'Out[\\#]: ',
200 prompts_pad_left = 1,
200 prompts_pad_left = 1,
201 quick = 0,
201 quick = 0,
202 readline = 1,
202 readline = 1,
203 readline_merge_completions = 1,
203 readline_merge_completions = 1,
204 readline_omit__names = 0,
204 readline_omit__names = 0,
205 rcfile = 'ipythonrc' + rc_suffix,
205 rcfile = 'ipythonrc' + rc_suffix,
206 screen_length = 0,
206 screen_length = 0,
207 separate_in = '\n',
207 separate_in = '\n',
208 separate_out = '\n',
208 separate_out = '\n',
209 separate_out2 = '',
209 separate_out2 = '',
210 system_verbose = 0,
210 system_verbose = 0,
211 gthread = 0,
211 gthread = 0,
212 qthread = 0,
212 qthread = 0,
213 wthread = 0,
213 wthread = 0,
214 pylab = 0,
214 pylab = 0,
215 tk = 0,
215 tk = 0,
216 upgrade = 0,
216 upgrade = 0,
217 Version = 0,
217 Version = 0,
218 xmode = 'Verbose',
218 xmode = 'Verbose',
219 magic_docstrings = 0, # undocumented, for doc generation
219 magic_docstrings = 0, # undocumented, for doc generation
220 )
220 )
221
221
222 # Things that will *only* appear in rcfiles (not at the command line).
222 # Things that will *only* appear in rcfiles (not at the command line).
223 # Make sure there's a space before each end of line (they get auto-joined!)
223 # Make sure there's a space before each end of line (they get auto-joined!)
224 rcfile_opts = { qwflat: 'include import_mod import_all execfile ',
224 rcfile_opts = { qwflat: 'include import_mod import_all execfile ',
225 qw_lol: 'import_some ',
225 qw_lol: 'import_some ',
226 # for things with embedded whitespace:
226 # for things with embedded whitespace:
227 list_strings:'execute alias readline_parse_and_bind ',
227 list_strings:'execute alias readline_parse_and_bind ',
228 # Regular strings need no conversion:
228 # Regular strings need no conversion:
229 None:'readline_remove_delims ',
229 None:'readline_remove_delims ',
230 }
230 }
231 # Default values for these
231 # Default values for these
232 rc_def = Struct(include = [],
232 rc_def = Struct(include = [],
233 import_mod = [],
233 import_mod = [],
234 import_all = [],
234 import_all = [],
235 import_some = [[]],
235 import_some = [[]],
236 execute = [],
236 execute = [],
237 execfile = [],
237 execfile = [],
238 alias = [],
238 alias = [],
239 readline_parse_and_bind = [],
239 readline_parse_and_bind = [],
240 readline_remove_delims = '',
240 readline_remove_delims = '',
241 )
241 )
242
242
243 # Build the type conversion dictionary from the above tables:
243 # Build the type conversion dictionary from the above tables:
244 typeconv = rcfile_opts.copy()
244 typeconv = rcfile_opts.copy()
245 typeconv.update(optstr2types(cmdline_opts))
245 typeconv.update(optstr2types(cmdline_opts))
246
246
247 # FIXME: the None key appears in both, put that back together by hand. Ugly!
247 # FIXME: the None key appears in both, put that back together by hand. Ugly!
248 typeconv[None] += ' ' + rcfile_opts[None]
248 typeconv[None] += ' ' + rcfile_opts[None]
249
249
250 # Remove quotes at ends of all strings (used to protect spaces)
250 # Remove quotes at ends of all strings (used to protect spaces)
251 typeconv[unquote_ends] = typeconv[None]
251 typeconv[unquote_ends] = typeconv[None]
252 del typeconv[None]
252 del typeconv[None]
253
253
254 # Build the list we'll use to make all config decisions with defaults:
254 # Build the list we'll use to make all config decisions with defaults:
255 opts_all = opts_def.copy()
255 opts_all = opts_def.copy()
256 opts_all.update(rc_def)
256 opts_all.update(rc_def)
257
257
258 # Build conflict resolver for recursive loading of config files:
258 # Build conflict resolver for recursive loading of config files:
259 # - preserve means the outermost file maintains the value, it is not
259 # - preserve means the outermost file maintains the value, it is not
260 # overwritten if an included file has the same key.
260 # overwritten if an included file has the same key.
261 # - add_flip applies + to the two values, so it better make sense to add
261 # - add_flip applies + to the two values, so it better make sense to add
262 # those types of keys. But it flips them first so that things loaded
262 # those types of keys. But it flips them first so that things loaded
263 # deeper in the inclusion chain have lower precedence.
263 # deeper in the inclusion chain have lower precedence.
264 conflict = {'preserve': ' '.join([ typeconv[int],
264 conflict = {'preserve': ' '.join([ typeconv[int],
265 typeconv[unquote_ends] ]),
265 typeconv[unquote_ends] ]),
266 'add_flip': ' '.join([ typeconv[qwflat],
266 'add_flip': ' '.join([ typeconv[qwflat],
267 typeconv[qw_lol],
267 typeconv[qw_lol],
268 typeconv[list_strings] ])
268 typeconv[list_strings] ])
269 }
269 }
270
270
271 # Now actually process the command line
271 # Now actually process the command line
272 getopt = DPyGetOpt.DPyGetOpt()
272 getopt = DPyGetOpt.DPyGetOpt()
273 getopt.setIgnoreCase(0)
273 getopt.setIgnoreCase(0)
274
274
275 getopt.parseConfiguration(opts_names)
275 getopt.parseConfiguration(opts_names)
276
276
277 try:
277 try:
278 getopt.processArguments(argv)
278 getopt.processArguments(argv)
279 except:
279 except:
280 print cmd_line_usage
280 print cmd_line_usage
281 warn('\nError in Arguments: ' + `sys.exc_value`)
281 warn('\nError in Arguments: ' + `sys.exc_value`)
282 sys.exit()
282 sys.exit()
283
283
284 # convert the options dict to a struct for much lighter syntax later
284 # convert the options dict to a struct for much lighter syntax later
285 opts = Struct(getopt.optionValues)
285 opts = Struct(getopt.optionValues)
286 args = getopt.freeValues
286 args = getopt.freeValues
287
287
288 # this is the struct (which has default values at this point) with which
288 # this is the struct (which has default values at this point) with which
289 # we make all decisions:
289 # we make all decisions:
290 opts_all.update(opts)
290 opts_all.update(opts)
291
291
292 # Options that force an immediate exit
292 # Options that force an immediate exit
293 if opts_all.help:
293 if opts_all.help:
294 page(cmd_line_usage)
294 page(cmd_line_usage)
295 sys.exit()
295 sys.exit()
296
296
297 if opts_all.Version:
297 if opts_all.Version:
298 print __version__
298 print __version__
299 sys.exit()
299 sys.exit()
300
300
301 if opts_all.magic_docstrings:
301 if opts_all.magic_docstrings:
302 IP.magic_magic('-latex')
302 IP.magic_magic('-latex')
303 sys.exit()
303 sys.exit()
304
304
305 # Create user config directory if it doesn't exist. This must be done
305 # Create user config directory if it doesn't exist. This must be done
306 # *after* getting the cmd line options.
306 # *after* getting the cmd line options.
307 if not os.path.isdir(opts_all.ipythondir):
307 if not os.path.isdir(opts_all.ipythondir):
308 IP.user_setup(opts_all.ipythondir,rc_suffix,'install')
308 IP.user_setup(opts_all.ipythondir,rc_suffix,'install')
309
309
310 # upgrade user config files while preserving a copy of the originals
310 # upgrade user config files while preserving a copy of the originals
311 if opts_all.upgrade:
311 if opts_all.upgrade:
312 IP.user_setup(opts_all.ipythondir,rc_suffix,'upgrade')
312 IP.user_setup(opts_all.ipythondir,rc_suffix,'upgrade')
313
313
314 # check mutually exclusive options in the *original* command line
314 # check mutually exclusive options in the *original* command line
315 mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'),
315 mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'),
316 qw('classic profile'),qw('classic rcfile')])
316 qw('classic profile'),qw('classic rcfile')])
317
317
318 # default logfilename used when -log is called.
318 # default logfilename used when -log is called.
319 IP.LOGDEF = 'ipython.log'
319 IP.LOGDEF = 'ipython.log'
320
320
321 #---------------------------------------------------------------------------
321 #---------------------------------------------------------------------------
322 # Log replay
322 # Log replay
323
323
324 # if -logplay, we need to 'become' the other session. That basically means
324 # if -logplay, we need to 'become' the other session. That basically means
325 # replacing the current command line environment with that of the old
325 # replacing the current command line environment with that of the old
326 # session and moving on.
326 # session and moving on.
327
327
328 # this is needed so that later we know we're in session reload mode, as
328 # this is needed so that later we know we're in session reload mode, as
329 # opts_all will get overwritten:
329 # opts_all will get overwritten:
330 load_logplay = 0
330 load_logplay = 0
331
331
332 if opts_all.logplay:
332 if opts_all.logplay:
333 load_logplay = opts_all.logplay
333 load_logplay = opts_all.logplay
334 opts_debug_save = opts_all.debug
334 opts_debug_save = opts_all.debug
335 try:
335 try:
336 logplay = open(opts_all.logplay)
336 logplay = open(opts_all.logplay)
337 except IOError:
337 except IOError:
338 if opts_all.debug: IP.InteractiveTB()
338 if opts_all.debug: IP.InteractiveTB()
339 warn('Could not open logplay file '+`opts_all.logplay`)
339 warn('Could not open logplay file '+`opts_all.logplay`)
340 # restore state as if nothing had happened and move on, but make
340 # restore state as if nothing had happened and move on, but make
341 # sure that later we don't try to actually load the session file
341 # sure that later we don't try to actually load the session file
342 logplay = None
342 logplay = None
343 load_logplay = 0
343 load_logplay = 0
344 del opts_all.logplay
344 del opts_all.logplay
345 else:
345 else:
346 try:
346 try:
347 logplay.readline()
347 logplay.readline()
348 logplay.readline();
348 logplay.readline();
349 # this reloads that session's command line
349 # this reloads that session's command line
350 cmd = logplay.readline()[6:]
350 cmd = logplay.readline()[6:]
351 exec cmd
351 exec cmd
352 # restore the true debug flag given so that the process of
352 # restore the true debug flag given so that the process of
353 # session loading itself can be monitored.
353 # session loading itself can be monitored.
354 opts.debug = opts_debug_save
354 opts.debug = opts_debug_save
355 # save the logplay flag so later we don't overwrite the log
355 # save the logplay flag so later we don't overwrite the log
356 opts.logplay = load_logplay
356 opts.logplay = load_logplay
357 # now we must update our own structure with defaults
357 # now we must update our own structure with defaults
358 opts_all.update(opts)
358 opts_all.update(opts)
359 # now load args
359 # now load args
360 cmd = logplay.readline()[6:]
360 cmd = logplay.readline()[6:]
361 exec cmd
361 exec cmd
362 logplay.close()
362 logplay.close()
363 except:
363 except:
364 logplay.close()
364 logplay.close()
365 if opts_all.debug: IP.InteractiveTB()
365 if opts_all.debug: IP.InteractiveTB()
366 warn("Logplay file lacking full configuration information.\n"
366 warn("Logplay file lacking full configuration information.\n"
367 "I'll try to read it, but some things may not work.")
367 "I'll try to read it, but some things may not work.")
368
368
369 #-------------------------------------------------------------------------
369 #-------------------------------------------------------------------------
370 # set up output traps: catch all output from files, being run, modules
370 # set up output traps: catch all output from files, being run, modules
371 # loaded, etc. Then give it to the user in a clean form at the end.
371 # loaded, etc. Then give it to the user in a clean form at the end.
372
372
373 msg_out = 'Output messages. '
373 msg_out = 'Output messages. '
374 msg_err = 'Error messages. '
374 msg_err = 'Error messages. '
375 msg_sep = '\n'
375 msg_sep = '\n'
376 msg = Struct(config = OutputTrap('Configuration Loader',msg_out,
376 msg = Struct(config = OutputTrap('Configuration Loader',msg_out,
377 msg_err,msg_sep,debug,
377 msg_err,msg_sep,debug,
378 quiet_out=1),
378 quiet_out=1),
379 user_exec = OutputTrap('User File Execution',msg_out,
379 user_exec = OutputTrap('User File Execution',msg_out,
380 msg_err,msg_sep,debug),
380 msg_err,msg_sep,debug),
381 logplay = OutputTrap('Log Loader',msg_out,
381 logplay = OutputTrap('Log Loader',msg_out,
382 msg_err,msg_sep,debug),
382 msg_err,msg_sep,debug),
383 summary = ''
383 summary = ''
384 )
384 )
385
385
386 #-------------------------------------------------------------------------
386 #-------------------------------------------------------------------------
387 # Process user ipythonrc-type configuration files
387 # Process user ipythonrc-type configuration files
388
388
389 # turn on output trapping and log to msg.config
389 # turn on output trapping and log to msg.config
390 # remember that with debug on, trapping is actually disabled
390 # remember that with debug on, trapping is actually disabled
391 msg.config.trap_all()
391 msg.config.trap_all()
392
392
393 # look for rcfile in current or default directory
393 # look for rcfile in current or default directory
394 try:
394 try:
395 opts_all.rcfile = filefind(opts_all.rcfile,opts_all.ipythondir)
395 opts_all.rcfile = filefind(opts_all.rcfile,opts_all.ipythondir)
396 except IOError:
396 except IOError:
397 if opts_all.debug: IP.InteractiveTB()
397 if opts_all.debug: IP.InteractiveTB()
398 warn('Configuration file %s not found. Ignoring request.'
398 warn('Configuration file %s not found. Ignoring request.'
399 % (opts_all.rcfile) )
399 % (opts_all.rcfile) )
400
400
401 # 'profiles' are a shorthand notation for config filenames
401 # 'profiles' are a shorthand notation for config filenames
402 if opts_all.profile:
402 if opts_all.profile:
403 try:
403 try:
404 opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile
404 opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile
405 + rc_suffix,
405 + rc_suffix,
406 opts_all.ipythondir)
406 opts_all.ipythondir)
407 except IOError:
407 except IOError:
408 if opts_all.debug: IP.InteractiveTB()
408 if opts_all.debug: IP.InteractiveTB()
409 opts.profile = '' # remove profile from options if invalid
409 opts.profile = '' # remove profile from options if invalid
410 warn('Profile configuration file %s not found. Ignoring request.'
410 warn('Profile configuration file %s not found. Ignoring request.'
411 % (opts_all.profile) )
411 % (opts_all.profile) )
412
412
413 # load the config file
413 # load the config file
414 rcfiledata = None
414 rcfiledata = None
415 if opts_all.quick:
415 if opts_all.quick:
416 print 'Launching IPython in quick mode. No config file read.'
416 print 'Launching IPython in quick mode. No config file read.'
417 elif opts_all.classic:
417 elif opts_all.classic:
418 print 'Launching IPython in classic mode. No config file read.'
418 print 'Launching IPython in classic mode. No config file read.'
419 elif opts_all.rcfile:
419 elif opts_all.rcfile:
420 try:
420 try:
421 cfg_loader = ConfigLoader(conflict)
421 cfg_loader = ConfigLoader(conflict)
422 rcfiledata = cfg_loader.load(opts_all.rcfile,typeconv,
422 rcfiledata = cfg_loader.load(opts_all.rcfile,typeconv,
423 'include',opts_all.ipythondir,
423 'include',opts_all.ipythondir,
424 purge = 1,
424 purge = 1,
425 unique = conflict['preserve'])
425 unique = conflict['preserve'])
426 except:
426 except:
427 IP.InteractiveTB()
427 IP.InteractiveTB()
428 warn('Problems loading configuration file '+
428 warn('Problems loading configuration file '+
429 `opts_all.rcfile`+
429 `opts_all.rcfile`+
430 '\nStarting with default -bare bones- configuration.')
430 '\nStarting with default -bare bones- configuration.')
431 else:
431 else:
432 warn('No valid configuration file found in either currrent directory\n'+
432 warn('No valid configuration file found in either currrent directory\n'+
433 'or in the IPython config. directory: '+`opts_all.ipythondir`+
433 'or in the IPython config. directory: '+`opts_all.ipythondir`+
434 '\nProceeding with internal defaults.')
434 '\nProceeding with internal defaults.')
435
435
436 #------------------------------------------------------------------------
436 #------------------------------------------------------------------------
437 # Set exception handlers in mode requested by user.
437 # Set exception handlers in mode requested by user.
438 otrap = OutputTrap(trap_out=1) # trap messages from magic_xmode
438 otrap = OutputTrap(trap_out=1) # trap messages from magic_xmode
439 IP.magic_xmode(opts_all.xmode)
439 IP.magic_xmode(opts_all.xmode)
440 otrap.release_out()
440 otrap.release_out()
441
441
442 #------------------------------------------------------------------------
442 #------------------------------------------------------------------------
443 # Execute user config
443 # Execute user config
444
444
445 # first, create a valid config structure with the right precedence order:
445 # first, create a valid config structure with the right precedence order:
446 # defaults < rcfile < command line
446 # defaults < rcfile < command line
447 IP.rc = rc_def.copy()
447 IP.rc = rc_def.copy()
448 IP.rc.update(opts_def)
448 IP.rc.update(opts_def)
449 if rcfiledata:
449 if rcfiledata:
450 # now we can update
450 # now we can update
451 IP.rc.update(rcfiledata)
451 IP.rc.update(rcfiledata)
452 IP.rc.update(opts)
452 IP.rc.update(opts)
453 IP.rc.update(rc_override)
453 IP.rc.update(rc_override)
454
454
455 # Store the original cmd line for reference:
455 # Store the original cmd line for reference:
456 IP.rc.opts = opts
456 IP.rc.opts = opts
457 IP.rc.args = args
457 IP.rc.args = args
458
458
459 # create a *runtime* Struct like rc for holding parameters which may be
459 # create a *runtime* Struct like rc for holding parameters which may be
460 # created and/or modified by runtime user extensions.
460 # created and/or modified by runtime user extensions.
461 IP.runtime_rc = Struct()
461 IP.runtime_rc = Struct()
462
462
463 # from this point on, all config should be handled through IP.rc,
463 # from this point on, all config should be handled through IP.rc,
464 # opts* shouldn't be used anymore.
464 # opts* shouldn't be used anymore.
465
465
466 # add personal .ipython dir to sys.path so that users can put things in
466 # add personal .ipython dir to sys.path so that users can put things in
467 # there for customization
467 # there for customization
468 sys.path.append(IP.rc.ipythondir)
468 sys.path.append(IP.rc.ipythondir)
469 sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran
469 sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran
470
470
471 # update IP.rc with some special things that need manual
471 # update IP.rc with some special things that need manual
472 # tweaks. Basically options which affect other options. I guess this
472 # tweaks. Basically options which affect other options. I guess this
473 # should just be written so that options are fully orthogonal and we
473 # should just be written so that options are fully orthogonal and we
474 # wouldn't worry about this stuff!
474 # wouldn't worry about this stuff!
475
475
476 if IP.rc.classic:
476 if IP.rc.classic:
477 IP.rc.quick = 1
477 IP.rc.quick = 1
478 IP.rc.cache_size = 0
478 IP.rc.cache_size = 0
479 IP.rc.pprint = 0
479 IP.rc.pprint = 0
480 IP.rc.prompt_in1 = '>>> '
480 IP.rc.prompt_in1 = '>>> '
481 IP.rc.prompt_in2 = '... '
481 IP.rc.prompt_in2 = '... '
482 IP.rc.prompt_out = ''
482 IP.rc.prompt_out = ''
483 IP.rc.separate_in = IP.rc.separate_out = IP.rc.separate_out2 = '0'
483 IP.rc.separate_in = IP.rc.separate_out = IP.rc.separate_out2 = '0'
484 IP.rc.colors = 'NoColor'
484 IP.rc.colors = 'NoColor'
485 IP.rc.xmode = 'Plain'
485 IP.rc.xmode = 'Plain'
486
486
487 # configure readline
487 # configure readline
488 # Define the history file for saving commands in between sessions
488 # Define the history file for saving commands in between sessions
489 if IP.rc.profile:
489 if IP.rc.profile:
490 histfname = 'history-%s' % IP.rc.profile
490 histfname = 'history-%s' % IP.rc.profile
491 else:
491 else:
492 histfname = 'history'
492 histfname = 'history'
493 IP.histfile = os.path.join(opts_all.ipythondir,histfname)
493 IP.histfile = os.path.join(opts_all.ipythondir,histfname)
494 # Load readline proper
494 # Load readline proper
495 if IP.rc.readline:
495 if IP.rc.readline:
496 IP.init_readline()
496 IP.init_readline()
497
497
498 # update exception handlers with rc file status
498 # update exception handlers with rc file status
499 otrap.trap_out() # I don't want these messages ever.
499 otrap.trap_out() # I don't want these messages ever.
500 IP.magic_xmode(IP.rc.xmode)
500 IP.magic_xmode(IP.rc.xmode)
501 otrap.release_out()
501 otrap.release_out()
502
502
503 # activate logging if requested and not reloading a log
503 # activate logging if requested and not reloading a log
504 if IP.rc.logplay:
504 if IP.rc.logplay:
505 IP.magic_logstart(IP.rc.logplay + ' append')
505 IP.magic_logstart(IP.rc.logplay + ' append')
506 elif IP.rc.logfile:
506 elif IP.rc.logfile:
507 IP.magic_logstart(IP.rc.logfile)
507 IP.magic_logstart(IP.rc.logfile)
508 elif IP.rc.log:
508 elif IP.rc.log:
509 IP.magic_logstart()
509 IP.magic_logstart()
510
510
511 # find user editor so that it we don't have to look it up constantly
511 # find user editor so that it we don't have to look it up constantly
512 if IP.rc.editor.strip()=='0':
512 if IP.rc.editor.strip()=='0':
513 try:
513 try:
514 ed = os.environ['EDITOR']
514 ed = os.environ['EDITOR']
515 except KeyError:
515 except KeyError:
516 if os.name == 'posix':
516 if os.name == 'posix':
517 ed = 'vi' # the only one guaranteed to be there!
517 ed = 'vi' # the only one guaranteed to be there!
518 else:
518 else:
519 ed = 'notepad' # same in Windows!
519 ed = 'notepad' # same in Windows!
520 IP.rc.editor = ed
520 IP.rc.editor = ed
521
521
522 # Recursive reload
522 # Recursive reload
523 try:
523 try:
524 from IPython import deep_reload
524 from IPython import deep_reload
525 if IP.rc.deep_reload:
525 if IP.rc.deep_reload:
526 __builtin__.reload = deep_reload.reload
526 __builtin__.reload = deep_reload.reload
527 else:
527 else:
528 __builtin__.dreload = deep_reload.reload
528 __builtin__.dreload = deep_reload.reload
529 del deep_reload
529 del deep_reload
530 except ImportError:
530 except ImportError:
531 pass
531 pass
532
532
533 # Save the current state of our namespace so that the interactive shell
533 # Save the current state of our namespace so that the interactive shell
534 # can later know which variables have been created by us from config files
534 # can later know which variables have been created by us from config files
535 # and loading. This way, loading a file (in any way) is treated just like
535 # and loading. This way, loading a file (in any way) is treated just like
536 # defining things on the command line, and %who works as expected.
536 # defining things on the command line, and %who works as expected.
537
537
538 # DON'T do anything that affects the namespace beyond this point!
538 # DON'T do anything that affects the namespace beyond this point!
539 IP.internal_ns = __main__.__dict__.copy()
539 IP.internal_ns = __main__.__dict__.copy()
540
540
541 #IP.internal_ns.update(locals()) # so our stuff doesn't show up in %who
541 #IP.internal_ns.update(locals()) # so our stuff doesn't show up in %who
542
542
543 # Now run through the different sections of the users's config
543 # Now run through the different sections of the users's config
544 if IP.rc.debug:
544 if IP.rc.debug:
545 print 'Trying to execute the following configuration structure:'
545 print 'Trying to execute the following configuration structure:'
546 print '(Things listed first are deeper in the inclusion tree and get'
546 print '(Things listed first are deeper in the inclusion tree and get'
547 print 'loaded first).\n'
547 print 'loaded first).\n'
548 pprint(IP.rc.__dict__)
548 pprint(IP.rc.__dict__)
549
549
550 for mod in IP.rc.import_mod:
550 for mod in IP.rc.import_mod:
551 try:
551 try:
552 exec 'import '+mod in IP.user_ns
552 exec 'import '+mod in IP.user_ns
553 except :
553 except :
554 IP.InteractiveTB()
554 IP.InteractiveTB()
555 import_fail_info(mod)
555 import_fail_info(mod)
556
556
557 for mod_fn in IP.rc.import_some:
557 for mod_fn in IP.rc.import_some:
558 if mod_fn == []: break
558 if mod_fn == []: break
559 mod,fn = mod_fn[0],','.join(mod_fn[1:])
559 mod,fn = mod_fn[0],','.join(mod_fn[1:])
560 try:
560 try:
561 exec 'from '+mod+' import '+fn in IP.user_ns
561 exec 'from '+mod+' import '+fn in IP.user_ns
562 except :
562 except :
563 IP.InteractiveTB()
563 IP.InteractiveTB()
564 import_fail_info(mod,fn)
564 import_fail_info(mod,fn)
565
565
566 for mod in IP.rc.import_all:
566 for mod in IP.rc.import_all:
567 try:
567 try:
568 exec 'from '+mod+' import *' in IP.user_ns
568 exec 'from '+mod+' import *' in IP.user_ns
569 except :
569 except :
570 IP.InteractiveTB()
570 IP.InteractiveTB()
571 import_fail_info(mod)
571 import_fail_info(mod)
572
572
573 for code in IP.rc.execute:
573 for code in IP.rc.execute:
574 try:
574 try:
575 exec code in IP.user_ns
575 exec code in IP.user_ns
576 except:
576 except:
577 IP.InteractiveTB()
577 IP.InteractiveTB()
578 warn('Failure executing code: ' + `code`)
578 warn('Failure executing code: ' + `code`)
579
579
580 # Execute the files the user wants in ipythonrc
580 # Execute the files the user wants in ipythonrc
581 for file in IP.rc.execfile:
581 for file in IP.rc.execfile:
582 try:
582 try:
583 file = filefind(file,sys.path+[IPython_dir])
583 file = filefind(file,sys.path+[IPython_dir])
584 except IOError:
584 except IOError:
585 warn(itpl('File $file not found. Skipping it.'))
585 warn(itpl('File $file not found. Skipping it.'))
586 else:
586 else:
587 IP.safe_execfile(os.path.expanduser(file),IP.user_ns)
587 IP.safe_execfile(os.path.expanduser(file),IP.user_ns)
588
588
589 # Load user aliases
589 # Load user aliases
590 for alias in IP.rc.alias:
590 for alias in IP.rc.alias:
591 IP.magic_alias(alias)
591 IP.magic_alias(alias)
592
592
593 # release stdout and stderr and save config log into a global summary
593 # release stdout and stderr and save config log into a global summary
594 msg.config.release_all()
594 msg.config.release_all()
595 if IP.rc.messages:
595 if IP.rc.messages:
596 msg.summary += msg.config.summary_all()
596 msg.summary += msg.config.summary_all()
597
597
598 #------------------------------------------------------------------------
598 #------------------------------------------------------------------------
599 # Setup interactive session
599 # Setup interactive session
600
600
601 # Now we should be fully configured. We can then execute files or load
601 # Now we should be fully configured. We can then execute files or load
602 # things only needed for interactive use. Then we'll open the shell.
602 # things only needed for interactive use. Then we'll open the shell.
603
603
604 # Take a snapshot of the user namespace before opening the shell. That way
604 # Take a snapshot of the user namespace before opening the shell. That way
605 # we'll be able to identify which things were interactively defined and
605 # we'll be able to identify which things were interactively defined and
606 # which were defined through config files.
606 # which were defined through config files.
607 IP.user_config_ns = IP.user_ns.copy()
607 IP.user_config_ns = IP.user_ns.copy()
608
608
609 # Force reading a file as if it were a session log. Slower but safer.
609 # Force reading a file as if it were a session log. Slower but safer.
610 if load_logplay:
610 if load_logplay:
611 print 'Replaying log...'
611 print 'Replaying log...'
612 try:
612 try:
613 if IP.rc.debug:
613 if IP.rc.debug:
614 logplay_quiet = 0
614 logplay_quiet = 0
615 else:
615 else:
616 logplay_quiet = 1
616 logplay_quiet = 1
617
617
618 msg.logplay.trap_all()
618 msg.logplay.trap_all()
619 IP.safe_execfile(load_logplay,IP.user_ns,
619 IP.safe_execfile(load_logplay,IP.user_ns,
620 islog = 1, quiet = logplay_quiet)
620 islog = 1, quiet = logplay_quiet)
621 msg.logplay.release_all()
621 msg.logplay.release_all()
622 if IP.rc.messages:
622 if IP.rc.messages:
623 msg.summary += msg.logplay.summary_all()
623 msg.summary += msg.logplay.summary_all()
624 except:
624 except:
625 warn('Problems replaying logfile %s.' % load_logplay)
625 warn('Problems replaying logfile %s.' % load_logplay)
626 IP.InteractiveTB()
626 IP.InteractiveTB()
627
627
628 # Load remaining files in command line
628 # Load remaining files in command line
629 msg.user_exec.trap_all()
629 msg.user_exec.trap_all()
630
630
631 # Do NOT execute files named in the command line as scripts to be loaded
631 # Do NOT execute files named in the command line as scripts to be loaded
632 # by embedded instances. Doing so has the potential for an infinite
632 # by embedded instances. Doing so has the potential for an infinite
633 # recursion if there are exceptions thrown in the process.
633 # recursion if there are exceptions thrown in the process.
634
634
635 # XXX FIXME: the execution of user files should be moved out to after
635 # XXX FIXME: the execution of user files should be moved out to after
636 # ipython is fully initialized, just as if they were run via %run at the
636 # ipython is fully initialized, just as if they were run via %run at the
637 # ipython prompt. This would also give them the benefit of ipython's
637 # ipython prompt. This would also give them the benefit of ipython's
638 # nice tracebacks.
638 # nice tracebacks.
639
639
640 if not embedded and IP.rc.args:
640 if not embedded and IP.rc.args:
641 name_save = IP.user_ns['__name__']
641 name_save = IP.user_ns['__name__']
642 IP.user_ns['__name__'] = '__main__'
642 IP.user_ns['__name__'] = '__main__'
643 try:
643 try:
644 # Set our own excepthook in case the user code tries to call it
644 # Set our own excepthook in case the user code tries to call it
645 # directly. This prevents triggering the IPython crash handler.
645 # directly. This prevents triggering the IPython crash handler.
646 old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook
646 old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook
647 for run in args:
647 for run in args:
648 IP.safe_execfile(run,IP.user_ns)
648 IP.safe_execfile(run,IP.user_ns)
649 finally:
649 finally:
650 # Reset our crash handler in place
650 # Reset our crash handler in place
651 sys.excepthook = old_excepthook
651 sys.excepthook = old_excepthook
652
652
653 IP.user_ns['__name__'] = name_save
653 IP.user_ns['__name__'] = name_save
654
654
655 msg.user_exec.release_all()
655 msg.user_exec.release_all()
656 if IP.rc.messages:
656 if IP.rc.messages:
657 msg.summary += msg.user_exec.summary_all()
657 msg.summary += msg.user_exec.summary_all()
658
658
659 # since we can't specify a null string on the cmd line, 0 is the equivalent:
659 # since we can't specify a null string on the cmd line, 0 is the equivalent:
660 if IP.rc.nosep:
660 if IP.rc.nosep:
661 IP.rc.separate_in = IP.rc.separate_out = IP.rc.separate_out2 = '0'
661 IP.rc.separate_in = IP.rc.separate_out = IP.rc.separate_out2 = '0'
662 if IP.rc.separate_in == '0': IP.rc.separate_in = ''
662 if IP.rc.separate_in == '0': IP.rc.separate_in = ''
663 if IP.rc.separate_out == '0': IP.rc.separate_out = ''
663 if IP.rc.separate_out == '0': IP.rc.separate_out = ''
664 if IP.rc.separate_out2 == '0': IP.rc.separate_out2 = ''
664 if IP.rc.separate_out2 == '0': IP.rc.separate_out2 = ''
665 IP.rc.separate_in = IP.rc.separate_in.replace('\\n','\n')
665 IP.rc.separate_in = IP.rc.separate_in.replace('\\n','\n')
666 IP.rc.separate_out = IP.rc.separate_out.replace('\\n','\n')
666 IP.rc.separate_out = IP.rc.separate_out.replace('\\n','\n')
667 IP.rc.separate_out2 = IP.rc.separate_out2.replace('\\n','\n')
667 IP.rc.separate_out2 = IP.rc.separate_out2.replace('\\n','\n')
668
668
669 # Determine how many lines at the bottom of the screen are needed for
669 # Determine how many lines at the bottom of the screen are needed for
670 # showing prompts, so we can know wheter long strings are to be printed or
670 # showing prompts, so we can know wheter long strings are to be printed or
671 # paged:
671 # paged:
672 num_lines_bot = IP.rc.separate_in.count('\n')+1
672 num_lines_bot = IP.rc.separate_in.count('\n')+1
673 IP.rc.screen_length = IP.rc.screen_length - num_lines_bot
673 IP.rc.screen_length = IP.rc.screen_length - num_lines_bot
674 # Initialize cache, set in/out prompts and printing system
674 # Initialize cache, set in/out prompts and printing system
675 IP.outputcache = CachedOutput(IP.rc.cache_size,
675 IP.outputcache = CachedOutput(IP.rc.cache_size,
676 IP.rc.pprint,
676 IP.rc.pprint,
677 input_sep = IP.rc.separate_in,
677 input_sep = IP.rc.separate_in,
678 output_sep = IP.rc.separate_out,
678 output_sep = IP.rc.separate_out,
679 output_sep2 = IP.rc.separate_out2,
679 output_sep2 = IP.rc.separate_out2,
680 ps1 = IP.rc.prompt_in1,
680 ps1 = IP.rc.prompt_in1,
681 ps2 = IP.rc.prompt_in2,
681 ps2 = IP.rc.prompt_in2,
682 ps_out = IP.rc.prompt_out,
682 ps_out = IP.rc.prompt_out,
683 user_ns = IP.user_ns,
683 user_ns = IP.user_ns,
684 input_hist = IP.input_hist,
684 input_hist = IP.input_hist,
685 pad_left = IP.rc.prompts_pad_left)
685 pad_left = IP.rc.prompts_pad_left)
686
686
687 # Set user colors (don't do it in the constructor above so that it doesn't
687 # Set user colors (don't do it in the constructor above so that it doesn't
688 # crash if colors option is invalid)
688 # crash if colors option is invalid)
689 IP.magic_colors(IP.rc.colors)
689 IP.magic_colors(IP.rc.colors)
690
690
691 # user may have over-ridden the default print hook:
691 # user may have over-ridden the default print hook:
692 try:
692 try:
693 IP.outputcache.__class__.display = IP.hooks.display
693 IP.outputcache.__class__.display = IP.hooks.display
694 except AttributeError:
694 except AttributeError:
695 pass
695 pass
696
696
697 # Set calling of pdb on exceptions
697 # Set calling of pdb on exceptions
698 IP.InteractiveTB.call_pdb = IP.rc.pdb
698 IP.InteractiveTB.call_pdb = IP.rc.pdb
699
699
700 # I don't like assigning globally to sys, because it means when embedding
700 # I don't like assigning globally to sys, because it means when embedding
701 # instances, each embedded instance overrides the previous choice. But
701 # instances, each embedded instance overrides the previous choice. But
702 # sys.displayhook seems to be called internally by exec, so I don't see a
702 # sys.displayhook seems to be called internally by exec, so I don't see a
703 # way around it.
703 # way around it.
704 sys.displayhook = IP.outputcache
704 sys.displayhook = IP.outputcache
705
705
706 # we need to know globally if we're caching i/o or not
706 # we need to know globally if we're caching i/o or not
707 IP.do_full_cache = IP.outputcache.do_full_cache
707 IP.do_full_cache = IP.outputcache.do_full_cache
708
708
709 # configure startup banner
709 # configure startup banner
710 if IP.rc.c: # regular python doesn't print the banner with -c
710 if IP.rc.c: # regular python doesn't print the banner with -c
711 IP.rc.banner = 0
711 IP.rc.banner = 0
712 if IP.rc.banner:
712 if IP.rc.banner:
713 IP.BANNER = '\n'.join(IP.BANNER_PARTS)
713 IP.BANNER = '\n'.join(IP.BANNER_PARTS)
714 else:
714 else:
715 IP.BANNER = ''
715 IP.BANNER = ''
716
716
717 if IP.rc.profile: IP.BANNER += '\nIPython profile: '+IP.rc.profile+'\n'
717 if IP.rc.profile: IP.BANNER += '\nIPython profile: '+IP.rc.profile+'\n'
718
718
719 # add message log (possibly empty)
719 # add message log (possibly empty)
720 IP.BANNER += msg.summary
720 IP.BANNER += msg.summary
721
721
722 IP.post_config_initialization()
722 IP.post_config_initialization()
723
723
724 return IP
724 return IP
725 #************************ end of file <ipmaker.py> **************************
725 #************************ end of file <ipmaker.py> **************************
@@ -1,4338 +1,4351
1 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
4 calls. These were a leftover from the GTK 1.x days, and can cause
5 problems in certain cases (after a report by John Hunter).
6
7 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
8 os.getcwd() fails at init time. Thanks to patch from David Remahl
9 <chmod007 AT mac.com>.
10 (InteractiveShell.__init__): prevent certain special magics from
11 being shadowed by aliases. Closes
12 http://www.scipy.net/roundup/ipython/issue41.
13
1 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
14 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2
15
3 * IPython/iplib.py (InteractiveShell.complete): Added new
16 * IPython/iplib.py (InteractiveShell.complete): Added new
4 top-level completion method to expose the completion mechanism
17 top-level completion method to expose the completion mechanism
5 beyond readline-based environments.
18 beyond readline-based environments.
6
19
7 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
20 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
8
21
9 * tools/ipsvnc (svnversion): fix svnversion capture.
22 * tools/ipsvnc (svnversion): fix svnversion capture.
10
23
11 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
24 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
12 attribute to self, which was missing. Before, it was set by a
25 attribute to self, which was missing. Before, it was set by a
13 routine which in certain cases wasn't being called, so the
26 routine which in certain cases wasn't being called, so the
14 instance could end up missing the attribute. This caused a crash.
27 instance could end up missing the attribute. This caused a crash.
15 Closes http://www.scipy.net/roundup/ipython/issue40.
28 Closes http://www.scipy.net/roundup/ipython/issue40.
16
29
17 2005-08-16 Fernando Perez <fperez@colorado.edu>
30 2005-08-16 Fernando Perez <fperez@colorado.edu>
18
31
19 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
32 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
20 contains non-string attribute. Closes
33 contains non-string attribute. Closes
21 http://www.scipy.net/roundup/ipython/issue38.
34 http://www.scipy.net/roundup/ipython/issue38.
22
35
23 2005-08-14 Fernando Perez <fperez@colorado.edu>
36 2005-08-14 Fernando Perez <fperez@colorado.edu>
24
37
25 * tools/ipsvnc: Minor improvements, to add changeset info.
38 * tools/ipsvnc: Minor improvements, to add changeset info.
26
39
27 2005-08-12 Fernando Perez <fperez@colorado.edu>
40 2005-08-12 Fernando Perez <fperez@colorado.edu>
28
41
29 * IPython/iplib.py (runsource): remove self.code_to_run_src
42 * IPython/iplib.py (runsource): remove self.code_to_run_src
30 attribute. I realized this is nothing more than
43 attribute. I realized this is nothing more than
31 '\n'.join(self.buffer), and having the same data in two different
44 '\n'.join(self.buffer), and having the same data in two different
32 places is just asking for synchronization bugs. This may impact
45 places is just asking for synchronization bugs. This may impact
33 people who have custom exception handlers, so I need to warn
46 people who have custom exception handlers, so I need to warn
34 ipython-dev about it (F. Mantegazza may use them).
47 ipython-dev about it (F. Mantegazza may use them).
35
48
36 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
49 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
37
50
38 * IPython/genutils.py: fix 2.2 compatibility (generators)
51 * IPython/genutils.py: fix 2.2 compatibility (generators)
39
52
40 2005-07-18 Fernando Perez <fperez@colorado.edu>
53 2005-07-18 Fernando Perez <fperez@colorado.edu>
41
54
42 * IPython/genutils.py (get_home_dir): fix to help users with
55 * IPython/genutils.py (get_home_dir): fix to help users with
43 invalid $HOME under win32.
56 invalid $HOME under win32.
44
57
45 2005-07-17 Fernando Perez <fperez@colorado.edu>
58 2005-07-17 Fernando Perez <fperez@colorado.edu>
46
59
47 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
60 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
48 some old hacks and clean up a bit other routines; code should be
61 some old hacks and clean up a bit other routines; code should be
49 simpler and a bit faster.
62 simpler and a bit faster.
50
63
51 * IPython/iplib.py (interact): removed some last-resort attempts
64 * IPython/iplib.py (interact): removed some last-resort attempts
52 to survive broken stdout/stderr. That code was only making it
65 to survive broken stdout/stderr. That code was only making it
53 harder to abstract out the i/o (necessary for gui integration),
66 harder to abstract out the i/o (necessary for gui integration),
54 and the crashes it could prevent were extremely rare in practice
67 and the crashes it could prevent were extremely rare in practice
55 (besides being fully user-induced in a pretty violent manner).
68 (besides being fully user-induced in a pretty violent manner).
56
69
57 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
70 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
58 Nothing major yet, but the code is simpler to read; this should
71 Nothing major yet, but the code is simpler to read; this should
59 make it easier to do more serious modifications in the future.
72 make it easier to do more serious modifications in the future.
60
73
61 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
74 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
62 which broke in .15 (thanks to a report by Ville).
75 which broke in .15 (thanks to a report by Ville).
63
76
64 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
77 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
65 be quite correct, I know next to nothing about unicode). This
78 be quite correct, I know next to nothing about unicode). This
66 will allow unicode strings to be used in prompts, amongst other
79 will allow unicode strings to be used in prompts, amongst other
67 cases. It also will prevent ipython from crashing when unicode
80 cases. It also will prevent ipython from crashing when unicode
68 shows up unexpectedly in many places. If ascii encoding fails, we
81 shows up unexpectedly in many places. If ascii encoding fails, we
69 assume utf_8. Currently the encoding is not a user-visible
82 assume utf_8. Currently the encoding is not a user-visible
70 setting, though it could be made so if there is demand for it.
83 setting, though it could be made so if there is demand for it.
71
84
72 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
85 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
73
86
74 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
87 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
75
88
76 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
89 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
77
90
78 * IPython/genutils.py: Add 2.2 compatibility here, so all other
91 * IPython/genutils.py: Add 2.2 compatibility here, so all other
79 code can work transparently for 2.2/2.3.
92 code can work transparently for 2.2/2.3.
80
93
81 2005-07-16 Fernando Perez <fperez@colorado.edu>
94 2005-07-16 Fernando Perez <fperez@colorado.edu>
82
95
83 * IPython/ultraTB.py (ExceptionColors): Make a global variable
96 * IPython/ultraTB.py (ExceptionColors): Make a global variable
84 out of the color scheme table used for coloring exception
97 out of the color scheme table used for coloring exception
85 tracebacks. This allows user code to add new schemes at runtime.
98 tracebacks. This allows user code to add new schemes at runtime.
86 This is a minimally modified version of the patch at
99 This is a minimally modified version of the patch at
87 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
100 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
88 for the contribution.
101 for the contribution.
89
102
90 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
103 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
91 slightly modified version of the patch in
104 slightly modified version of the patch in
92 http://www.scipy.net/roundup/ipython/issue34, which also allows me
105 http://www.scipy.net/roundup/ipython/issue34, which also allows me
93 to remove the previous try/except solution (which was costlier).
106 to remove the previous try/except solution (which was costlier).
94 Thanks to Gaetan Lehmann <gaetan.lehmann AT jouy.inra.fr> for the fix.
107 Thanks to Gaetan Lehmann <gaetan.lehmann AT jouy.inra.fr> for the fix.
95
108
96 2005-06-08 Fernando Perez <fperez@colorado.edu>
109 2005-06-08 Fernando Perez <fperez@colorado.edu>
97
110
98 * IPython/iplib.py (write/write_err): Add methods to abstract all
111 * IPython/iplib.py (write/write_err): Add methods to abstract all
99 I/O a bit more.
112 I/O a bit more.
100
113
101 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
114 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
102 warning, reported by Aric Hagberg, fix by JD Hunter.
115 warning, reported by Aric Hagberg, fix by JD Hunter.
103
116
104 2005-06-02 *** Released version 0.6.15
117 2005-06-02 *** Released version 0.6.15
105
118
106 2005-06-01 Fernando Perez <fperez@colorado.edu>
119 2005-06-01 Fernando Perez <fperez@colorado.edu>
107
120
108 * IPython/iplib.py (MagicCompleter.file_matches): Fix
121 * IPython/iplib.py (MagicCompleter.file_matches): Fix
109 tab-completion of filenames within open-quoted strings. Note that
122 tab-completion of filenames within open-quoted strings. Note that
110 this requires that in ~/.ipython/ipythonrc, users change the
123 this requires that in ~/.ipython/ipythonrc, users change the
111 readline delimiters configuration to read:
124 readline delimiters configuration to read:
112
125
113 readline_remove_delims -/~
126 readline_remove_delims -/~
114
127
115
128
116 2005-05-31 *** Released version 0.6.14
129 2005-05-31 *** Released version 0.6.14
117
130
118 2005-05-29 Fernando Perez <fperez@colorado.edu>
131 2005-05-29 Fernando Perez <fperez@colorado.edu>
119
132
120 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
133 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
121 with files not on the filesystem. Reported by Eliyahu Sandler
134 with files not on the filesystem. Reported by Eliyahu Sandler
122 <eli@gondolin.net>
135 <eli@gondolin.net>
123
136
124 2005-05-22 Fernando Perez <fperez@colorado.edu>
137 2005-05-22 Fernando Perez <fperez@colorado.edu>
125
138
126 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
139 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
127 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
140 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
128
141
129 2005-05-19 Fernando Perez <fperez@colorado.edu>
142 2005-05-19 Fernando Perez <fperez@colorado.edu>
130
143
131 * IPython/iplib.py (safe_execfile): close a file which could be
144 * IPython/iplib.py (safe_execfile): close a file which could be
132 left open (causing problems in win32, which locks open files).
145 left open (causing problems in win32, which locks open files).
133 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
146 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
134
147
135 2005-05-18 Fernando Perez <fperez@colorado.edu>
148 2005-05-18 Fernando Perez <fperez@colorado.edu>
136
149
137 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
150 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
138 keyword arguments correctly to safe_execfile().
151 keyword arguments correctly to safe_execfile().
139
152
140 2005-05-13 Fernando Perez <fperez@colorado.edu>
153 2005-05-13 Fernando Perez <fperez@colorado.edu>
141
154
142 * ipython.1: Added info about Qt to manpage, and threads warning
155 * ipython.1: Added info about Qt to manpage, and threads warning
143 to usage page (invoked with --help).
156 to usage page (invoked with --help).
144
157
145 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
158 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
146 new matcher (it goes at the end of the priority list) to do
159 new matcher (it goes at the end of the priority list) to do
147 tab-completion on named function arguments. Submitted by George
160 tab-completion on named function arguments. Submitted by George
148 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
161 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
149 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
162 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
150 for more details.
163 for more details.
151
164
152 * IPython/Magic.py (magic_run): Added new -e flag to ignore
165 * IPython/Magic.py (magic_run): Added new -e flag to ignore
153 SystemExit exceptions in the script being run. Thanks to a report
166 SystemExit exceptions in the script being run. Thanks to a report
154 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
167 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
155 producing very annoying behavior when running unit tests.
168 producing very annoying behavior when running unit tests.
156
169
157 2005-05-12 Fernando Perez <fperez@colorado.edu>
170 2005-05-12 Fernando Perez <fperez@colorado.edu>
158
171
159 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
172 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
160 which I'd broken (again) due to a changed regexp. In the process,
173 which I'd broken (again) due to a changed regexp. In the process,
161 added ';' as an escape to auto-quote the whole line without
174 added ';' as an escape to auto-quote the whole line without
162 splitting its arguments. Thanks to a report by Jerry McRae
175 splitting its arguments. Thanks to a report by Jerry McRae
163 <qrs0xyc02-AT-sneakemail.com>.
176 <qrs0xyc02-AT-sneakemail.com>.
164
177
165 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
178 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
166 possible crashes caused by a TokenError. Reported by Ed Schofield
179 possible crashes caused by a TokenError. Reported by Ed Schofield
167 <schofield-AT-ftw.at>.
180 <schofield-AT-ftw.at>.
168
181
169 2005-05-06 Fernando Perez <fperez@colorado.edu>
182 2005-05-06 Fernando Perez <fperez@colorado.edu>
170
183
171 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
184 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
172
185
173 2005-04-29 Fernando Perez <fperez@colorado.edu>
186 2005-04-29 Fernando Perez <fperez@colorado.edu>
174
187
175 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
188 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
176 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
189 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
177 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
190 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
178 which provides support for Qt interactive usage (similar to the
191 which provides support for Qt interactive usage (similar to the
179 existing one for WX and GTK). This had been often requested.
192 existing one for WX and GTK). This had been often requested.
180
193
181 2005-04-14 *** Released version 0.6.13
194 2005-04-14 *** Released version 0.6.13
182
195
183 2005-04-08 Fernando Perez <fperez@colorado.edu>
196 2005-04-08 Fernando Perez <fperez@colorado.edu>
184
197
185 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
198 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
186 from _ofind, which gets called on almost every input line. Now,
199 from _ofind, which gets called on almost every input line. Now,
187 we only try to get docstrings if they are actually going to be
200 we only try to get docstrings if they are actually going to be
188 used (the overhead of fetching unnecessary docstrings can be
201 used (the overhead of fetching unnecessary docstrings can be
189 noticeable for certain objects, such as Pyro proxies).
202 noticeable for certain objects, such as Pyro proxies).
190
203
191 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
204 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
192 for completers. For some reason I had been passing them the state
205 for completers. For some reason I had been passing them the state
193 variable, which completers never actually need, and was in
206 variable, which completers never actually need, and was in
194 conflict with the rlcompleter API. Custom completers ONLY need to
207 conflict with the rlcompleter API. Custom completers ONLY need to
195 take the text parameter.
208 take the text parameter.
196
209
197 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
210 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
198 work correctly in pysh. I've also moved all the logic which used
211 work correctly in pysh. I've also moved all the logic which used
199 to be in pysh.py here, which will prevent problems with future
212 to be in pysh.py here, which will prevent problems with future
200 upgrades. However, this time I must warn users to update their
213 upgrades. However, this time I must warn users to update their
201 pysh profile to include the line
214 pysh profile to include the line
202
215
203 import_all IPython.Extensions.InterpreterExec
216 import_all IPython.Extensions.InterpreterExec
204
217
205 because otherwise things won't work for them. They MUST also
218 because otherwise things won't work for them. They MUST also
206 delete pysh.py and the line
219 delete pysh.py and the line
207
220
208 execfile pysh.py
221 execfile pysh.py
209
222
210 from their ipythonrc-pysh.
223 from their ipythonrc-pysh.
211
224
212 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
225 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
213 robust in the face of objects whose dir() returns non-strings
226 robust in the face of objects whose dir() returns non-strings
214 (which it shouldn't, but some broken libs like ITK do). Thanks to
227 (which it shouldn't, but some broken libs like ITK do). Thanks to
215 a patch by John Hunter (implemented differently, though). Also
228 a patch by John Hunter (implemented differently, though). Also
216 minor improvements by using .extend instead of + on lists.
229 minor improvements by using .extend instead of + on lists.
217
230
218 * pysh.py:
231 * pysh.py:
219
232
220 2005-04-06 Fernando Perez <fperez@colorado.edu>
233 2005-04-06 Fernando Perez <fperez@colorado.edu>
221
234
222 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
235 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
223 by default, so that all users benefit from it. Those who don't
236 by default, so that all users benefit from it. Those who don't
224 want it can still turn it off.
237 want it can still turn it off.
225
238
226 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
239 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
227 config file, I'd forgotten about this, so users were getting it
240 config file, I'd forgotten about this, so users were getting it
228 off by default.
241 off by default.
229
242
230 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
243 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
231 consistency. Now magics can be called in multiline statements,
244 consistency. Now magics can be called in multiline statements,
232 and python variables can be expanded in magic calls via $var.
245 and python variables can be expanded in magic calls via $var.
233 This makes the magic system behave just like aliases or !system
246 This makes the magic system behave just like aliases or !system
234 calls.
247 calls.
235
248
236 2005-03-28 Fernando Perez <fperez@colorado.edu>
249 2005-03-28 Fernando Perez <fperez@colorado.edu>
237
250
238 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
251 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
239 expensive string additions for building command. Add support for
252 expensive string additions for building command. Add support for
240 trailing ';' when autocall is used.
253 trailing ';' when autocall is used.
241
254
242 2005-03-26 Fernando Perez <fperez@colorado.edu>
255 2005-03-26 Fernando Perez <fperez@colorado.edu>
243
256
244 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
257 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
245 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
258 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
246 ipython.el robust against prompts with any number of spaces
259 ipython.el robust against prompts with any number of spaces
247 (including 0) after the ':' character.
260 (including 0) after the ':' character.
248
261
249 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
262 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
250 continuation prompt, which misled users to think the line was
263 continuation prompt, which misled users to think the line was
251 already indented. Closes debian Bug#300847, reported to me by
264 already indented. Closes debian Bug#300847, reported to me by
252 Norbert Tretkowski <tretkowski-AT-inittab.de>.
265 Norbert Tretkowski <tretkowski-AT-inittab.de>.
253
266
254 2005-03-23 Fernando Perez <fperez@colorado.edu>
267 2005-03-23 Fernando Perez <fperez@colorado.edu>
255
268
256 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
269 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
257 properly aligned if they have embedded newlines.
270 properly aligned if they have embedded newlines.
258
271
259 * IPython/iplib.py (runlines): Add a public method to expose
272 * IPython/iplib.py (runlines): Add a public method to expose
260 IPython's code execution machinery, so that users can run strings
273 IPython's code execution machinery, so that users can run strings
261 as if they had been typed at the prompt interactively.
274 as if they had been typed at the prompt interactively.
262 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
275 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
263 methods which can call the system shell, but with python variable
276 methods which can call the system shell, but with python variable
264 expansion. The three such methods are: __IPYTHON__.system,
277 expansion. The three such methods are: __IPYTHON__.system,
265 .getoutput and .getoutputerror. These need to be documented in a
278 .getoutput and .getoutputerror. These need to be documented in a
266 'public API' section (to be written) of the manual.
279 'public API' section (to be written) of the manual.
267
280
268 2005-03-20 Fernando Perez <fperez@colorado.edu>
281 2005-03-20 Fernando Perez <fperez@colorado.edu>
269
282
270 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
283 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
271 for custom exception handling. This is quite powerful, and it
284 for custom exception handling. This is quite powerful, and it
272 allows for user-installable exception handlers which can trap
285 allows for user-installable exception handlers which can trap
273 custom exceptions at runtime and treat them separately from
286 custom exceptions at runtime and treat them separately from
274 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
287 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
275 Mantegazza <mantegazza-AT-ill.fr>.
288 Mantegazza <mantegazza-AT-ill.fr>.
276 (InteractiveShell.set_custom_completer): public API function to
289 (InteractiveShell.set_custom_completer): public API function to
277 add new completers at runtime.
290 add new completers at runtime.
278
291
279 2005-03-19 Fernando Perez <fperez@colorado.edu>
292 2005-03-19 Fernando Perez <fperez@colorado.edu>
280
293
281 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
294 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
282 allow objects which provide their docstrings via non-standard
295 allow objects which provide their docstrings via non-standard
283 mechanisms (like Pyro proxies) to still be inspected by ipython's
296 mechanisms (like Pyro proxies) to still be inspected by ipython's
284 ? system.
297 ? system.
285
298
286 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
299 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
287 automatic capture system. I tried quite hard to make it work
300 automatic capture system. I tried quite hard to make it work
288 reliably, and simply failed. I tried many combinations with the
301 reliably, and simply failed. I tried many combinations with the
289 subprocess module, but eventually nothing worked in all needed
302 subprocess module, but eventually nothing worked in all needed
290 cases (not blocking stdin for the child, duplicating stdout
303 cases (not blocking stdin for the child, duplicating stdout
291 without blocking, etc). The new %sc/%sx still do capture to these
304 without blocking, etc). The new %sc/%sx still do capture to these
292 magical list/string objects which make shell use much more
305 magical list/string objects which make shell use much more
293 conveninent, so not all is lost.
306 conveninent, so not all is lost.
294
307
295 XXX - FIX MANUAL for the change above!
308 XXX - FIX MANUAL for the change above!
296
309
297 (runsource): I copied code.py's runsource() into ipython to modify
310 (runsource): I copied code.py's runsource() into ipython to modify
298 it a bit. Now the code object and source to be executed are
311 it a bit. Now the code object and source to be executed are
299 stored in ipython. This makes this info accessible to third-party
312 stored in ipython. This makes this info accessible to third-party
300 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
313 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
301 Mantegazza <mantegazza-AT-ill.fr>.
314 Mantegazza <mantegazza-AT-ill.fr>.
302
315
303 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
316 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
304 history-search via readline (like C-p/C-n). I'd wanted this for a
317 history-search via readline (like C-p/C-n). I'd wanted this for a
305 long time, but only recently found out how to do it. For users
318 long time, but only recently found out how to do it. For users
306 who already have their ipythonrc files made and want this, just
319 who already have their ipythonrc files made and want this, just
307 add:
320 add:
308
321
309 readline_parse_and_bind "\e[A": history-search-backward
322 readline_parse_and_bind "\e[A": history-search-backward
310 readline_parse_and_bind "\e[B": history-search-forward
323 readline_parse_and_bind "\e[B": history-search-forward
311
324
312 2005-03-18 Fernando Perez <fperez@colorado.edu>
325 2005-03-18 Fernando Perez <fperez@colorado.edu>
313
326
314 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
327 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
315 LSString and SList classes which allow transparent conversions
328 LSString and SList classes which allow transparent conversions
316 between list mode and whitespace-separated string.
329 between list mode and whitespace-separated string.
317 (magic_r): Fix recursion problem in %r.
330 (magic_r): Fix recursion problem in %r.
318
331
319 * IPython/genutils.py (LSString): New class to be used for
332 * IPython/genutils.py (LSString): New class to be used for
320 automatic storage of the results of all alias/system calls in _o
333 automatic storage of the results of all alias/system calls in _o
321 and _e (stdout/err). These provide a .l/.list attribute which
334 and _e (stdout/err). These provide a .l/.list attribute which
322 does automatic splitting on newlines. This means that for most
335 does automatic splitting on newlines. This means that for most
323 uses, you'll never need to do capturing of output with %sc/%sx
336 uses, you'll never need to do capturing of output with %sc/%sx
324 anymore, since ipython keeps this always done for you. Note that
337 anymore, since ipython keeps this always done for you. Note that
325 only the LAST results are stored, the _o/e variables are
338 only the LAST results are stored, the _o/e variables are
326 overwritten on each call. If you need to save their contents
339 overwritten on each call. If you need to save their contents
327 further, simply bind them to any other name.
340 further, simply bind them to any other name.
328
341
329 2005-03-17 Fernando Perez <fperez@colorado.edu>
342 2005-03-17 Fernando Perez <fperez@colorado.edu>
330
343
331 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
344 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
332 prompt namespace handling.
345 prompt namespace handling.
333
346
334 2005-03-16 Fernando Perez <fperez@colorado.edu>
347 2005-03-16 Fernando Perez <fperez@colorado.edu>
335
348
336 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
349 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
337 classic prompts to be '>>> ' (final space was missing, and it
350 classic prompts to be '>>> ' (final space was missing, and it
338 trips the emacs python mode).
351 trips the emacs python mode).
339 (BasePrompt.__str__): Added safe support for dynamic prompt
352 (BasePrompt.__str__): Added safe support for dynamic prompt
340 strings. Now you can set your prompt string to be '$x', and the
353 strings. Now you can set your prompt string to be '$x', and the
341 value of x will be printed from your interactive namespace. The
354 value of x will be printed from your interactive namespace. The
342 interpolation syntax includes the full Itpl support, so
355 interpolation syntax includes the full Itpl support, so
343 ${foo()+x+bar()} is a valid prompt string now, and the function
356 ${foo()+x+bar()} is a valid prompt string now, and the function
344 calls will be made at runtime.
357 calls will be made at runtime.
345
358
346 2005-03-15 Fernando Perez <fperez@colorado.edu>
359 2005-03-15 Fernando Perez <fperez@colorado.edu>
347
360
348 * IPython/Magic.py (magic_history): renamed %hist to %history, to
361 * IPython/Magic.py (magic_history): renamed %hist to %history, to
349 avoid name clashes in pylab. %hist still works, it just forwards
362 avoid name clashes in pylab. %hist still works, it just forwards
350 the call to %history.
363 the call to %history.
351
364
352 2005-03-02 *** Released version 0.6.12
365 2005-03-02 *** Released version 0.6.12
353
366
354 2005-03-02 Fernando Perez <fperez@colorado.edu>
367 2005-03-02 Fernando Perez <fperez@colorado.edu>
355
368
356 * IPython/iplib.py (handle_magic): log magic calls properly as
369 * IPython/iplib.py (handle_magic): log magic calls properly as
357 ipmagic() function calls.
370 ipmagic() function calls.
358
371
359 * IPython/Magic.py (magic_time): Improved %time to support
372 * IPython/Magic.py (magic_time): Improved %time to support
360 statements and provide wall-clock as well as CPU time.
373 statements and provide wall-clock as well as CPU time.
361
374
362 2005-02-27 Fernando Perez <fperez@colorado.edu>
375 2005-02-27 Fernando Perez <fperez@colorado.edu>
363
376
364 * IPython/hooks.py: New hooks module, to expose user-modifiable
377 * IPython/hooks.py: New hooks module, to expose user-modifiable
365 IPython functionality in a clean manner. For now only the editor
378 IPython functionality in a clean manner. For now only the editor
366 hook is actually written, and other thigns which I intend to turn
379 hook is actually written, and other thigns which I intend to turn
367 into proper hooks aren't yet there. The display and prefilter
380 into proper hooks aren't yet there. The display and prefilter
368 stuff, for example, should be hooks. But at least now the
381 stuff, for example, should be hooks. But at least now the
369 framework is in place, and the rest can be moved here with more
382 framework is in place, and the rest can be moved here with more
370 time later. IPython had had a .hooks variable for a long time for
383 time later. IPython had had a .hooks variable for a long time for
371 this purpose, but I'd never actually used it for anything.
384 this purpose, but I'd never actually used it for anything.
372
385
373 2005-02-26 Fernando Perez <fperez@colorado.edu>
386 2005-02-26 Fernando Perez <fperez@colorado.edu>
374
387
375 * IPython/ipmaker.py (make_IPython): make the default ipython
388 * IPython/ipmaker.py (make_IPython): make the default ipython
376 directory be called _ipython under win32, to follow more the
389 directory be called _ipython under win32, to follow more the
377 naming peculiarities of that platform (where buggy software like
390 naming peculiarities of that platform (where buggy software like
378 Visual Sourcesafe breaks with .named directories). Reported by
391 Visual Sourcesafe breaks with .named directories). Reported by
379 Ville Vainio.
392 Ville Vainio.
380
393
381 2005-02-23 Fernando Perez <fperez@colorado.edu>
394 2005-02-23 Fernando Perez <fperez@colorado.edu>
382
395
383 * IPython/iplib.py (InteractiveShell.__init__): removed a few
396 * IPython/iplib.py (InteractiveShell.__init__): removed a few
384 auto_aliases for win32 which were causing problems. Users can
397 auto_aliases for win32 which were causing problems. Users can
385 define the ones they personally like.
398 define the ones they personally like.
386
399
387 2005-02-21 Fernando Perez <fperez@colorado.edu>
400 2005-02-21 Fernando Perez <fperez@colorado.edu>
388
401
389 * IPython/Magic.py (magic_time): new magic to time execution of
402 * IPython/Magic.py (magic_time): new magic to time execution of
390 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
403 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
391
404
392 2005-02-19 Fernando Perez <fperez@colorado.edu>
405 2005-02-19 Fernando Perez <fperez@colorado.edu>
393
406
394 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
407 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
395 into keys (for prompts, for example).
408 into keys (for prompts, for example).
396
409
397 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
410 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
398 prompts in case users want them. This introduces a small behavior
411 prompts in case users want them. This introduces a small behavior
399 change: ipython does not automatically add a space to all prompts
412 change: ipython does not automatically add a space to all prompts
400 anymore. To get the old prompts with a space, users should add it
413 anymore. To get the old prompts with a space, users should add it
401 manually to their ipythonrc file, so for example prompt_in1 should
414 manually to their ipythonrc file, so for example prompt_in1 should
402 now read 'In [\#]: ' instead of 'In [\#]:'.
415 now read 'In [\#]: ' instead of 'In [\#]:'.
403 (BasePrompt.__init__): New option prompts_pad_left (only in rc
416 (BasePrompt.__init__): New option prompts_pad_left (only in rc
404 file) to control left-padding of secondary prompts.
417 file) to control left-padding of secondary prompts.
405
418
406 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
419 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
407 the profiler can't be imported. Fix for Debian, which removed
420 the profiler can't be imported. Fix for Debian, which removed
408 profile.py because of License issues. I applied a slightly
421 profile.py because of License issues. I applied a slightly
409 modified version of the original Debian patch at
422 modified version of the original Debian patch at
410 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
423 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
411
424
412 2005-02-17 Fernando Perez <fperez@colorado.edu>
425 2005-02-17 Fernando Perez <fperez@colorado.edu>
413
426
414 * IPython/genutils.py (native_line_ends): Fix bug which would
427 * IPython/genutils.py (native_line_ends): Fix bug which would
415 cause improper line-ends under win32 b/c I was not opening files
428 cause improper line-ends under win32 b/c I was not opening files
416 in binary mode. Bug report and fix thanks to Ville.
429 in binary mode. Bug report and fix thanks to Ville.
417
430
418 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
431 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
419 trying to catch spurious foo[1] autocalls. My fix actually broke
432 trying to catch spurious foo[1] autocalls. My fix actually broke
420 ',/' autoquote/call with explicit escape (bad regexp).
433 ',/' autoquote/call with explicit escape (bad regexp).
421
434
422 2005-02-15 *** Released version 0.6.11
435 2005-02-15 *** Released version 0.6.11
423
436
424 2005-02-14 Fernando Perez <fperez@colorado.edu>
437 2005-02-14 Fernando Perez <fperez@colorado.edu>
425
438
426 * IPython/background_jobs.py: New background job management
439 * IPython/background_jobs.py: New background job management
427 subsystem. This is implemented via a new set of classes, and
440 subsystem. This is implemented via a new set of classes, and
428 IPython now provides a builtin 'jobs' object for background job
441 IPython now provides a builtin 'jobs' object for background job
429 execution. A convenience %bg magic serves as a lightweight
442 execution. A convenience %bg magic serves as a lightweight
430 frontend for starting the more common type of calls. This was
443 frontend for starting the more common type of calls. This was
431 inspired by discussions with B. Granger and the BackgroundCommand
444 inspired by discussions with B. Granger and the BackgroundCommand
432 class described in the book Python Scripting for Computational
445 class described in the book Python Scripting for Computational
433 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
446 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
434 (although ultimately no code from this text was used, as IPython's
447 (although ultimately no code from this text was used, as IPython's
435 system is a separate implementation).
448 system is a separate implementation).
436
449
437 * IPython/iplib.py (MagicCompleter.python_matches): add new option
450 * IPython/iplib.py (MagicCompleter.python_matches): add new option
438 to control the completion of single/double underscore names
451 to control the completion of single/double underscore names
439 separately. As documented in the example ipytonrc file, the
452 separately. As documented in the example ipytonrc file, the
440 readline_omit__names variable can now be set to 2, to omit even
453 readline_omit__names variable can now be set to 2, to omit even
441 single underscore names. Thanks to a patch by Brian Wong
454 single underscore names. Thanks to a patch by Brian Wong
442 <BrianWong-AT-AirgoNetworks.Com>.
455 <BrianWong-AT-AirgoNetworks.Com>.
443 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
456 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
444 be autocalled as foo([1]) if foo were callable. A problem for
457 be autocalled as foo([1]) if foo were callable. A problem for
445 things which are both callable and implement __getitem__.
458 things which are both callable and implement __getitem__.
446 (init_readline): Fix autoindentation for win32. Thanks to a patch
459 (init_readline): Fix autoindentation for win32. Thanks to a patch
447 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
460 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
448
461
449 2005-02-12 Fernando Perez <fperez@colorado.edu>
462 2005-02-12 Fernando Perez <fperez@colorado.edu>
450
463
451 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
464 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
452 which I had written long ago to sort out user error messages which
465 which I had written long ago to sort out user error messages which
453 may occur during startup. This seemed like a good idea initially,
466 may occur during startup. This seemed like a good idea initially,
454 but it has proven a disaster in retrospect. I don't want to
467 but it has proven a disaster in retrospect. I don't want to
455 change much code for now, so my fix is to set the internal 'debug'
468 change much code for now, so my fix is to set the internal 'debug'
456 flag to true everywhere, whose only job was precisely to control
469 flag to true everywhere, whose only job was precisely to control
457 this subsystem. This closes issue 28 (as well as avoiding all
470 this subsystem. This closes issue 28 (as well as avoiding all
458 sorts of strange hangups which occur from time to time).
471 sorts of strange hangups which occur from time to time).
459
472
460 2005-02-07 Fernando Perez <fperez@colorado.edu>
473 2005-02-07 Fernando Perez <fperez@colorado.edu>
461
474
462 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
475 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
463 previous call produced a syntax error.
476 previous call produced a syntax error.
464
477
465 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
478 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
466 classes without constructor.
479 classes without constructor.
467
480
468 2005-02-06 Fernando Perez <fperez@colorado.edu>
481 2005-02-06 Fernando Perez <fperez@colorado.edu>
469
482
470 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
483 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
471 completions with the results of each matcher, so we return results
484 completions with the results of each matcher, so we return results
472 to the user from all namespaces. This breaks with ipython
485 to the user from all namespaces. This breaks with ipython
473 tradition, but I think it's a nicer behavior. Now you get all
486 tradition, but I think it's a nicer behavior. Now you get all
474 possible completions listed, from all possible namespaces (python,
487 possible completions listed, from all possible namespaces (python,
475 filesystem, magics...) After a request by John Hunter
488 filesystem, magics...) After a request by John Hunter
476 <jdhunter-AT-nitace.bsd.uchicago.edu>.
489 <jdhunter-AT-nitace.bsd.uchicago.edu>.
477
490
478 2005-02-05 Fernando Perez <fperez@colorado.edu>
491 2005-02-05 Fernando Perez <fperez@colorado.edu>
479
492
480 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
493 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
481 the call had quote characters in it (the quotes were stripped).
494 the call had quote characters in it (the quotes were stripped).
482
495
483 2005-01-31 Fernando Perez <fperez@colorado.edu>
496 2005-01-31 Fernando Perez <fperez@colorado.edu>
484
497
485 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
498 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
486 Itpl.itpl() to make the code more robust against psyco
499 Itpl.itpl() to make the code more robust against psyco
487 optimizations.
500 optimizations.
488
501
489 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
502 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
490 of causing an exception. Quicker, cleaner.
503 of causing an exception. Quicker, cleaner.
491
504
492 2005-01-28 Fernando Perez <fperez@colorado.edu>
505 2005-01-28 Fernando Perez <fperez@colorado.edu>
493
506
494 * scripts/ipython_win_post_install.py (install): hardcode
507 * scripts/ipython_win_post_install.py (install): hardcode
495 sys.prefix+'python.exe' as the executable path. It turns out that
508 sys.prefix+'python.exe' as the executable path. It turns out that
496 during the post-installation run, sys.executable resolves to the
509 during the post-installation run, sys.executable resolves to the
497 name of the binary installer! I should report this as a distutils
510 name of the binary installer! I should report this as a distutils
498 bug, I think. I updated the .10 release with this tiny fix, to
511 bug, I think. I updated the .10 release with this tiny fix, to
499 avoid annoying the lists further.
512 avoid annoying the lists further.
500
513
501 2005-01-27 *** Released version 0.6.10
514 2005-01-27 *** Released version 0.6.10
502
515
503 2005-01-27 Fernando Perez <fperez@colorado.edu>
516 2005-01-27 Fernando Perez <fperez@colorado.edu>
504
517
505 * IPython/numutils.py (norm): Added 'inf' as optional name for
518 * IPython/numutils.py (norm): Added 'inf' as optional name for
506 L-infinity norm, included references to mathworld.com for vector
519 L-infinity norm, included references to mathworld.com for vector
507 norm definitions.
520 norm definitions.
508 (amin/amax): added amin/amax for array min/max. Similar to what
521 (amin/amax): added amin/amax for array min/max. Similar to what
509 pylab ships with after the recent reorganization of names.
522 pylab ships with after the recent reorganization of names.
510 (spike/spike_odd): removed deprecated spike/spike_odd functions.
523 (spike/spike_odd): removed deprecated spike/spike_odd functions.
511
524
512 * ipython.el: committed Alex's recent fixes and improvements.
525 * ipython.el: committed Alex's recent fixes and improvements.
513 Tested with python-mode from CVS, and it looks excellent. Since
526 Tested with python-mode from CVS, and it looks excellent. Since
514 python-mode hasn't released anything in a while, I'm temporarily
527 python-mode hasn't released anything in a while, I'm temporarily
515 putting a copy of today's CVS (v 4.70) of python-mode in:
528 putting a copy of today's CVS (v 4.70) of python-mode in:
516 http://ipython.scipy.org/tmp/python-mode.el
529 http://ipython.scipy.org/tmp/python-mode.el
517
530
518 * scripts/ipython_win_post_install.py (install): Win32 fix to use
531 * scripts/ipython_win_post_install.py (install): Win32 fix to use
519 sys.executable for the executable name, instead of assuming it's
532 sys.executable for the executable name, instead of assuming it's
520 called 'python.exe' (the post-installer would have produced broken
533 called 'python.exe' (the post-installer would have produced broken
521 setups on systems with a differently named python binary).
534 setups on systems with a differently named python binary).
522
535
523 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
536 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
524 references to os.linesep, to make the code more
537 references to os.linesep, to make the code more
525 platform-independent. This is also part of the win32 coloring
538 platform-independent. This is also part of the win32 coloring
526 fixes.
539 fixes.
527
540
528 * IPython/genutils.py (page_dumb): Remove attempts to chop long
541 * IPython/genutils.py (page_dumb): Remove attempts to chop long
529 lines, which actually cause coloring bugs because the length of
542 lines, which actually cause coloring bugs because the length of
530 the line is very difficult to correctly compute with embedded
543 the line is very difficult to correctly compute with embedded
531 escapes. This was the source of all the coloring problems under
544 escapes. This was the source of all the coloring problems under
532 Win32. I think that _finally_, Win32 users have a properly
545 Win32. I think that _finally_, Win32 users have a properly
533 working ipython in all respects. This would never have happened
546 working ipython in all respects. This would never have happened
534 if not for Gary Bishop and Viktor Ransmayr's great help and work.
547 if not for Gary Bishop and Viktor Ransmayr's great help and work.
535
548
536 2005-01-26 *** Released version 0.6.9
549 2005-01-26 *** Released version 0.6.9
537
550
538 2005-01-25 Fernando Perez <fperez@colorado.edu>
551 2005-01-25 Fernando Perez <fperez@colorado.edu>
539
552
540 * setup.py: finally, we have a true Windows installer, thanks to
553 * setup.py: finally, we have a true Windows installer, thanks to
541 the excellent work of Viktor Ransmayr
554 the excellent work of Viktor Ransmayr
542 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
555 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
543 Windows users. The setup routine is quite a bit cleaner thanks to
556 Windows users. The setup routine is quite a bit cleaner thanks to
544 this, and the post-install script uses the proper functions to
557 this, and the post-install script uses the proper functions to
545 allow a clean de-installation using the standard Windows Control
558 allow a clean de-installation using the standard Windows Control
546 Panel.
559 Panel.
547
560
548 * IPython/genutils.py (get_home_dir): changed to use the $HOME
561 * IPython/genutils.py (get_home_dir): changed to use the $HOME
549 environment variable under all OSes (including win32) if
562 environment variable under all OSes (including win32) if
550 available. This will give consistency to win32 users who have set
563 available. This will give consistency to win32 users who have set
551 this variable for any reason. If os.environ['HOME'] fails, the
564 this variable for any reason. If os.environ['HOME'] fails, the
552 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
565 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
553
566
554 2005-01-24 Fernando Perez <fperez@colorado.edu>
567 2005-01-24 Fernando Perez <fperez@colorado.edu>
555
568
556 * IPython/numutils.py (empty_like): add empty_like(), similar to
569 * IPython/numutils.py (empty_like): add empty_like(), similar to
557 zeros_like() but taking advantage of the new empty() Numeric routine.
570 zeros_like() but taking advantage of the new empty() Numeric routine.
558
571
559 2005-01-23 *** Released version 0.6.8
572 2005-01-23 *** Released version 0.6.8
560
573
561 2005-01-22 Fernando Perez <fperez@colorado.edu>
574 2005-01-22 Fernando Perez <fperez@colorado.edu>
562
575
563 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
576 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
564 automatic show() calls. After discussing things with JDH, it
577 automatic show() calls. After discussing things with JDH, it
565 turns out there are too many corner cases where this can go wrong.
578 turns out there are too many corner cases where this can go wrong.
566 It's best not to try to be 'too smart', and simply have ipython
579 It's best not to try to be 'too smart', and simply have ipython
567 reproduce as much as possible the default behavior of a normal
580 reproduce as much as possible the default behavior of a normal
568 python shell.
581 python shell.
569
582
570 * IPython/iplib.py (InteractiveShell.__init__): Modified the
583 * IPython/iplib.py (InteractiveShell.__init__): Modified the
571 line-splitting regexp and _prefilter() to avoid calling getattr()
584 line-splitting regexp and _prefilter() to avoid calling getattr()
572 on assignments. This closes
585 on assignments. This closes
573 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
586 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
574 readline uses getattr(), so a simple <TAB> keypress is still
587 readline uses getattr(), so a simple <TAB> keypress is still
575 enough to trigger getattr() calls on an object.
588 enough to trigger getattr() calls on an object.
576
589
577 2005-01-21 Fernando Perez <fperez@colorado.edu>
590 2005-01-21 Fernando Perez <fperez@colorado.edu>
578
591
579 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
592 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
580 docstring under pylab so it doesn't mask the original.
593 docstring under pylab so it doesn't mask the original.
581
594
582 2005-01-21 *** Released version 0.6.7
595 2005-01-21 *** Released version 0.6.7
583
596
584 2005-01-21 Fernando Perez <fperez@colorado.edu>
597 2005-01-21 Fernando Perez <fperez@colorado.edu>
585
598
586 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
599 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
587 signal handling for win32 users in multithreaded mode.
600 signal handling for win32 users in multithreaded mode.
588
601
589 2005-01-17 Fernando Perez <fperez@colorado.edu>
602 2005-01-17 Fernando Perez <fperez@colorado.edu>
590
603
591 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
604 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
592 instances with no __init__. After a crash report by Norbert Nemec
605 instances with no __init__. After a crash report by Norbert Nemec
593 <Norbert-AT-nemec-online.de>.
606 <Norbert-AT-nemec-online.de>.
594
607
595 2005-01-14 Fernando Perez <fperez@colorado.edu>
608 2005-01-14 Fernando Perez <fperez@colorado.edu>
596
609
597 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
610 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
598 names for verbose exceptions, when multiple dotted names and the
611 names for verbose exceptions, when multiple dotted names and the
599 'parent' object were present on the same line.
612 'parent' object were present on the same line.
600
613
601 2005-01-11 Fernando Perez <fperez@colorado.edu>
614 2005-01-11 Fernando Perez <fperez@colorado.edu>
602
615
603 * IPython/genutils.py (flag_calls): new utility to trap and flag
616 * IPython/genutils.py (flag_calls): new utility to trap and flag
604 calls in functions. I need it to clean up matplotlib support.
617 calls in functions. I need it to clean up matplotlib support.
605 Also removed some deprecated code in genutils.
618 Also removed some deprecated code in genutils.
606
619
607 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
620 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
608 that matplotlib scripts called with %run, which don't call show()
621 that matplotlib scripts called with %run, which don't call show()
609 themselves, still have their plotting windows open.
622 themselves, still have their plotting windows open.
610
623
611 2005-01-05 Fernando Perez <fperez@colorado.edu>
624 2005-01-05 Fernando Perez <fperez@colorado.edu>
612
625
613 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
626 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
614 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
627 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
615
628
616 2004-12-19 Fernando Perez <fperez@colorado.edu>
629 2004-12-19 Fernando Perez <fperez@colorado.edu>
617
630
618 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
631 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
619 parent_runcode, which was an eyesore. The same result can be
632 parent_runcode, which was an eyesore. The same result can be
620 obtained with Python's regular superclass mechanisms.
633 obtained with Python's regular superclass mechanisms.
621
634
622 2004-12-17 Fernando Perez <fperez@colorado.edu>
635 2004-12-17 Fernando Perez <fperez@colorado.edu>
623
636
624 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
637 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
625 reported by Prabhu.
638 reported by Prabhu.
626 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
639 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
627 sys.stderr) instead of explicitly calling sys.stderr. This helps
640 sys.stderr) instead of explicitly calling sys.stderr. This helps
628 maintain our I/O abstractions clean, for future GUI embeddings.
641 maintain our I/O abstractions clean, for future GUI embeddings.
629
642
630 * IPython/genutils.py (info): added new utility for sys.stderr
643 * IPython/genutils.py (info): added new utility for sys.stderr
631 unified info message handling (thin wrapper around warn()).
644 unified info message handling (thin wrapper around warn()).
632
645
633 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
646 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
634 composite (dotted) names on verbose exceptions.
647 composite (dotted) names on verbose exceptions.
635 (VerboseTB.nullrepr): harden against another kind of errors which
648 (VerboseTB.nullrepr): harden against another kind of errors which
636 Python's inspect module can trigger, and which were crashing
649 Python's inspect module can trigger, and which were crashing
637 IPython. Thanks to a report by Marco Lombardi
650 IPython. Thanks to a report by Marco Lombardi
638 <mlombard-AT-ma010192.hq.eso.org>.
651 <mlombard-AT-ma010192.hq.eso.org>.
639
652
640 2004-12-13 *** Released version 0.6.6
653 2004-12-13 *** Released version 0.6.6
641
654
642 2004-12-12 Fernando Perez <fperez@colorado.edu>
655 2004-12-12 Fernando Perez <fperez@colorado.edu>
643
656
644 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
657 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
645 generated by pygtk upon initialization if it was built without
658 generated by pygtk upon initialization if it was built without
646 threads (for matplotlib users). After a crash reported by
659 threads (for matplotlib users). After a crash reported by
647 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
660 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
648
661
649 * IPython/ipmaker.py (make_IPython): fix small bug in the
662 * IPython/ipmaker.py (make_IPython): fix small bug in the
650 import_some parameter for multiple imports.
663 import_some parameter for multiple imports.
651
664
652 * IPython/iplib.py (ipmagic): simplified the interface of
665 * IPython/iplib.py (ipmagic): simplified the interface of
653 ipmagic() to take a single string argument, just as it would be
666 ipmagic() to take a single string argument, just as it would be
654 typed at the IPython cmd line.
667 typed at the IPython cmd line.
655 (ipalias): Added new ipalias() with an interface identical to
668 (ipalias): Added new ipalias() with an interface identical to
656 ipmagic(). This completes exposing a pure python interface to the
669 ipmagic(). This completes exposing a pure python interface to the
657 alias and magic system, which can be used in loops or more complex
670 alias and magic system, which can be used in loops or more complex
658 code where IPython's automatic line mangling is not active.
671 code where IPython's automatic line mangling is not active.
659
672
660 * IPython/genutils.py (timing): changed interface of timing to
673 * IPython/genutils.py (timing): changed interface of timing to
661 simply run code once, which is the most common case. timings()
674 simply run code once, which is the most common case. timings()
662 remains unchanged, for the cases where you want multiple runs.
675 remains unchanged, for the cases where you want multiple runs.
663
676
664 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
677 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
665 bug where Python2.2 crashes with exec'ing code which does not end
678 bug where Python2.2 crashes with exec'ing code which does not end
666 in a single newline. Python 2.3 is OK, so I hadn't noticed this
679 in a single newline. Python 2.3 is OK, so I hadn't noticed this
667 before.
680 before.
668
681
669 2004-12-10 Fernando Perez <fperez@colorado.edu>
682 2004-12-10 Fernando Perez <fperez@colorado.edu>
670
683
671 * IPython/Magic.py (Magic.magic_prun): changed name of option from
684 * IPython/Magic.py (Magic.magic_prun): changed name of option from
672 -t to -T, to accomodate the new -t flag in %run (the %run and
685 -t to -T, to accomodate the new -t flag in %run (the %run and
673 %prun options are kind of intermixed, and it's not easy to change
686 %prun options are kind of intermixed, and it's not easy to change
674 this with the limitations of python's getopt).
687 this with the limitations of python's getopt).
675
688
676 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
689 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
677 the execution of scripts. It's not as fine-tuned as timeit.py,
690 the execution of scripts. It's not as fine-tuned as timeit.py,
678 but it works from inside ipython (and under 2.2, which lacks
691 but it works from inside ipython (and under 2.2, which lacks
679 timeit.py). Optionally a number of runs > 1 can be given for
692 timeit.py). Optionally a number of runs > 1 can be given for
680 timing very short-running code.
693 timing very short-running code.
681
694
682 * IPython/genutils.py (uniq_stable): new routine which returns a
695 * IPython/genutils.py (uniq_stable): new routine which returns a
683 list of unique elements in any iterable, but in stable order of
696 list of unique elements in any iterable, but in stable order of
684 appearance. I needed this for the ultraTB fixes, and it's a handy
697 appearance. I needed this for the ultraTB fixes, and it's a handy
685 utility.
698 utility.
686
699
687 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
700 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
688 dotted names in Verbose exceptions. This had been broken since
701 dotted names in Verbose exceptions. This had been broken since
689 the very start, now x.y will properly be printed in a Verbose
702 the very start, now x.y will properly be printed in a Verbose
690 traceback, instead of x being shown and y appearing always as an
703 traceback, instead of x being shown and y appearing always as an
691 'undefined global'. Getting this to work was a bit tricky,
704 'undefined global'. Getting this to work was a bit tricky,
692 because by default python tokenizers are stateless. Saved by
705 because by default python tokenizers are stateless. Saved by
693 python's ability to easily add a bit of state to an arbitrary
706 python's ability to easily add a bit of state to an arbitrary
694 function (without needing to build a full-blown callable object).
707 function (without needing to build a full-blown callable object).
695
708
696 Also big cleanup of this code, which had horrendous runtime
709 Also big cleanup of this code, which had horrendous runtime
697 lookups of zillions of attributes for colorization. Moved all
710 lookups of zillions of attributes for colorization. Moved all
698 this code into a few templates, which make it cleaner and quicker.
711 this code into a few templates, which make it cleaner and quicker.
699
712
700 Printout quality was also improved for Verbose exceptions: one
713 Printout quality was also improved for Verbose exceptions: one
701 variable per line, and memory addresses are printed (this can be
714 variable per line, and memory addresses are printed (this can be
702 quite handy in nasty debugging situations, which is what Verbose
715 quite handy in nasty debugging situations, which is what Verbose
703 is for).
716 is for).
704
717
705 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
718 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
706 the command line as scripts to be loaded by embedded instances.
719 the command line as scripts to be loaded by embedded instances.
707 Doing so has the potential for an infinite recursion if there are
720 Doing so has the potential for an infinite recursion if there are
708 exceptions thrown in the process. This fixes a strange crash
721 exceptions thrown in the process. This fixes a strange crash
709 reported by Philippe MULLER <muller-AT-irit.fr>.
722 reported by Philippe MULLER <muller-AT-irit.fr>.
710
723
711 2004-12-09 Fernando Perez <fperez@colorado.edu>
724 2004-12-09 Fernando Perez <fperez@colorado.edu>
712
725
713 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
726 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
714 to reflect new names in matplotlib, which now expose the
727 to reflect new names in matplotlib, which now expose the
715 matlab-compatible interface via a pylab module instead of the
728 matlab-compatible interface via a pylab module instead of the
716 'matlab' name. The new code is backwards compatible, so users of
729 'matlab' name. The new code is backwards compatible, so users of
717 all matplotlib versions are OK. Patch by J. Hunter.
730 all matplotlib versions are OK. Patch by J. Hunter.
718
731
719 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
732 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
720 of __init__ docstrings for instances (class docstrings are already
733 of __init__ docstrings for instances (class docstrings are already
721 automatically printed). Instances with customized docstrings
734 automatically printed). Instances with customized docstrings
722 (indep. of the class) are also recognized and all 3 separate
735 (indep. of the class) are also recognized and all 3 separate
723 docstrings are printed (instance, class, constructor). After some
736 docstrings are printed (instance, class, constructor). After some
724 comments/suggestions by J. Hunter.
737 comments/suggestions by J. Hunter.
725
738
726 2004-12-05 Fernando Perez <fperez@colorado.edu>
739 2004-12-05 Fernando Perez <fperez@colorado.edu>
727
740
728 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
741 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
729 warnings when tab-completion fails and triggers an exception.
742 warnings when tab-completion fails and triggers an exception.
730
743
731 2004-12-03 Fernando Perez <fperez@colorado.edu>
744 2004-12-03 Fernando Perez <fperez@colorado.edu>
732
745
733 * IPython/Magic.py (magic_prun): Fix bug where an exception would
746 * IPython/Magic.py (magic_prun): Fix bug where an exception would
734 be triggered when using 'run -p'. An incorrect option flag was
747 be triggered when using 'run -p'. An incorrect option flag was
735 being set ('d' instead of 'D').
748 being set ('d' instead of 'D').
736 (manpage): fix missing escaped \- sign.
749 (manpage): fix missing escaped \- sign.
737
750
738 2004-11-30 *** Released version 0.6.5
751 2004-11-30 *** Released version 0.6.5
739
752
740 2004-11-30 Fernando Perez <fperez@colorado.edu>
753 2004-11-30 Fernando Perez <fperez@colorado.edu>
741
754
742 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
755 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
743 setting with -d option.
756 setting with -d option.
744
757
745 * setup.py (docfiles): Fix problem where the doc glob I was using
758 * setup.py (docfiles): Fix problem where the doc glob I was using
746 was COMPLETELY BROKEN. It was giving the right files by pure
759 was COMPLETELY BROKEN. It was giving the right files by pure
747 accident, but failed once I tried to include ipython.el. Note:
760 accident, but failed once I tried to include ipython.el. Note:
748 glob() does NOT allow you to do exclusion on multiple endings!
761 glob() does NOT allow you to do exclusion on multiple endings!
749
762
750 2004-11-29 Fernando Perez <fperez@colorado.edu>
763 2004-11-29 Fernando Perez <fperez@colorado.edu>
751
764
752 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
765 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
753 the manpage as the source. Better formatting & consistency.
766 the manpage as the source. Better formatting & consistency.
754
767
755 * IPython/Magic.py (magic_run): Added new -d option, to run
768 * IPython/Magic.py (magic_run): Added new -d option, to run
756 scripts under the control of the python pdb debugger. Note that
769 scripts under the control of the python pdb debugger. Note that
757 this required changing the %prun option -d to -D, to avoid a clash
770 this required changing the %prun option -d to -D, to avoid a clash
758 (since %run must pass options to %prun, and getopt is too dumb to
771 (since %run must pass options to %prun, and getopt is too dumb to
759 handle options with string values with embedded spaces). Thanks
772 handle options with string values with embedded spaces). Thanks
760 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
773 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
761 (magic_who_ls): added type matching to %who and %whos, so that one
774 (magic_who_ls): added type matching to %who and %whos, so that one
762 can filter their output to only include variables of certain
775 can filter their output to only include variables of certain
763 types. Another suggestion by Matthew.
776 types. Another suggestion by Matthew.
764 (magic_whos): Added memory summaries in kb and Mb for arrays.
777 (magic_whos): Added memory summaries in kb and Mb for arrays.
765 (magic_who): Improve formatting (break lines every 9 vars).
778 (magic_who): Improve formatting (break lines every 9 vars).
766
779
767 2004-11-28 Fernando Perez <fperez@colorado.edu>
780 2004-11-28 Fernando Perez <fperez@colorado.edu>
768
781
769 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
782 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
770 cache when empty lines were present.
783 cache when empty lines were present.
771
784
772 2004-11-24 Fernando Perez <fperez@colorado.edu>
785 2004-11-24 Fernando Perez <fperez@colorado.edu>
773
786
774 * IPython/usage.py (__doc__): document the re-activated threading
787 * IPython/usage.py (__doc__): document the re-activated threading
775 options for WX and GTK.
788 options for WX and GTK.
776
789
777 2004-11-23 Fernando Perez <fperez@colorado.edu>
790 2004-11-23 Fernando Perez <fperez@colorado.edu>
778
791
779 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
792 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
780 the -wthread and -gthread options, along with a new -tk one to try
793 the -wthread and -gthread options, along with a new -tk one to try
781 and coordinate Tk threading with wx/gtk. The tk support is very
794 and coordinate Tk threading with wx/gtk. The tk support is very
782 platform dependent, since it seems to require Tcl and Tk to be
795 platform dependent, since it seems to require Tcl and Tk to be
783 built with threads (Fedora1/2 appears NOT to have it, but in
796 built with threads (Fedora1/2 appears NOT to have it, but in
784 Prabhu's Debian boxes it works OK). But even with some Tk
797 Prabhu's Debian boxes it works OK). But even with some Tk
785 limitations, this is a great improvement.
798 limitations, this is a great improvement.
786
799
787 * IPython/Prompts.py (prompt_specials_color): Added \t for time
800 * IPython/Prompts.py (prompt_specials_color): Added \t for time
788 info in user prompts. Patch by Prabhu.
801 info in user prompts. Patch by Prabhu.
789
802
790 2004-11-18 Fernando Perez <fperez@colorado.edu>
803 2004-11-18 Fernando Perez <fperez@colorado.edu>
791
804
792 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
805 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
793 EOFErrors and bail, to avoid infinite loops if a non-terminating
806 EOFErrors and bail, to avoid infinite loops if a non-terminating
794 file is fed into ipython. Patch submitted in issue 19 by user,
807 file is fed into ipython. Patch submitted in issue 19 by user,
795 many thanks.
808 many thanks.
796
809
797 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
810 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
798 autoquote/parens in continuation prompts, which can cause lots of
811 autoquote/parens in continuation prompts, which can cause lots of
799 problems. Closes roundup issue 20.
812 problems. Closes roundup issue 20.
800
813
801 2004-11-17 Fernando Perez <fperez@colorado.edu>
814 2004-11-17 Fernando Perez <fperez@colorado.edu>
802
815
803 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
816 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
804 reported as debian bug #280505. I'm not sure my local changelog
817 reported as debian bug #280505. I'm not sure my local changelog
805 entry has the proper debian format (Jack?).
818 entry has the proper debian format (Jack?).
806
819
807 2004-11-08 *** Released version 0.6.4
820 2004-11-08 *** Released version 0.6.4
808
821
809 2004-11-08 Fernando Perez <fperez@colorado.edu>
822 2004-11-08 Fernando Perez <fperez@colorado.edu>
810
823
811 * IPython/iplib.py (init_readline): Fix exit message for Windows
824 * IPython/iplib.py (init_readline): Fix exit message for Windows
812 when readline is active. Thanks to a report by Eric Jones
825 when readline is active. Thanks to a report by Eric Jones
813 <eric-AT-enthought.com>.
826 <eric-AT-enthought.com>.
814
827
815 2004-11-07 Fernando Perez <fperez@colorado.edu>
828 2004-11-07 Fernando Perez <fperez@colorado.edu>
816
829
817 * IPython/genutils.py (page): Add a trap for OSError exceptions,
830 * IPython/genutils.py (page): Add a trap for OSError exceptions,
818 sometimes seen by win2k/cygwin users.
831 sometimes seen by win2k/cygwin users.
819
832
820 2004-11-06 Fernando Perez <fperez@colorado.edu>
833 2004-11-06 Fernando Perez <fperez@colorado.edu>
821
834
822 * IPython/iplib.py (interact): Change the handling of %Exit from
835 * IPython/iplib.py (interact): Change the handling of %Exit from
823 trying to propagate a SystemExit to an internal ipython flag.
836 trying to propagate a SystemExit to an internal ipython flag.
824 This is less elegant than using Python's exception mechanism, but
837 This is less elegant than using Python's exception mechanism, but
825 I can't get that to work reliably with threads, so under -pylab
838 I can't get that to work reliably with threads, so under -pylab
826 %Exit was hanging IPython. Cross-thread exception handling is
839 %Exit was hanging IPython. Cross-thread exception handling is
827 really a bitch. Thaks to a bug report by Stephen Walton
840 really a bitch. Thaks to a bug report by Stephen Walton
828 <stephen.walton-AT-csun.edu>.
841 <stephen.walton-AT-csun.edu>.
829
842
830 2004-11-04 Fernando Perez <fperez@colorado.edu>
843 2004-11-04 Fernando Perez <fperez@colorado.edu>
831
844
832 * IPython/iplib.py (raw_input_original): store a pointer to the
845 * IPython/iplib.py (raw_input_original): store a pointer to the
833 true raw_input to harden against code which can modify it
846 true raw_input to harden against code which can modify it
834 (wx.py.PyShell does this and would otherwise crash ipython).
847 (wx.py.PyShell does this and would otherwise crash ipython).
835 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
848 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
836
849
837 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
850 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
838 Ctrl-C problem, which does not mess up the input line.
851 Ctrl-C problem, which does not mess up the input line.
839
852
840 2004-11-03 Fernando Perez <fperez@colorado.edu>
853 2004-11-03 Fernando Perez <fperez@colorado.edu>
841
854
842 * IPython/Release.py: Changed licensing to BSD, in all files.
855 * IPython/Release.py: Changed licensing to BSD, in all files.
843 (name): lowercase name for tarball/RPM release.
856 (name): lowercase name for tarball/RPM release.
844
857
845 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
858 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
846 use throughout ipython.
859 use throughout ipython.
847
860
848 * IPython/Magic.py (Magic._ofind): Switch to using the new
861 * IPython/Magic.py (Magic._ofind): Switch to using the new
849 OInspect.getdoc() function.
862 OInspect.getdoc() function.
850
863
851 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
864 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
852 of the line currently being canceled via Ctrl-C. It's extremely
865 of the line currently being canceled via Ctrl-C. It's extremely
853 ugly, but I don't know how to do it better (the problem is one of
866 ugly, but I don't know how to do it better (the problem is one of
854 handling cross-thread exceptions).
867 handling cross-thread exceptions).
855
868
856 2004-10-28 Fernando Perez <fperez@colorado.edu>
869 2004-10-28 Fernando Perez <fperez@colorado.edu>
857
870
858 * IPython/Shell.py (signal_handler): add signal handlers to trap
871 * IPython/Shell.py (signal_handler): add signal handlers to trap
859 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
872 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
860 report by Francesc Alted.
873 report by Francesc Alted.
861
874
862 2004-10-21 Fernando Perez <fperez@colorado.edu>
875 2004-10-21 Fernando Perez <fperez@colorado.edu>
863
876
864 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
877 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
865 to % for pysh syntax extensions.
878 to % for pysh syntax extensions.
866
879
867 2004-10-09 Fernando Perez <fperez@colorado.edu>
880 2004-10-09 Fernando Perez <fperez@colorado.edu>
868
881
869 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
882 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
870 arrays to print a more useful summary, without calling str(arr).
883 arrays to print a more useful summary, without calling str(arr).
871 This avoids the problem of extremely lengthy computations which
884 This avoids the problem of extremely lengthy computations which
872 occur if arr is large, and appear to the user as a system lockup
885 occur if arr is large, and appear to the user as a system lockup
873 with 100% cpu activity. After a suggestion by Kristian Sandberg
886 with 100% cpu activity. After a suggestion by Kristian Sandberg
874 <Kristian.Sandberg@colorado.edu>.
887 <Kristian.Sandberg@colorado.edu>.
875 (Magic.__init__): fix bug in global magic escapes not being
888 (Magic.__init__): fix bug in global magic escapes not being
876 correctly set.
889 correctly set.
877
890
878 2004-10-08 Fernando Perez <fperez@colorado.edu>
891 2004-10-08 Fernando Perez <fperez@colorado.edu>
879
892
880 * IPython/Magic.py (__license__): change to absolute imports of
893 * IPython/Magic.py (__license__): change to absolute imports of
881 ipython's own internal packages, to start adapting to the absolute
894 ipython's own internal packages, to start adapting to the absolute
882 import requirement of PEP-328.
895 import requirement of PEP-328.
883
896
884 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
897 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
885 files, and standardize author/license marks through the Release
898 files, and standardize author/license marks through the Release
886 module instead of having per/file stuff (except for files with
899 module instead of having per/file stuff (except for files with
887 particular licenses, like the MIT/PSF-licensed codes).
900 particular licenses, like the MIT/PSF-licensed codes).
888
901
889 * IPython/Debugger.py: remove dead code for python 2.1
902 * IPython/Debugger.py: remove dead code for python 2.1
890
903
891 2004-10-04 Fernando Perez <fperez@colorado.edu>
904 2004-10-04 Fernando Perez <fperez@colorado.edu>
892
905
893 * IPython/iplib.py (ipmagic): New function for accessing magics
906 * IPython/iplib.py (ipmagic): New function for accessing magics
894 via a normal python function call.
907 via a normal python function call.
895
908
896 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
909 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
897 from '@' to '%', to accomodate the new @decorator syntax of python
910 from '@' to '%', to accomodate the new @decorator syntax of python
898 2.4.
911 2.4.
899
912
900 2004-09-29 Fernando Perez <fperez@colorado.edu>
913 2004-09-29 Fernando Perez <fperez@colorado.edu>
901
914
902 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
915 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
903 matplotlib.use to prevent running scripts which try to switch
916 matplotlib.use to prevent running scripts which try to switch
904 interactive backends from within ipython. This will just crash
917 interactive backends from within ipython. This will just crash
905 the python interpreter, so we can't allow it (but a detailed error
918 the python interpreter, so we can't allow it (but a detailed error
906 is given to the user).
919 is given to the user).
907
920
908 2004-09-28 Fernando Perez <fperez@colorado.edu>
921 2004-09-28 Fernando Perez <fperez@colorado.edu>
909
922
910 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
923 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
911 matplotlib-related fixes so that using @run with non-matplotlib
924 matplotlib-related fixes so that using @run with non-matplotlib
912 scripts doesn't pop up spurious plot windows. This requires
925 scripts doesn't pop up spurious plot windows. This requires
913 matplotlib >= 0.63, where I had to make some changes as well.
926 matplotlib >= 0.63, where I had to make some changes as well.
914
927
915 * IPython/ipmaker.py (make_IPython): update version requirement to
928 * IPython/ipmaker.py (make_IPython): update version requirement to
916 python 2.2.
929 python 2.2.
917
930
918 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
931 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
919 banner arg for embedded customization.
932 banner arg for embedded customization.
920
933
921 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
934 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
922 explicit uses of __IP as the IPython's instance name. Now things
935 explicit uses of __IP as the IPython's instance name. Now things
923 are properly handled via the shell.name value. The actual code
936 are properly handled via the shell.name value. The actual code
924 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
937 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
925 is much better than before. I'll clean things completely when the
938 is much better than before. I'll clean things completely when the
926 magic stuff gets a real overhaul.
939 magic stuff gets a real overhaul.
927
940
928 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
941 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
929 minor changes to debian dir.
942 minor changes to debian dir.
930
943
931 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
944 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
932 pointer to the shell itself in the interactive namespace even when
945 pointer to the shell itself in the interactive namespace even when
933 a user-supplied dict is provided. This is needed for embedding
946 a user-supplied dict is provided. This is needed for embedding
934 purposes (found by tests with Michel Sanner).
947 purposes (found by tests with Michel Sanner).
935
948
936 2004-09-27 Fernando Perez <fperez@colorado.edu>
949 2004-09-27 Fernando Perez <fperez@colorado.edu>
937
950
938 * IPython/UserConfig/ipythonrc: remove []{} from
951 * IPython/UserConfig/ipythonrc: remove []{} from
939 readline_remove_delims, so that things like [modname.<TAB> do
952 readline_remove_delims, so that things like [modname.<TAB> do
940 proper completion. This disables [].TAB, but that's a less common
953 proper completion. This disables [].TAB, but that's a less common
941 case than module names in list comprehensions, for example.
954 case than module names in list comprehensions, for example.
942 Thanks to a report by Andrea Riciputi.
955 Thanks to a report by Andrea Riciputi.
943
956
944 2004-09-09 Fernando Perez <fperez@colorado.edu>
957 2004-09-09 Fernando Perez <fperez@colorado.edu>
945
958
946 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
959 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
947 blocking problems in win32 and osx. Fix by John.
960 blocking problems in win32 and osx. Fix by John.
948
961
949 2004-09-08 Fernando Perez <fperez@colorado.edu>
962 2004-09-08 Fernando Perez <fperez@colorado.edu>
950
963
951 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
964 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
952 for Win32 and OSX. Fix by John Hunter.
965 for Win32 and OSX. Fix by John Hunter.
953
966
954 2004-08-30 *** Released version 0.6.3
967 2004-08-30 *** Released version 0.6.3
955
968
956 2004-08-30 Fernando Perez <fperez@colorado.edu>
969 2004-08-30 Fernando Perez <fperez@colorado.edu>
957
970
958 * setup.py (isfile): Add manpages to list of dependent files to be
971 * setup.py (isfile): Add manpages to list of dependent files to be
959 updated.
972 updated.
960
973
961 2004-08-27 Fernando Perez <fperez@colorado.edu>
974 2004-08-27 Fernando Perez <fperez@colorado.edu>
962
975
963 * IPython/Shell.py (start): I've disabled -wthread and -gthread
976 * IPython/Shell.py (start): I've disabled -wthread and -gthread
964 for now. They don't really work with standalone WX/GTK code
977 for now. They don't really work with standalone WX/GTK code
965 (though matplotlib IS working fine with both of those backends).
978 (though matplotlib IS working fine with both of those backends).
966 This will neeed much more testing. I disabled most things with
979 This will neeed much more testing. I disabled most things with
967 comments, so turning it back on later should be pretty easy.
980 comments, so turning it back on later should be pretty easy.
968
981
969 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
982 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
970 autocalling of expressions like r'foo', by modifying the line
983 autocalling of expressions like r'foo', by modifying the line
971 split regexp. Closes
984 split regexp. Closes
972 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
985 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
973 Riley <ipythonbugs-AT-sabi.net>.
986 Riley <ipythonbugs-AT-sabi.net>.
974 (InteractiveShell.mainloop): honor --nobanner with banner
987 (InteractiveShell.mainloop): honor --nobanner with banner
975 extensions.
988 extensions.
976
989
977 * IPython/Shell.py: Significant refactoring of all classes, so
990 * IPython/Shell.py: Significant refactoring of all classes, so
978 that we can really support ALL matplotlib backends and threading
991 that we can really support ALL matplotlib backends and threading
979 models (John spotted a bug with Tk which required this). Now we
992 models (John spotted a bug with Tk which required this). Now we
980 should support single-threaded, WX-threads and GTK-threads, both
993 should support single-threaded, WX-threads and GTK-threads, both
981 for generic code and for matplotlib.
994 for generic code and for matplotlib.
982
995
983 * IPython/ipmaker.py (__call__): Changed -mpthread option to
996 * IPython/ipmaker.py (__call__): Changed -mpthread option to
984 -pylab, to simplify things for users. Will also remove the pylab
997 -pylab, to simplify things for users. Will also remove the pylab
985 profile, since now all of matplotlib configuration is directly
998 profile, since now all of matplotlib configuration is directly
986 handled here. This also reduces startup time.
999 handled here. This also reduces startup time.
987
1000
988 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1001 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
989 shell wasn't being correctly called. Also in IPShellWX.
1002 shell wasn't being correctly called. Also in IPShellWX.
990
1003
991 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1004 * IPython/iplib.py (InteractiveShell.__init__): Added option to
992 fine-tune banner.
1005 fine-tune banner.
993
1006
994 * IPython/numutils.py (spike): Deprecate these spike functions,
1007 * IPython/numutils.py (spike): Deprecate these spike functions,
995 delete (long deprecated) gnuplot_exec handler.
1008 delete (long deprecated) gnuplot_exec handler.
996
1009
997 2004-08-26 Fernando Perez <fperez@colorado.edu>
1010 2004-08-26 Fernando Perez <fperez@colorado.edu>
998
1011
999 * ipython.1: Update for threading options, plus some others which
1012 * ipython.1: Update for threading options, plus some others which
1000 were missing.
1013 were missing.
1001
1014
1002 * IPython/ipmaker.py (__call__): Added -wthread option for
1015 * IPython/ipmaker.py (__call__): Added -wthread option for
1003 wxpython thread handling. Make sure threading options are only
1016 wxpython thread handling. Make sure threading options are only
1004 valid at the command line.
1017 valid at the command line.
1005
1018
1006 * scripts/ipython: moved shell selection into a factory function
1019 * scripts/ipython: moved shell selection into a factory function
1007 in Shell.py, to keep the starter script to a minimum.
1020 in Shell.py, to keep the starter script to a minimum.
1008
1021
1009 2004-08-25 Fernando Perez <fperez@colorado.edu>
1022 2004-08-25 Fernando Perez <fperez@colorado.edu>
1010
1023
1011 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1024 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1012 John. Along with some recent changes he made to matplotlib, the
1025 John. Along with some recent changes he made to matplotlib, the
1013 next versions of both systems should work very well together.
1026 next versions of both systems should work very well together.
1014
1027
1015 2004-08-24 Fernando Perez <fperez@colorado.edu>
1028 2004-08-24 Fernando Perez <fperez@colorado.edu>
1016
1029
1017 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1030 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1018 tried to switch the profiling to using hotshot, but I'm getting
1031 tried to switch the profiling to using hotshot, but I'm getting
1019 strange errors from prof.runctx() there. I may be misreading the
1032 strange errors from prof.runctx() there. I may be misreading the
1020 docs, but it looks weird. For now the profiling code will
1033 docs, but it looks weird. For now the profiling code will
1021 continue to use the standard profiler.
1034 continue to use the standard profiler.
1022
1035
1023 2004-08-23 Fernando Perez <fperez@colorado.edu>
1036 2004-08-23 Fernando Perez <fperez@colorado.edu>
1024
1037
1025 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1038 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1026 threaded shell, by John Hunter. It's not quite ready yet, but
1039 threaded shell, by John Hunter. It's not quite ready yet, but
1027 close.
1040 close.
1028
1041
1029 2004-08-22 Fernando Perez <fperez@colorado.edu>
1042 2004-08-22 Fernando Perez <fperez@colorado.edu>
1030
1043
1031 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1044 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1032 in Magic and ultraTB.
1045 in Magic and ultraTB.
1033
1046
1034 * ipython.1: document threading options in manpage.
1047 * ipython.1: document threading options in manpage.
1035
1048
1036 * scripts/ipython: Changed name of -thread option to -gthread,
1049 * scripts/ipython: Changed name of -thread option to -gthread,
1037 since this is GTK specific. I want to leave the door open for a
1050 since this is GTK specific. I want to leave the door open for a
1038 -wthread option for WX, which will most likely be necessary. This
1051 -wthread option for WX, which will most likely be necessary. This
1039 change affects usage and ipmaker as well.
1052 change affects usage and ipmaker as well.
1040
1053
1041 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1054 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1042 handle the matplotlib shell issues. Code by John Hunter
1055 handle the matplotlib shell issues. Code by John Hunter
1043 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1056 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1044 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1057 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1045 broken (and disabled for end users) for now, but it puts the
1058 broken (and disabled for end users) for now, but it puts the
1046 infrastructure in place.
1059 infrastructure in place.
1047
1060
1048 2004-08-21 Fernando Perez <fperez@colorado.edu>
1061 2004-08-21 Fernando Perez <fperez@colorado.edu>
1049
1062
1050 * ipythonrc-pylab: Add matplotlib support.
1063 * ipythonrc-pylab: Add matplotlib support.
1051
1064
1052 * matplotlib_config.py: new files for matplotlib support, part of
1065 * matplotlib_config.py: new files for matplotlib support, part of
1053 the pylab profile.
1066 the pylab profile.
1054
1067
1055 * IPython/usage.py (__doc__): documented the threading options.
1068 * IPython/usage.py (__doc__): documented the threading options.
1056
1069
1057 2004-08-20 Fernando Perez <fperez@colorado.edu>
1070 2004-08-20 Fernando Perez <fperez@colorado.edu>
1058
1071
1059 * ipython: Modified the main calling routine to handle the -thread
1072 * ipython: Modified the main calling routine to handle the -thread
1060 and -mpthread options. This needs to be done as a top-level hack,
1073 and -mpthread options. This needs to be done as a top-level hack,
1061 because it determines which class to instantiate for IPython
1074 because it determines which class to instantiate for IPython
1062 itself.
1075 itself.
1063
1076
1064 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1077 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1065 classes to support multithreaded GTK operation without blocking,
1078 classes to support multithreaded GTK operation without blocking,
1066 and matplotlib with all backends. This is a lot of still very
1079 and matplotlib with all backends. This is a lot of still very
1067 experimental code, and threads are tricky. So it may still have a
1080 experimental code, and threads are tricky. So it may still have a
1068 few rough edges... This code owes a lot to
1081 few rough edges... This code owes a lot to
1069 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1082 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1070 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1083 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1071 to John Hunter for all the matplotlib work.
1084 to John Hunter for all the matplotlib work.
1072
1085
1073 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1086 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1074 options for gtk thread and matplotlib support.
1087 options for gtk thread and matplotlib support.
1075
1088
1076 2004-08-16 Fernando Perez <fperez@colorado.edu>
1089 2004-08-16 Fernando Perez <fperez@colorado.edu>
1077
1090
1078 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1091 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1079 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1092 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1080 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1093 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1081
1094
1082 2004-08-11 Fernando Perez <fperez@colorado.edu>
1095 2004-08-11 Fernando Perez <fperez@colorado.edu>
1083
1096
1084 * setup.py (isfile): Fix build so documentation gets updated for
1097 * setup.py (isfile): Fix build so documentation gets updated for
1085 rpms (it was only done for .tgz builds).
1098 rpms (it was only done for .tgz builds).
1086
1099
1087 2004-08-10 Fernando Perez <fperez@colorado.edu>
1100 2004-08-10 Fernando Perez <fperez@colorado.edu>
1088
1101
1089 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1102 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1090
1103
1091 * iplib.py : Silence syntax error exceptions in tab-completion.
1104 * iplib.py : Silence syntax error exceptions in tab-completion.
1092
1105
1093 2004-08-05 Fernando Perez <fperez@colorado.edu>
1106 2004-08-05 Fernando Perez <fperez@colorado.edu>
1094
1107
1095 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1108 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1096 'color off' mark for continuation prompts. This was causing long
1109 'color off' mark for continuation prompts. This was causing long
1097 continuation lines to mis-wrap.
1110 continuation lines to mis-wrap.
1098
1111
1099 2004-08-01 Fernando Perez <fperez@colorado.edu>
1112 2004-08-01 Fernando Perez <fperez@colorado.edu>
1100
1113
1101 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1114 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1102 for building ipython to be a parameter. All this is necessary
1115 for building ipython to be a parameter. All this is necessary
1103 right now to have a multithreaded version, but this insane
1116 right now to have a multithreaded version, but this insane
1104 non-design will be cleaned up soon. For now, it's a hack that
1117 non-design will be cleaned up soon. For now, it's a hack that
1105 works.
1118 works.
1106
1119
1107 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1120 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1108 args in various places. No bugs so far, but it's a dangerous
1121 args in various places. No bugs so far, but it's a dangerous
1109 practice.
1122 practice.
1110
1123
1111 2004-07-31 Fernando Perez <fperez@colorado.edu>
1124 2004-07-31 Fernando Perez <fperez@colorado.edu>
1112
1125
1113 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1126 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1114 fix completion of files with dots in their names under most
1127 fix completion of files with dots in their names under most
1115 profiles (pysh was OK because the completion order is different).
1128 profiles (pysh was OK because the completion order is different).
1116
1129
1117 2004-07-27 Fernando Perez <fperez@colorado.edu>
1130 2004-07-27 Fernando Perez <fperez@colorado.edu>
1118
1131
1119 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1132 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1120 keywords manually, b/c the one in keyword.py was removed in python
1133 keywords manually, b/c the one in keyword.py was removed in python
1121 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1134 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1122 This is NOT a bug under python 2.3 and earlier.
1135 This is NOT a bug under python 2.3 and earlier.
1123
1136
1124 2004-07-26 Fernando Perez <fperez@colorado.edu>
1137 2004-07-26 Fernando Perez <fperez@colorado.edu>
1125
1138
1126 * IPython/ultraTB.py (VerboseTB.text): Add another
1139 * IPython/ultraTB.py (VerboseTB.text): Add another
1127 linecache.checkcache() call to try to prevent inspect.py from
1140 linecache.checkcache() call to try to prevent inspect.py from
1128 crashing under python 2.3. I think this fixes
1141 crashing under python 2.3. I think this fixes
1129 http://www.scipy.net/roundup/ipython/issue17.
1142 http://www.scipy.net/roundup/ipython/issue17.
1130
1143
1131 2004-07-26 *** Released version 0.6.2
1144 2004-07-26 *** Released version 0.6.2
1132
1145
1133 2004-07-26 Fernando Perez <fperez@colorado.edu>
1146 2004-07-26 Fernando Perez <fperez@colorado.edu>
1134
1147
1135 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1148 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1136 fail for any number.
1149 fail for any number.
1137 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1150 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1138 empty bookmarks.
1151 empty bookmarks.
1139
1152
1140 2004-07-26 *** Released version 0.6.1
1153 2004-07-26 *** Released version 0.6.1
1141
1154
1142 2004-07-26 Fernando Perez <fperez@colorado.edu>
1155 2004-07-26 Fernando Perez <fperez@colorado.edu>
1143
1156
1144 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1157 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1145
1158
1146 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1159 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1147 escaping '()[]{}' in filenames.
1160 escaping '()[]{}' in filenames.
1148
1161
1149 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1162 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1150 Python 2.2 users who lack a proper shlex.split.
1163 Python 2.2 users who lack a proper shlex.split.
1151
1164
1152 2004-07-19 Fernando Perez <fperez@colorado.edu>
1165 2004-07-19 Fernando Perez <fperez@colorado.edu>
1153
1166
1154 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1167 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1155 for reading readline's init file. I follow the normal chain:
1168 for reading readline's init file. I follow the normal chain:
1156 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1169 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1157 report by Mike Heeter. This closes
1170 report by Mike Heeter. This closes
1158 http://www.scipy.net/roundup/ipython/issue16.
1171 http://www.scipy.net/roundup/ipython/issue16.
1159
1172
1160 2004-07-18 Fernando Perez <fperez@colorado.edu>
1173 2004-07-18 Fernando Perez <fperez@colorado.edu>
1161
1174
1162 * IPython/iplib.py (__init__): Add better handling of '\' under
1175 * IPython/iplib.py (__init__): Add better handling of '\' under
1163 Win32 for filenames. After a patch by Ville.
1176 Win32 for filenames. After a patch by Ville.
1164
1177
1165 2004-07-17 Fernando Perez <fperez@colorado.edu>
1178 2004-07-17 Fernando Perez <fperez@colorado.edu>
1166
1179
1167 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1180 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1168 autocalling would be triggered for 'foo is bar' if foo is
1181 autocalling would be triggered for 'foo is bar' if foo is
1169 callable. I also cleaned up the autocall detection code to use a
1182 callable. I also cleaned up the autocall detection code to use a
1170 regexp, which is faster. Bug reported by Alexander Schmolck.
1183 regexp, which is faster. Bug reported by Alexander Schmolck.
1171
1184
1172 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1185 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1173 '?' in them would confuse the help system. Reported by Alex
1186 '?' in them would confuse the help system. Reported by Alex
1174 Schmolck.
1187 Schmolck.
1175
1188
1176 2004-07-16 Fernando Perez <fperez@colorado.edu>
1189 2004-07-16 Fernando Perez <fperez@colorado.edu>
1177
1190
1178 * IPython/GnuplotInteractive.py (__all__): added plot2.
1191 * IPython/GnuplotInteractive.py (__all__): added plot2.
1179
1192
1180 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1193 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1181 plotting dictionaries, lists or tuples of 1d arrays.
1194 plotting dictionaries, lists or tuples of 1d arrays.
1182
1195
1183 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1196 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1184 optimizations.
1197 optimizations.
1185
1198
1186 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1199 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1187 the information which was there from Janko's original IPP code:
1200 the information which was there from Janko's original IPP code:
1188
1201
1189 03.05.99 20:53 porto.ifm.uni-kiel.de
1202 03.05.99 20:53 porto.ifm.uni-kiel.de
1190 --Started changelog.
1203 --Started changelog.
1191 --make clear do what it say it does
1204 --make clear do what it say it does
1192 --added pretty output of lines from inputcache
1205 --added pretty output of lines from inputcache
1193 --Made Logger a mixin class, simplifies handling of switches
1206 --Made Logger a mixin class, simplifies handling of switches
1194 --Added own completer class. .string<TAB> expands to last history
1207 --Added own completer class. .string<TAB> expands to last history
1195 line which starts with string. The new expansion is also present
1208 line which starts with string. The new expansion is also present
1196 with Ctrl-r from the readline library. But this shows, who this
1209 with Ctrl-r from the readline library. But this shows, who this
1197 can be done for other cases.
1210 can be done for other cases.
1198 --Added convention that all shell functions should accept a
1211 --Added convention that all shell functions should accept a
1199 parameter_string This opens the door for different behaviour for
1212 parameter_string This opens the door for different behaviour for
1200 each function. @cd is a good example of this.
1213 each function. @cd is a good example of this.
1201
1214
1202 04.05.99 12:12 porto.ifm.uni-kiel.de
1215 04.05.99 12:12 porto.ifm.uni-kiel.de
1203 --added logfile rotation
1216 --added logfile rotation
1204 --added new mainloop method which freezes first the namespace
1217 --added new mainloop method which freezes first the namespace
1205
1218
1206 07.05.99 21:24 porto.ifm.uni-kiel.de
1219 07.05.99 21:24 porto.ifm.uni-kiel.de
1207 --added the docreader classes. Now there is a help system.
1220 --added the docreader classes. Now there is a help system.
1208 -This is only a first try. Currently it's not easy to put new
1221 -This is only a first try. Currently it's not easy to put new
1209 stuff in the indices. But this is the way to go. Info would be
1222 stuff in the indices. But this is the way to go. Info would be
1210 better, but HTML is every where and not everybody has an info
1223 better, but HTML is every where and not everybody has an info
1211 system installed and it's not so easy to change html-docs to info.
1224 system installed and it's not so easy to change html-docs to info.
1212 --added global logfile option
1225 --added global logfile option
1213 --there is now a hook for object inspection method pinfo needs to
1226 --there is now a hook for object inspection method pinfo needs to
1214 be provided for this. Can be reached by two '??'.
1227 be provided for this. Can be reached by two '??'.
1215
1228
1216 08.05.99 20:51 porto.ifm.uni-kiel.de
1229 08.05.99 20:51 porto.ifm.uni-kiel.de
1217 --added a README
1230 --added a README
1218 --bug in rc file. Something has changed so functions in the rc
1231 --bug in rc file. Something has changed so functions in the rc
1219 file need to reference the shell and not self. Not clear if it's a
1232 file need to reference the shell and not self. Not clear if it's a
1220 bug or feature.
1233 bug or feature.
1221 --changed rc file for new behavior
1234 --changed rc file for new behavior
1222
1235
1223 2004-07-15 Fernando Perez <fperez@colorado.edu>
1236 2004-07-15 Fernando Perez <fperez@colorado.edu>
1224
1237
1225 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1238 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1226 cache was falling out of sync in bizarre manners when multi-line
1239 cache was falling out of sync in bizarre manners when multi-line
1227 input was present. Minor optimizations and cleanup.
1240 input was present. Minor optimizations and cleanup.
1228
1241
1229 (Logger): Remove old Changelog info for cleanup. This is the
1242 (Logger): Remove old Changelog info for cleanup. This is the
1230 information which was there from Janko's original code:
1243 information which was there from Janko's original code:
1231
1244
1232 Changes to Logger: - made the default log filename a parameter
1245 Changes to Logger: - made the default log filename a parameter
1233
1246
1234 - put a check for lines beginning with !@? in log(). Needed
1247 - put a check for lines beginning with !@? in log(). Needed
1235 (even if the handlers properly log their lines) for mid-session
1248 (even if the handlers properly log their lines) for mid-session
1236 logging activation to work properly. Without this, lines logged
1249 logging activation to work properly. Without this, lines logged
1237 in mid session, which get read from the cache, would end up
1250 in mid session, which get read from the cache, would end up
1238 'bare' (with !@? in the open) in the log. Now they are caught
1251 'bare' (with !@? in the open) in the log. Now they are caught
1239 and prepended with a #.
1252 and prepended with a #.
1240
1253
1241 * IPython/iplib.py (InteractiveShell.init_readline): added check
1254 * IPython/iplib.py (InteractiveShell.init_readline): added check
1242 in case MagicCompleter fails to be defined, so we don't crash.
1255 in case MagicCompleter fails to be defined, so we don't crash.
1243
1256
1244 2004-07-13 Fernando Perez <fperez@colorado.edu>
1257 2004-07-13 Fernando Perez <fperez@colorado.edu>
1245
1258
1246 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1259 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1247 of EPS if the requested filename ends in '.eps'.
1260 of EPS if the requested filename ends in '.eps'.
1248
1261
1249 2004-07-04 Fernando Perez <fperez@colorado.edu>
1262 2004-07-04 Fernando Perez <fperez@colorado.edu>
1250
1263
1251 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1264 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1252 escaping of quotes when calling the shell.
1265 escaping of quotes when calling the shell.
1253
1266
1254 2004-07-02 Fernando Perez <fperez@colorado.edu>
1267 2004-07-02 Fernando Perez <fperez@colorado.edu>
1255
1268
1256 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1269 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1257 gettext not working because we were clobbering '_'. Fixes
1270 gettext not working because we were clobbering '_'. Fixes
1258 http://www.scipy.net/roundup/ipython/issue6.
1271 http://www.scipy.net/roundup/ipython/issue6.
1259
1272
1260 2004-07-01 Fernando Perez <fperez@colorado.edu>
1273 2004-07-01 Fernando Perez <fperez@colorado.edu>
1261
1274
1262 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1275 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1263 into @cd. Patch by Ville.
1276 into @cd. Patch by Ville.
1264
1277
1265 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1278 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1266 new function to store things after ipmaker runs. Patch by Ville.
1279 new function to store things after ipmaker runs. Patch by Ville.
1267 Eventually this will go away once ipmaker is removed and the class
1280 Eventually this will go away once ipmaker is removed and the class
1268 gets cleaned up, but for now it's ok. Key functionality here is
1281 gets cleaned up, but for now it's ok. Key functionality here is
1269 the addition of the persistent storage mechanism, a dict for
1282 the addition of the persistent storage mechanism, a dict for
1270 keeping data across sessions (for now just bookmarks, but more can
1283 keeping data across sessions (for now just bookmarks, but more can
1271 be implemented later).
1284 be implemented later).
1272
1285
1273 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1286 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1274 persistent across sections. Patch by Ville, I modified it
1287 persistent across sections. Patch by Ville, I modified it
1275 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1288 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1276 added a '-l' option to list all bookmarks.
1289 added a '-l' option to list all bookmarks.
1277
1290
1278 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1291 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1279 center for cleanup. Registered with atexit.register(). I moved
1292 center for cleanup. Registered with atexit.register(). I moved
1280 here the old exit_cleanup(). After a patch by Ville.
1293 here the old exit_cleanup(). After a patch by Ville.
1281
1294
1282 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1295 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1283 characters in the hacked shlex_split for python 2.2.
1296 characters in the hacked shlex_split for python 2.2.
1284
1297
1285 * IPython/iplib.py (file_matches): more fixes to filenames with
1298 * IPython/iplib.py (file_matches): more fixes to filenames with
1286 whitespace in them. It's not perfect, but limitations in python's
1299 whitespace in them. It's not perfect, but limitations in python's
1287 readline make it impossible to go further.
1300 readline make it impossible to go further.
1288
1301
1289 2004-06-29 Fernando Perez <fperez@colorado.edu>
1302 2004-06-29 Fernando Perez <fperez@colorado.edu>
1290
1303
1291 * IPython/iplib.py (file_matches): escape whitespace correctly in
1304 * IPython/iplib.py (file_matches): escape whitespace correctly in
1292 filename completions. Bug reported by Ville.
1305 filename completions. Bug reported by Ville.
1293
1306
1294 2004-06-28 Fernando Perez <fperez@colorado.edu>
1307 2004-06-28 Fernando Perez <fperez@colorado.edu>
1295
1308
1296 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1309 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1297 the history file will be called 'history-PROFNAME' (or just
1310 the history file will be called 'history-PROFNAME' (or just
1298 'history' if no profile is loaded). I was getting annoyed at
1311 'history' if no profile is loaded). I was getting annoyed at
1299 getting my Numerical work history clobbered by pysh sessions.
1312 getting my Numerical work history clobbered by pysh sessions.
1300
1313
1301 * IPython/iplib.py (InteractiveShell.__init__): Internal
1314 * IPython/iplib.py (InteractiveShell.__init__): Internal
1302 getoutputerror() function so that we can honor the system_verbose
1315 getoutputerror() function so that we can honor the system_verbose
1303 flag for _all_ system calls. I also added escaping of #
1316 flag for _all_ system calls. I also added escaping of #
1304 characters here to avoid confusing Itpl.
1317 characters here to avoid confusing Itpl.
1305
1318
1306 * IPython/Magic.py (shlex_split): removed call to shell in
1319 * IPython/Magic.py (shlex_split): removed call to shell in
1307 parse_options and replaced it with shlex.split(). The annoying
1320 parse_options and replaced it with shlex.split(). The annoying
1308 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1321 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1309 to backport it from 2.3, with several frail hacks (the shlex
1322 to backport it from 2.3, with several frail hacks (the shlex
1310 module is rather limited in 2.2). Thanks to a suggestion by Ville
1323 module is rather limited in 2.2). Thanks to a suggestion by Ville
1311 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1324 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1312 problem.
1325 problem.
1313
1326
1314 (Magic.magic_system_verbose): new toggle to print the actual
1327 (Magic.magic_system_verbose): new toggle to print the actual
1315 system calls made by ipython. Mainly for debugging purposes.
1328 system calls made by ipython. Mainly for debugging purposes.
1316
1329
1317 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1330 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1318 doesn't support persistence. Reported (and fix suggested) by
1331 doesn't support persistence. Reported (and fix suggested) by
1319 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1332 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1320
1333
1321 2004-06-26 Fernando Perez <fperez@colorado.edu>
1334 2004-06-26 Fernando Perez <fperez@colorado.edu>
1322
1335
1323 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1336 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1324 continue prompts.
1337 continue prompts.
1325
1338
1326 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1339 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1327 function (basically a big docstring) and a few more things here to
1340 function (basically a big docstring) and a few more things here to
1328 speedup startup. pysh.py is now very lightweight. We want because
1341 speedup startup. pysh.py is now very lightweight. We want because
1329 it gets execfile'd, while InterpreterExec gets imported, so
1342 it gets execfile'd, while InterpreterExec gets imported, so
1330 byte-compilation saves time.
1343 byte-compilation saves time.
1331
1344
1332 2004-06-25 Fernando Perez <fperez@colorado.edu>
1345 2004-06-25 Fernando Perez <fperez@colorado.edu>
1333
1346
1334 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1347 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1335 -NUM', which was recently broken.
1348 -NUM', which was recently broken.
1336
1349
1337 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1350 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1338 in multi-line input (but not !!, which doesn't make sense there).
1351 in multi-line input (but not !!, which doesn't make sense there).
1339
1352
1340 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1353 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1341 It's just too useful, and people can turn it off in the less
1354 It's just too useful, and people can turn it off in the less
1342 common cases where it's a problem.
1355 common cases where it's a problem.
1343
1356
1344 2004-06-24 Fernando Perez <fperez@colorado.edu>
1357 2004-06-24 Fernando Perez <fperez@colorado.edu>
1345
1358
1346 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1359 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1347 special syntaxes (like alias calling) is now allied in multi-line
1360 special syntaxes (like alias calling) is now allied in multi-line
1348 input. This is still _very_ experimental, but it's necessary for
1361 input. This is still _very_ experimental, but it's necessary for
1349 efficient shell usage combining python looping syntax with system
1362 efficient shell usage combining python looping syntax with system
1350 calls. For now it's restricted to aliases, I don't think it
1363 calls. For now it's restricted to aliases, I don't think it
1351 really even makes sense to have this for magics.
1364 really even makes sense to have this for magics.
1352
1365
1353 2004-06-23 Fernando Perez <fperez@colorado.edu>
1366 2004-06-23 Fernando Perez <fperez@colorado.edu>
1354
1367
1355 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1368 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1356 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1369 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1357
1370
1358 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1371 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1359 extensions under Windows (after code sent by Gary Bishop). The
1372 extensions under Windows (after code sent by Gary Bishop). The
1360 extensions considered 'executable' are stored in IPython's rc
1373 extensions considered 'executable' are stored in IPython's rc
1361 structure as win_exec_ext.
1374 structure as win_exec_ext.
1362
1375
1363 * IPython/genutils.py (shell): new function, like system() but
1376 * IPython/genutils.py (shell): new function, like system() but
1364 without return value. Very useful for interactive shell work.
1377 without return value. Very useful for interactive shell work.
1365
1378
1366 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1379 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1367 delete aliases.
1380 delete aliases.
1368
1381
1369 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1382 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1370 sure that the alias table doesn't contain python keywords.
1383 sure that the alias table doesn't contain python keywords.
1371
1384
1372 2004-06-21 Fernando Perez <fperez@colorado.edu>
1385 2004-06-21 Fernando Perez <fperez@colorado.edu>
1373
1386
1374 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1387 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1375 non-existent items are found in $PATH. Reported by Thorsten.
1388 non-existent items are found in $PATH. Reported by Thorsten.
1376
1389
1377 2004-06-20 Fernando Perez <fperez@colorado.edu>
1390 2004-06-20 Fernando Perez <fperez@colorado.edu>
1378
1391
1379 * IPython/iplib.py (complete): modified the completer so that the
1392 * IPython/iplib.py (complete): modified the completer so that the
1380 order of priorities can be easily changed at runtime.
1393 order of priorities can be easily changed at runtime.
1381
1394
1382 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1395 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1383 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1396 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1384
1397
1385 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1398 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1386 expand Python variables prepended with $ in all system calls. The
1399 expand Python variables prepended with $ in all system calls. The
1387 same was done to InteractiveShell.handle_shell_escape. Now all
1400 same was done to InteractiveShell.handle_shell_escape. Now all
1388 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1401 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1389 expansion of python variables and expressions according to the
1402 expansion of python variables and expressions according to the
1390 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1403 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1391
1404
1392 Though PEP-215 has been rejected, a similar (but simpler) one
1405 Though PEP-215 has been rejected, a similar (but simpler) one
1393 seems like it will go into Python 2.4, PEP-292 -
1406 seems like it will go into Python 2.4, PEP-292 -
1394 http://www.python.org/peps/pep-0292.html.
1407 http://www.python.org/peps/pep-0292.html.
1395
1408
1396 I'll keep the full syntax of PEP-215, since IPython has since the
1409 I'll keep the full syntax of PEP-215, since IPython has since the
1397 start used Ka-Ping Yee's reference implementation discussed there
1410 start used Ka-Ping Yee's reference implementation discussed there
1398 (Itpl), and I actually like the powerful semantics it offers.
1411 (Itpl), and I actually like the powerful semantics it offers.
1399
1412
1400 In order to access normal shell variables, the $ has to be escaped
1413 In order to access normal shell variables, the $ has to be escaped
1401 via an extra $. For example:
1414 via an extra $. For example:
1402
1415
1403 In [7]: PATH='a python variable'
1416 In [7]: PATH='a python variable'
1404
1417
1405 In [8]: !echo $PATH
1418 In [8]: !echo $PATH
1406 a python variable
1419 a python variable
1407
1420
1408 In [9]: !echo $$PATH
1421 In [9]: !echo $$PATH
1409 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1422 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1410
1423
1411 (Magic.parse_options): escape $ so the shell doesn't evaluate
1424 (Magic.parse_options): escape $ so the shell doesn't evaluate
1412 things prematurely.
1425 things prematurely.
1413
1426
1414 * IPython/iplib.py (InteractiveShell.call_alias): added the
1427 * IPython/iplib.py (InteractiveShell.call_alias): added the
1415 ability for aliases to expand python variables via $.
1428 ability for aliases to expand python variables via $.
1416
1429
1417 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1430 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1418 system, now there's a @rehash/@rehashx pair of magics. These work
1431 system, now there's a @rehash/@rehashx pair of magics. These work
1419 like the csh rehash command, and can be invoked at any time. They
1432 like the csh rehash command, and can be invoked at any time. They
1420 build a table of aliases to everything in the user's $PATH
1433 build a table of aliases to everything in the user's $PATH
1421 (@rehash uses everything, @rehashx is slower but only adds
1434 (@rehash uses everything, @rehashx is slower but only adds
1422 executable files). With this, the pysh.py-based shell profile can
1435 executable files). With this, the pysh.py-based shell profile can
1423 now simply call rehash upon startup, and full access to all
1436 now simply call rehash upon startup, and full access to all
1424 programs in the user's path is obtained.
1437 programs in the user's path is obtained.
1425
1438
1426 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1439 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1427 functionality is now fully in place. I removed the old dynamic
1440 functionality is now fully in place. I removed the old dynamic
1428 code generation based approach, in favor of a much lighter one
1441 code generation based approach, in favor of a much lighter one
1429 based on a simple dict. The advantage is that this allows me to
1442 based on a simple dict. The advantage is that this allows me to
1430 now have thousands of aliases with negligible cost (unthinkable
1443 now have thousands of aliases with negligible cost (unthinkable
1431 with the old system).
1444 with the old system).
1432
1445
1433 2004-06-19 Fernando Perez <fperez@colorado.edu>
1446 2004-06-19 Fernando Perez <fperez@colorado.edu>
1434
1447
1435 * IPython/iplib.py (__init__): extended MagicCompleter class to
1448 * IPython/iplib.py (__init__): extended MagicCompleter class to
1436 also complete (last in priority) on user aliases.
1449 also complete (last in priority) on user aliases.
1437
1450
1438 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1451 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1439 call to eval.
1452 call to eval.
1440 (ItplNS.__init__): Added a new class which functions like Itpl,
1453 (ItplNS.__init__): Added a new class which functions like Itpl,
1441 but allows configuring the namespace for the evaluation to occur
1454 but allows configuring the namespace for the evaluation to occur
1442 in.
1455 in.
1443
1456
1444 2004-06-18 Fernando Perez <fperez@colorado.edu>
1457 2004-06-18 Fernando Perez <fperez@colorado.edu>
1445
1458
1446 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1459 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1447 better message when 'exit' or 'quit' are typed (a common newbie
1460 better message when 'exit' or 'quit' are typed (a common newbie
1448 confusion).
1461 confusion).
1449
1462
1450 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1463 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1451 check for Windows users.
1464 check for Windows users.
1452
1465
1453 * IPython/iplib.py (InteractiveShell.user_setup): removed
1466 * IPython/iplib.py (InteractiveShell.user_setup): removed
1454 disabling of colors for Windows. I'll test at runtime and issue a
1467 disabling of colors for Windows. I'll test at runtime and issue a
1455 warning if Gary's readline isn't found, as to nudge users to
1468 warning if Gary's readline isn't found, as to nudge users to
1456 download it.
1469 download it.
1457
1470
1458 2004-06-16 Fernando Perez <fperez@colorado.edu>
1471 2004-06-16 Fernando Perez <fperez@colorado.edu>
1459
1472
1460 * IPython/genutils.py (Stream.__init__): changed to print errors
1473 * IPython/genutils.py (Stream.__init__): changed to print errors
1461 to sys.stderr. I had a circular dependency here. Now it's
1474 to sys.stderr. I had a circular dependency here. Now it's
1462 possible to run ipython as IDLE's shell (consider this pre-alpha,
1475 possible to run ipython as IDLE's shell (consider this pre-alpha,
1463 since true stdout things end up in the starting terminal instead
1476 since true stdout things end up in the starting terminal instead
1464 of IDLE's out).
1477 of IDLE's out).
1465
1478
1466 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1479 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1467 users who haven't # updated their prompt_in2 definitions. Remove
1480 users who haven't # updated their prompt_in2 definitions. Remove
1468 eventually.
1481 eventually.
1469 (multiple_replace): added credit to original ASPN recipe.
1482 (multiple_replace): added credit to original ASPN recipe.
1470
1483
1471 2004-06-15 Fernando Perez <fperez@colorado.edu>
1484 2004-06-15 Fernando Perez <fperez@colorado.edu>
1472
1485
1473 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1486 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1474 list of auto-defined aliases.
1487 list of auto-defined aliases.
1475
1488
1476 2004-06-13 Fernando Perez <fperez@colorado.edu>
1489 2004-06-13 Fernando Perez <fperez@colorado.edu>
1477
1490
1478 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1491 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1479 install was really requested (so setup.py can be used for other
1492 install was really requested (so setup.py can be used for other
1480 things under Windows).
1493 things under Windows).
1481
1494
1482 2004-06-10 Fernando Perez <fperez@colorado.edu>
1495 2004-06-10 Fernando Perez <fperez@colorado.edu>
1483
1496
1484 * IPython/Logger.py (Logger.create_log): Manually remove any old
1497 * IPython/Logger.py (Logger.create_log): Manually remove any old
1485 backup, since os.remove may fail under Windows. Fixes bug
1498 backup, since os.remove may fail under Windows. Fixes bug
1486 reported by Thorsten.
1499 reported by Thorsten.
1487
1500
1488 2004-06-09 Fernando Perez <fperez@colorado.edu>
1501 2004-06-09 Fernando Perez <fperez@colorado.edu>
1489
1502
1490 * examples/example-embed.py: fixed all references to %n (replaced
1503 * examples/example-embed.py: fixed all references to %n (replaced
1491 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1504 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1492 for all examples and the manual as well.
1505 for all examples and the manual as well.
1493
1506
1494 2004-06-08 Fernando Perez <fperez@colorado.edu>
1507 2004-06-08 Fernando Perez <fperez@colorado.edu>
1495
1508
1496 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1509 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1497 alignment and color management. All 3 prompt subsystems now
1510 alignment and color management. All 3 prompt subsystems now
1498 inherit from BasePrompt.
1511 inherit from BasePrompt.
1499
1512
1500 * tools/release: updates for windows installer build and tag rpms
1513 * tools/release: updates for windows installer build and tag rpms
1501 with python version (since paths are fixed).
1514 with python version (since paths are fixed).
1502
1515
1503 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1516 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1504 which will become eventually obsolete. Also fixed the default
1517 which will become eventually obsolete. Also fixed the default
1505 prompt_in2 to use \D, so at least new users start with the correct
1518 prompt_in2 to use \D, so at least new users start with the correct
1506 defaults.
1519 defaults.
1507 WARNING: Users with existing ipythonrc files will need to apply
1520 WARNING: Users with existing ipythonrc files will need to apply
1508 this fix manually!
1521 this fix manually!
1509
1522
1510 * setup.py: make windows installer (.exe). This is finally the
1523 * setup.py: make windows installer (.exe). This is finally the
1511 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1524 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1512 which I hadn't included because it required Python 2.3 (or recent
1525 which I hadn't included because it required Python 2.3 (or recent
1513 distutils).
1526 distutils).
1514
1527
1515 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1528 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1516 usage of new '\D' escape.
1529 usage of new '\D' escape.
1517
1530
1518 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1531 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1519 lacks os.getuid())
1532 lacks os.getuid())
1520 (CachedOutput.set_colors): Added the ability to turn coloring
1533 (CachedOutput.set_colors): Added the ability to turn coloring
1521 on/off with @colors even for manually defined prompt colors. It
1534 on/off with @colors even for manually defined prompt colors. It
1522 uses a nasty global, but it works safely and via the generic color
1535 uses a nasty global, but it works safely and via the generic color
1523 handling mechanism.
1536 handling mechanism.
1524 (Prompt2.__init__): Introduced new escape '\D' for continuation
1537 (Prompt2.__init__): Introduced new escape '\D' for continuation
1525 prompts. It represents the counter ('\#') as dots.
1538 prompts. It represents the counter ('\#') as dots.
1526 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1539 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1527 need to update their ipythonrc files and replace '%n' with '\D' in
1540 need to update their ipythonrc files and replace '%n' with '\D' in
1528 their prompt_in2 settings everywhere. Sorry, but there's
1541 their prompt_in2 settings everywhere. Sorry, but there's
1529 otherwise no clean way to get all prompts to properly align. The
1542 otherwise no clean way to get all prompts to properly align. The
1530 ipythonrc shipped with IPython has been updated.
1543 ipythonrc shipped with IPython has been updated.
1531
1544
1532 2004-06-07 Fernando Perez <fperez@colorado.edu>
1545 2004-06-07 Fernando Perez <fperez@colorado.edu>
1533
1546
1534 * setup.py (isfile): Pass local_icons option to latex2html, so the
1547 * setup.py (isfile): Pass local_icons option to latex2html, so the
1535 resulting HTML file is self-contained. Thanks to
1548 resulting HTML file is self-contained. Thanks to
1536 dryice-AT-liu.com.cn for the tip.
1549 dryice-AT-liu.com.cn for the tip.
1537
1550
1538 * pysh.py: I created a new profile 'shell', which implements a
1551 * pysh.py: I created a new profile 'shell', which implements a
1539 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1552 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1540 system shell, nor will it become one anytime soon. It's mainly
1553 system shell, nor will it become one anytime soon. It's mainly
1541 meant to illustrate the use of the new flexible bash-like prompts.
1554 meant to illustrate the use of the new flexible bash-like prompts.
1542 I guess it could be used by hardy souls for true shell management,
1555 I guess it could be used by hardy souls for true shell management,
1543 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1556 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1544 profile. This uses the InterpreterExec extension provided by
1557 profile. This uses the InterpreterExec extension provided by
1545 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1558 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1546
1559
1547 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1560 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1548 auto-align itself with the length of the previous input prompt
1561 auto-align itself with the length of the previous input prompt
1549 (taking into account the invisible color escapes).
1562 (taking into account the invisible color escapes).
1550 (CachedOutput.__init__): Large restructuring of this class. Now
1563 (CachedOutput.__init__): Large restructuring of this class. Now
1551 all three prompts (primary1, primary2, output) are proper objects,
1564 all three prompts (primary1, primary2, output) are proper objects,
1552 managed by the 'parent' CachedOutput class. The code is still a
1565 managed by the 'parent' CachedOutput class. The code is still a
1553 bit hackish (all prompts share state via a pointer to the cache),
1566 bit hackish (all prompts share state via a pointer to the cache),
1554 but it's overall far cleaner than before.
1567 but it's overall far cleaner than before.
1555
1568
1556 * IPython/genutils.py (getoutputerror): modified to add verbose,
1569 * IPython/genutils.py (getoutputerror): modified to add verbose,
1557 debug and header options. This makes the interface of all getout*
1570 debug and header options. This makes the interface of all getout*
1558 functions uniform.
1571 functions uniform.
1559 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1572 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1560
1573
1561 * IPython/Magic.py (Magic.default_option): added a function to
1574 * IPython/Magic.py (Magic.default_option): added a function to
1562 allow registering default options for any magic command. This
1575 allow registering default options for any magic command. This
1563 makes it easy to have profiles which customize the magics globally
1576 makes it easy to have profiles which customize the magics globally
1564 for a certain use. The values set through this function are
1577 for a certain use. The values set through this function are
1565 picked up by the parse_options() method, which all magics should
1578 picked up by the parse_options() method, which all magics should
1566 use to parse their options.
1579 use to parse their options.
1567
1580
1568 * IPython/genutils.py (warn): modified the warnings framework to
1581 * IPython/genutils.py (warn): modified the warnings framework to
1569 use the Term I/O class. I'm trying to slowly unify all of
1582 use the Term I/O class. I'm trying to slowly unify all of
1570 IPython's I/O operations to pass through Term.
1583 IPython's I/O operations to pass through Term.
1571
1584
1572 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1585 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1573 the secondary prompt to correctly match the length of the primary
1586 the secondary prompt to correctly match the length of the primary
1574 one for any prompt. Now multi-line code will properly line up
1587 one for any prompt. Now multi-line code will properly line up
1575 even for path dependent prompts, such as the new ones available
1588 even for path dependent prompts, such as the new ones available
1576 via the prompt_specials.
1589 via the prompt_specials.
1577
1590
1578 2004-06-06 Fernando Perez <fperez@colorado.edu>
1591 2004-06-06 Fernando Perez <fperez@colorado.edu>
1579
1592
1580 * IPython/Prompts.py (prompt_specials): Added the ability to have
1593 * IPython/Prompts.py (prompt_specials): Added the ability to have
1581 bash-like special sequences in the prompts, which get
1594 bash-like special sequences in the prompts, which get
1582 automatically expanded. Things like hostname, current working
1595 automatically expanded. Things like hostname, current working
1583 directory and username are implemented already, but it's easy to
1596 directory and username are implemented already, but it's easy to
1584 add more in the future. Thanks to a patch by W.J. van der Laan
1597 add more in the future. Thanks to a patch by W.J. van der Laan
1585 <gnufnork-AT-hetdigitalegat.nl>
1598 <gnufnork-AT-hetdigitalegat.nl>
1586 (prompt_specials): Added color support for prompt strings, so
1599 (prompt_specials): Added color support for prompt strings, so
1587 users can define arbitrary color setups for their prompts.
1600 users can define arbitrary color setups for their prompts.
1588
1601
1589 2004-06-05 Fernando Perez <fperez@colorado.edu>
1602 2004-06-05 Fernando Perez <fperez@colorado.edu>
1590
1603
1591 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1604 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1592 code to load Gary Bishop's readline and configure it
1605 code to load Gary Bishop's readline and configure it
1593 automatically. Thanks to Gary for help on this.
1606 automatically. Thanks to Gary for help on this.
1594
1607
1595 2004-06-01 Fernando Perez <fperez@colorado.edu>
1608 2004-06-01 Fernando Perez <fperez@colorado.edu>
1596
1609
1597 * IPython/Logger.py (Logger.create_log): fix bug for logging
1610 * IPython/Logger.py (Logger.create_log): fix bug for logging
1598 with no filename (previous fix was incomplete).
1611 with no filename (previous fix was incomplete).
1599
1612
1600 2004-05-25 Fernando Perez <fperez@colorado.edu>
1613 2004-05-25 Fernando Perez <fperez@colorado.edu>
1601
1614
1602 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1615 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1603 parens would get passed to the shell.
1616 parens would get passed to the shell.
1604
1617
1605 2004-05-20 Fernando Perez <fperez@colorado.edu>
1618 2004-05-20 Fernando Perez <fperez@colorado.edu>
1606
1619
1607 * IPython/Magic.py (Magic.magic_prun): changed default profile
1620 * IPython/Magic.py (Magic.magic_prun): changed default profile
1608 sort order to 'time' (the more common profiling need).
1621 sort order to 'time' (the more common profiling need).
1609
1622
1610 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1623 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1611 so that source code shown is guaranteed in sync with the file on
1624 so that source code shown is guaranteed in sync with the file on
1612 disk (also changed in psource). Similar fix to the one for
1625 disk (also changed in psource). Similar fix to the one for
1613 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1626 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1614 <yann.ledu-AT-noos.fr>.
1627 <yann.ledu-AT-noos.fr>.
1615
1628
1616 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1629 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1617 with a single option would not be correctly parsed. Closes
1630 with a single option would not be correctly parsed. Closes
1618 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1631 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1619 introduced in 0.6.0 (on 2004-05-06).
1632 introduced in 0.6.0 (on 2004-05-06).
1620
1633
1621 2004-05-13 *** Released version 0.6.0
1634 2004-05-13 *** Released version 0.6.0
1622
1635
1623 2004-05-13 Fernando Perez <fperez@colorado.edu>
1636 2004-05-13 Fernando Perez <fperez@colorado.edu>
1624
1637
1625 * debian/: Added debian/ directory to CVS, so that debian support
1638 * debian/: Added debian/ directory to CVS, so that debian support
1626 is publicly accessible. The debian package is maintained by Jack
1639 is publicly accessible. The debian package is maintained by Jack
1627 Moffit <jack-AT-xiph.org>.
1640 Moffit <jack-AT-xiph.org>.
1628
1641
1629 * Documentation: included the notes about an ipython-based system
1642 * Documentation: included the notes about an ipython-based system
1630 shell (the hypothetical 'pysh') into the new_design.pdf document,
1643 shell (the hypothetical 'pysh') into the new_design.pdf document,
1631 so that these ideas get distributed to users along with the
1644 so that these ideas get distributed to users along with the
1632 official documentation.
1645 official documentation.
1633
1646
1634 2004-05-10 Fernando Perez <fperez@colorado.edu>
1647 2004-05-10 Fernando Perez <fperez@colorado.edu>
1635
1648
1636 * IPython/Logger.py (Logger.create_log): fix recently introduced
1649 * IPython/Logger.py (Logger.create_log): fix recently introduced
1637 bug (misindented line) where logstart would fail when not given an
1650 bug (misindented line) where logstart would fail when not given an
1638 explicit filename.
1651 explicit filename.
1639
1652
1640 2004-05-09 Fernando Perez <fperez@colorado.edu>
1653 2004-05-09 Fernando Perez <fperez@colorado.edu>
1641
1654
1642 * IPython/Magic.py (Magic.parse_options): skip system call when
1655 * IPython/Magic.py (Magic.parse_options): skip system call when
1643 there are no options to look for. Faster, cleaner for the common
1656 there are no options to look for. Faster, cleaner for the common
1644 case.
1657 case.
1645
1658
1646 * Documentation: many updates to the manual: describing Windows
1659 * Documentation: many updates to the manual: describing Windows
1647 support better, Gnuplot updates, credits, misc small stuff. Also
1660 support better, Gnuplot updates, credits, misc small stuff. Also
1648 updated the new_design doc a bit.
1661 updated the new_design doc a bit.
1649
1662
1650 2004-05-06 *** Released version 0.6.0.rc1
1663 2004-05-06 *** Released version 0.6.0.rc1
1651
1664
1652 2004-05-06 Fernando Perez <fperez@colorado.edu>
1665 2004-05-06 Fernando Perez <fperez@colorado.edu>
1653
1666
1654 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1667 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1655 operations to use the vastly more efficient list/''.join() method.
1668 operations to use the vastly more efficient list/''.join() method.
1656 (FormattedTB.text): Fix
1669 (FormattedTB.text): Fix
1657 http://www.scipy.net/roundup/ipython/issue12 - exception source
1670 http://www.scipy.net/roundup/ipython/issue12 - exception source
1658 extract not updated after reload. Thanks to Mike Salib
1671 extract not updated after reload. Thanks to Mike Salib
1659 <msalib-AT-mit.edu> for pinning the source of the problem.
1672 <msalib-AT-mit.edu> for pinning the source of the problem.
1660 Fortunately, the solution works inside ipython and doesn't require
1673 Fortunately, the solution works inside ipython and doesn't require
1661 any changes to python proper.
1674 any changes to python proper.
1662
1675
1663 * IPython/Magic.py (Magic.parse_options): Improved to process the
1676 * IPython/Magic.py (Magic.parse_options): Improved to process the
1664 argument list as a true shell would (by actually using the
1677 argument list as a true shell would (by actually using the
1665 underlying system shell). This way, all @magics automatically get
1678 underlying system shell). This way, all @magics automatically get
1666 shell expansion for variables. Thanks to a comment by Alex
1679 shell expansion for variables. Thanks to a comment by Alex
1667 Schmolck.
1680 Schmolck.
1668
1681
1669 2004-04-04 Fernando Perez <fperez@colorado.edu>
1682 2004-04-04 Fernando Perez <fperez@colorado.edu>
1670
1683
1671 * IPython/iplib.py (InteractiveShell.interact): Added a special
1684 * IPython/iplib.py (InteractiveShell.interact): Added a special
1672 trap for a debugger quit exception, which is basically impossible
1685 trap for a debugger quit exception, which is basically impossible
1673 to handle by normal mechanisms, given what pdb does to the stack.
1686 to handle by normal mechanisms, given what pdb does to the stack.
1674 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1687 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1675
1688
1676 2004-04-03 Fernando Perez <fperez@colorado.edu>
1689 2004-04-03 Fernando Perez <fperez@colorado.edu>
1677
1690
1678 * IPython/genutils.py (Term): Standardized the names of the Term
1691 * IPython/genutils.py (Term): Standardized the names of the Term
1679 class streams to cin/cout/cerr, following C++ naming conventions
1692 class streams to cin/cout/cerr, following C++ naming conventions
1680 (I can't use in/out/err because 'in' is not a valid attribute
1693 (I can't use in/out/err because 'in' is not a valid attribute
1681 name).
1694 name).
1682
1695
1683 * IPython/iplib.py (InteractiveShell.interact): don't increment
1696 * IPython/iplib.py (InteractiveShell.interact): don't increment
1684 the prompt if there's no user input. By Daniel 'Dang' Griffith
1697 the prompt if there's no user input. By Daniel 'Dang' Griffith
1685 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1698 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1686 Francois Pinard.
1699 Francois Pinard.
1687
1700
1688 2004-04-02 Fernando Perez <fperez@colorado.edu>
1701 2004-04-02 Fernando Perez <fperez@colorado.edu>
1689
1702
1690 * IPython/genutils.py (Stream.__init__): Modified to survive at
1703 * IPython/genutils.py (Stream.__init__): Modified to survive at
1691 least importing in contexts where stdin/out/err aren't true file
1704 least importing in contexts where stdin/out/err aren't true file
1692 objects, such as PyCrust (they lack fileno() and mode). However,
1705 objects, such as PyCrust (they lack fileno() and mode). However,
1693 the recovery facilities which rely on these things existing will
1706 the recovery facilities which rely on these things existing will
1694 not work.
1707 not work.
1695
1708
1696 2004-04-01 Fernando Perez <fperez@colorado.edu>
1709 2004-04-01 Fernando Perez <fperez@colorado.edu>
1697
1710
1698 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1711 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1699 use the new getoutputerror() function, so it properly
1712 use the new getoutputerror() function, so it properly
1700 distinguishes stdout/err.
1713 distinguishes stdout/err.
1701
1714
1702 * IPython/genutils.py (getoutputerror): added a function to
1715 * IPython/genutils.py (getoutputerror): added a function to
1703 capture separately the standard output and error of a command.
1716 capture separately the standard output and error of a command.
1704 After a comment from dang on the mailing lists. This code is
1717 After a comment from dang on the mailing lists. This code is
1705 basically a modified version of commands.getstatusoutput(), from
1718 basically a modified version of commands.getstatusoutput(), from
1706 the standard library.
1719 the standard library.
1707
1720
1708 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1721 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1709 '!!' as a special syntax (shorthand) to access @sx.
1722 '!!' as a special syntax (shorthand) to access @sx.
1710
1723
1711 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
1724 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
1712 command and return its output as a list split on '\n'.
1725 command and return its output as a list split on '\n'.
1713
1726
1714 2004-03-31 Fernando Perez <fperez@colorado.edu>
1727 2004-03-31 Fernando Perez <fperez@colorado.edu>
1715
1728
1716 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
1729 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
1717 method to dictionaries used as FakeModule instances if they lack
1730 method to dictionaries used as FakeModule instances if they lack
1718 it. At least pydoc in python2.3 breaks for runtime-defined
1731 it. At least pydoc in python2.3 breaks for runtime-defined
1719 functions without this hack. At some point I need to _really_
1732 functions without this hack. At some point I need to _really_
1720 understand what FakeModule is doing, because it's a gross hack.
1733 understand what FakeModule is doing, because it's a gross hack.
1721 But it solves Arnd's problem for now...
1734 But it solves Arnd's problem for now...
1722
1735
1723 2004-02-27 Fernando Perez <fperez@colorado.edu>
1736 2004-02-27 Fernando Perez <fperez@colorado.edu>
1724
1737
1725 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
1738 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
1726 mode would behave erratically. Also increased the number of
1739 mode would behave erratically. Also increased the number of
1727 possible logs in rotate mod to 999. Thanks to Rod Holland
1740 possible logs in rotate mod to 999. Thanks to Rod Holland
1728 <rhh@StructureLABS.com> for the report and fixes.
1741 <rhh@StructureLABS.com> for the report and fixes.
1729
1742
1730 2004-02-26 Fernando Perez <fperez@colorado.edu>
1743 2004-02-26 Fernando Perez <fperez@colorado.edu>
1731
1744
1732 * IPython/genutils.py (page): Check that the curses module really
1745 * IPython/genutils.py (page): Check that the curses module really
1733 has the initscr attribute before trying to use it. For some
1746 has the initscr attribute before trying to use it. For some
1734 reason, the Solaris curses module is missing this. I think this
1747 reason, the Solaris curses module is missing this. I think this
1735 should be considered a Solaris python bug, but I'm not sure.
1748 should be considered a Solaris python bug, but I'm not sure.
1736
1749
1737 2004-01-17 Fernando Perez <fperez@colorado.edu>
1750 2004-01-17 Fernando Perez <fperez@colorado.edu>
1738
1751
1739 * IPython/genutils.py (Stream.__init__): Changes to try to make
1752 * IPython/genutils.py (Stream.__init__): Changes to try to make
1740 ipython robust against stdin/out/err being closed by the user.
1753 ipython robust against stdin/out/err being closed by the user.
1741 This is 'user error' (and blocks a normal python session, at least
1754 This is 'user error' (and blocks a normal python session, at least
1742 the stdout case). However, Ipython should be able to survive such
1755 the stdout case). However, Ipython should be able to survive such
1743 instances of abuse as gracefully as possible. To simplify the
1756 instances of abuse as gracefully as possible. To simplify the
1744 coding and maintain compatibility with Gary Bishop's Term
1757 coding and maintain compatibility with Gary Bishop's Term
1745 contributions, I've made use of classmethods for this. I think
1758 contributions, I've made use of classmethods for this. I think
1746 this introduces a dependency on python 2.2.
1759 this introduces a dependency on python 2.2.
1747
1760
1748 2004-01-13 Fernando Perez <fperez@colorado.edu>
1761 2004-01-13 Fernando Perez <fperez@colorado.edu>
1749
1762
1750 * IPython/numutils.py (exp_safe): simplified the code a bit and
1763 * IPython/numutils.py (exp_safe): simplified the code a bit and
1751 removed the need for importing the kinds module altogether.
1764 removed the need for importing the kinds module altogether.
1752
1765
1753 2004-01-06 Fernando Perez <fperez@colorado.edu>
1766 2004-01-06 Fernando Perez <fperez@colorado.edu>
1754
1767
1755 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
1768 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
1756 a magic function instead, after some community feedback. No
1769 a magic function instead, after some community feedback. No
1757 special syntax will exist for it, but its name is deliberately
1770 special syntax will exist for it, but its name is deliberately
1758 very short.
1771 very short.
1759
1772
1760 2003-12-20 Fernando Perez <fperez@colorado.edu>
1773 2003-12-20 Fernando Perez <fperez@colorado.edu>
1761
1774
1762 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
1775 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
1763 new functionality, to automagically assign the result of a shell
1776 new functionality, to automagically assign the result of a shell
1764 command to a variable. I'll solicit some community feedback on
1777 command to a variable. I'll solicit some community feedback on
1765 this before making it permanent.
1778 this before making it permanent.
1766
1779
1767 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
1780 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
1768 requested about callables for which inspect couldn't obtain a
1781 requested about callables for which inspect couldn't obtain a
1769 proper argspec. Thanks to a crash report sent by Etienne
1782 proper argspec. Thanks to a crash report sent by Etienne
1770 Posthumus <etienne-AT-apple01.cs.vu.nl>.
1783 Posthumus <etienne-AT-apple01.cs.vu.nl>.
1771
1784
1772 2003-12-09 Fernando Perez <fperez@colorado.edu>
1785 2003-12-09 Fernando Perez <fperez@colorado.edu>
1773
1786
1774 * IPython/genutils.py (page): patch for the pager to work across
1787 * IPython/genutils.py (page): patch for the pager to work across
1775 various versions of Windows. By Gary Bishop.
1788 various versions of Windows. By Gary Bishop.
1776
1789
1777 2003-12-04 Fernando Perez <fperez@colorado.edu>
1790 2003-12-04 Fernando Perez <fperez@colorado.edu>
1778
1791
1779 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
1792 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
1780 Gnuplot.py version 1.7, whose internal names changed quite a bit.
1793 Gnuplot.py version 1.7, whose internal names changed quite a bit.
1781 While I tested this and it looks ok, there may still be corner
1794 While I tested this and it looks ok, there may still be corner
1782 cases I've missed.
1795 cases I've missed.
1783
1796
1784 2003-12-01 Fernando Perez <fperez@colorado.edu>
1797 2003-12-01 Fernando Perez <fperez@colorado.edu>
1785
1798
1786 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
1799 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
1787 where a line like 'p,q=1,2' would fail because the automagic
1800 where a line like 'p,q=1,2' would fail because the automagic
1788 system would be triggered for @p.
1801 system would be triggered for @p.
1789
1802
1790 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
1803 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
1791 cleanups, code unmodified.
1804 cleanups, code unmodified.
1792
1805
1793 * IPython/genutils.py (Term): added a class for IPython to handle
1806 * IPython/genutils.py (Term): added a class for IPython to handle
1794 output. In most cases it will just be a proxy for stdout/err, but
1807 output. In most cases it will just be a proxy for stdout/err, but
1795 having this allows modifications to be made for some platforms,
1808 having this allows modifications to be made for some platforms,
1796 such as handling color escapes under Windows. All of this code
1809 such as handling color escapes under Windows. All of this code
1797 was contributed by Gary Bishop, with minor modifications by me.
1810 was contributed by Gary Bishop, with minor modifications by me.
1798 The actual changes affect many files.
1811 The actual changes affect many files.
1799
1812
1800 2003-11-30 Fernando Perez <fperez@colorado.edu>
1813 2003-11-30 Fernando Perez <fperez@colorado.edu>
1801
1814
1802 * IPython/iplib.py (file_matches): new completion code, courtesy
1815 * IPython/iplib.py (file_matches): new completion code, courtesy
1803 of Jeff Collins. This enables filename completion again under
1816 of Jeff Collins. This enables filename completion again under
1804 python 2.3, which disabled it at the C level.
1817 python 2.3, which disabled it at the C level.
1805
1818
1806 2003-11-11 Fernando Perez <fperez@colorado.edu>
1819 2003-11-11 Fernando Perez <fperez@colorado.edu>
1807
1820
1808 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
1821 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
1809 for Numeric.array(map(...)), but often convenient.
1822 for Numeric.array(map(...)), but often convenient.
1810
1823
1811 2003-11-05 Fernando Perez <fperez@colorado.edu>
1824 2003-11-05 Fernando Perez <fperez@colorado.edu>
1812
1825
1813 * IPython/numutils.py (frange): Changed a call from int() to
1826 * IPython/numutils.py (frange): Changed a call from int() to
1814 int(round()) to prevent a problem reported with arange() in the
1827 int(round()) to prevent a problem reported with arange() in the
1815 numpy list.
1828 numpy list.
1816
1829
1817 2003-10-06 Fernando Perez <fperez@colorado.edu>
1830 2003-10-06 Fernando Perez <fperez@colorado.edu>
1818
1831
1819 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
1832 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
1820 prevent crashes if sys lacks an argv attribute (it happens with
1833 prevent crashes if sys lacks an argv attribute (it happens with
1821 embedded interpreters which build a bare-bones sys module).
1834 embedded interpreters which build a bare-bones sys module).
1822 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
1835 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
1823
1836
1824 2003-09-24 Fernando Perez <fperez@colorado.edu>
1837 2003-09-24 Fernando Perez <fperez@colorado.edu>
1825
1838
1826 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
1839 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
1827 to protect against poorly written user objects where __getattr__
1840 to protect against poorly written user objects where __getattr__
1828 raises exceptions other than AttributeError. Thanks to a bug
1841 raises exceptions other than AttributeError. Thanks to a bug
1829 report by Oliver Sander <osander-AT-gmx.de>.
1842 report by Oliver Sander <osander-AT-gmx.de>.
1830
1843
1831 * IPython/FakeModule.py (FakeModule.__repr__): this method was
1844 * IPython/FakeModule.py (FakeModule.__repr__): this method was
1832 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
1845 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
1833
1846
1834 2003-09-09 Fernando Perez <fperez@colorado.edu>
1847 2003-09-09 Fernando Perez <fperez@colorado.edu>
1835
1848
1836 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1849 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1837 unpacking a list whith a callable as first element would
1850 unpacking a list whith a callable as first element would
1838 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
1851 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
1839 Collins.
1852 Collins.
1840
1853
1841 2003-08-25 *** Released version 0.5.0
1854 2003-08-25 *** Released version 0.5.0
1842
1855
1843 2003-08-22 Fernando Perez <fperez@colorado.edu>
1856 2003-08-22 Fernando Perez <fperez@colorado.edu>
1844
1857
1845 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
1858 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
1846 improperly defined user exceptions. Thanks to feedback from Mark
1859 improperly defined user exceptions. Thanks to feedback from Mark
1847 Russell <mrussell-AT-verio.net>.
1860 Russell <mrussell-AT-verio.net>.
1848
1861
1849 2003-08-20 Fernando Perez <fperez@colorado.edu>
1862 2003-08-20 Fernando Perez <fperez@colorado.edu>
1850
1863
1851 * IPython/OInspect.py (Inspector.pinfo): changed String Form
1864 * IPython/OInspect.py (Inspector.pinfo): changed String Form
1852 printing so that it would print multi-line string forms starting
1865 printing so that it would print multi-line string forms starting
1853 with a new line. This way the formatting is better respected for
1866 with a new line. This way the formatting is better respected for
1854 objects which work hard to make nice string forms.
1867 objects which work hard to make nice string forms.
1855
1868
1856 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
1869 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
1857 autocall would overtake data access for objects with both
1870 autocall would overtake data access for objects with both
1858 __getitem__ and __call__.
1871 __getitem__ and __call__.
1859
1872
1860 2003-08-19 *** Released version 0.5.0-rc1
1873 2003-08-19 *** Released version 0.5.0-rc1
1861
1874
1862 2003-08-19 Fernando Perez <fperez@colorado.edu>
1875 2003-08-19 Fernando Perez <fperez@colorado.edu>
1863
1876
1864 * IPython/deep_reload.py (load_tail): single tiny change here
1877 * IPython/deep_reload.py (load_tail): single tiny change here
1865 seems to fix the long-standing bug of dreload() failing to work
1878 seems to fix the long-standing bug of dreload() failing to work
1866 for dotted names. But this module is pretty tricky, so I may have
1879 for dotted names. But this module is pretty tricky, so I may have
1867 missed some subtlety. Needs more testing!.
1880 missed some subtlety. Needs more testing!.
1868
1881
1869 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
1882 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
1870 exceptions which have badly implemented __str__ methods.
1883 exceptions which have badly implemented __str__ methods.
1871 (VerboseTB.text): harden against inspect.getinnerframes crashing,
1884 (VerboseTB.text): harden against inspect.getinnerframes crashing,
1872 which I've been getting reports about from Python 2.3 users. I
1885 which I've been getting reports about from Python 2.3 users. I
1873 wish I had a simple test case to reproduce the problem, so I could
1886 wish I had a simple test case to reproduce the problem, so I could
1874 either write a cleaner workaround or file a bug report if
1887 either write a cleaner workaround or file a bug report if
1875 necessary.
1888 necessary.
1876
1889
1877 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
1890 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
1878 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
1891 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
1879 a bug report by Tjabo Kloppenburg.
1892 a bug report by Tjabo Kloppenburg.
1880
1893
1881 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
1894 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
1882 crashes. Wrapped the pdb call in a blanket try/except, since pdb
1895 crashes. Wrapped the pdb call in a blanket try/except, since pdb
1883 seems rather unstable. Thanks to a bug report by Tjabo
1896 seems rather unstable. Thanks to a bug report by Tjabo
1884 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
1897 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
1885
1898
1886 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
1899 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
1887 this out soon because of the critical fixes in the inner loop for
1900 this out soon because of the critical fixes in the inner loop for
1888 generators.
1901 generators.
1889
1902
1890 * IPython/Magic.py (Magic.getargspec): removed. This (and
1903 * IPython/Magic.py (Magic.getargspec): removed. This (and
1891 _get_def) have been obsoleted by OInspect for a long time, I
1904 _get_def) have been obsoleted by OInspect for a long time, I
1892 hadn't noticed that they were dead code.
1905 hadn't noticed that they were dead code.
1893 (Magic._ofind): restored _ofind functionality for a few literals
1906 (Magic._ofind): restored _ofind functionality for a few literals
1894 (those in ["''",'""','[]','{}','()']). But it won't work anymore
1907 (those in ["''",'""','[]','{}','()']). But it won't work anymore
1895 for things like "hello".capitalize?, since that would require a
1908 for things like "hello".capitalize?, since that would require a
1896 potentially dangerous eval() again.
1909 potentially dangerous eval() again.
1897
1910
1898 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
1911 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
1899 logic a bit more to clean up the escapes handling and minimize the
1912 logic a bit more to clean up the escapes handling and minimize the
1900 use of _ofind to only necessary cases. The interactive 'feel' of
1913 use of _ofind to only necessary cases. The interactive 'feel' of
1901 IPython should have improved quite a bit with the changes in
1914 IPython should have improved quite a bit with the changes in
1902 _prefilter and _ofind (besides being far safer than before).
1915 _prefilter and _ofind (besides being far safer than before).
1903
1916
1904 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
1917 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
1905 obscure, never reported). Edit would fail to find the object to
1918 obscure, never reported). Edit would fail to find the object to
1906 edit under some circumstances.
1919 edit under some circumstances.
1907 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
1920 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
1908 which were causing double-calling of generators. Those eval calls
1921 which were causing double-calling of generators. Those eval calls
1909 were _very_ dangerous, since code with side effects could be
1922 were _very_ dangerous, since code with side effects could be
1910 triggered. As they say, 'eval is evil'... These were the
1923 triggered. As they say, 'eval is evil'... These were the
1911 nastiest evals in IPython. Besides, _ofind is now far simpler,
1924 nastiest evals in IPython. Besides, _ofind is now far simpler,
1912 and it should also be quite a bit faster. Its use of inspect is
1925 and it should also be quite a bit faster. Its use of inspect is
1913 also safer, so perhaps some of the inspect-related crashes I've
1926 also safer, so perhaps some of the inspect-related crashes I've
1914 seen lately with Python 2.3 might be taken care of. That will
1927 seen lately with Python 2.3 might be taken care of. That will
1915 need more testing.
1928 need more testing.
1916
1929
1917 2003-08-17 Fernando Perez <fperez@colorado.edu>
1930 2003-08-17 Fernando Perez <fperez@colorado.edu>
1918
1931
1919 * IPython/iplib.py (InteractiveShell._prefilter): significant
1932 * IPython/iplib.py (InteractiveShell._prefilter): significant
1920 simplifications to the logic for handling user escapes. Faster
1933 simplifications to the logic for handling user escapes. Faster
1921 and simpler code.
1934 and simpler code.
1922
1935
1923 2003-08-14 Fernando Perez <fperez@colorado.edu>
1936 2003-08-14 Fernando Perez <fperez@colorado.edu>
1924
1937
1925 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
1938 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
1926 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
1939 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
1927 but it should be quite a bit faster. And the recursive version
1940 but it should be quite a bit faster. And the recursive version
1928 generated O(log N) intermediate storage for all rank>1 arrays,
1941 generated O(log N) intermediate storage for all rank>1 arrays,
1929 even if they were contiguous.
1942 even if they were contiguous.
1930 (l1norm): Added this function.
1943 (l1norm): Added this function.
1931 (norm): Added this function for arbitrary norms (including
1944 (norm): Added this function for arbitrary norms (including
1932 l-infinity). l1 and l2 are still special cases for convenience
1945 l-infinity). l1 and l2 are still special cases for convenience
1933 and speed.
1946 and speed.
1934
1947
1935 2003-08-03 Fernando Perez <fperez@colorado.edu>
1948 2003-08-03 Fernando Perez <fperez@colorado.edu>
1936
1949
1937 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
1950 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
1938 exceptions, which now raise PendingDeprecationWarnings in Python
1951 exceptions, which now raise PendingDeprecationWarnings in Python
1939 2.3. There were some in Magic and some in Gnuplot2.
1952 2.3. There were some in Magic and some in Gnuplot2.
1940
1953
1941 2003-06-30 Fernando Perez <fperez@colorado.edu>
1954 2003-06-30 Fernando Perez <fperez@colorado.edu>
1942
1955
1943 * IPython/genutils.py (page): modified to call curses only for
1956 * IPython/genutils.py (page): modified to call curses only for
1944 terminals where TERM=='xterm'. After problems under many other
1957 terminals where TERM=='xterm'. After problems under many other
1945 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
1958 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
1946
1959
1947 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
1960 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
1948 would be triggered when readline was absent. This was just an old
1961 would be triggered when readline was absent. This was just an old
1949 debugging statement I'd forgotten to take out.
1962 debugging statement I'd forgotten to take out.
1950
1963
1951 2003-06-20 Fernando Perez <fperez@colorado.edu>
1964 2003-06-20 Fernando Perez <fperez@colorado.edu>
1952
1965
1953 * IPython/genutils.py (clock): modified to return only user time
1966 * IPython/genutils.py (clock): modified to return only user time
1954 (not counting system time), after a discussion on scipy. While
1967 (not counting system time), after a discussion on scipy. While
1955 system time may be a useful quantity occasionally, it may much
1968 system time may be a useful quantity occasionally, it may much
1956 more easily be skewed by occasional swapping or other similar
1969 more easily be skewed by occasional swapping or other similar
1957 activity.
1970 activity.
1958
1971
1959 2003-06-05 Fernando Perez <fperez@colorado.edu>
1972 2003-06-05 Fernando Perez <fperez@colorado.edu>
1960
1973
1961 * IPython/numutils.py (identity): new function, for building
1974 * IPython/numutils.py (identity): new function, for building
1962 arbitrary rank Kronecker deltas (mostly backwards compatible with
1975 arbitrary rank Kronecker deltas (mostly backwards compatible with
1963 Numeric.identity)
1976 Numeric.identity)
1964
1977
1965 2003-06-03 Fernando Perez <fperez@colorado.edu>
1978 2003-06-03 Fernando Perez <fperez@colorado.edu>
1966
1979
1967 * IPython/iplib.py (InteractiveShell.handle_magic): protect
1980 * IPython/iplib.py (InteractiveShell.handle_magic): protect
1968 arguments passed to magics with spaces, to allow trailing '\' to
1981 arguments passed to magics with spaces, to allow trailing '\' to
1969 work normally (mainly for Windows users).
1982 work normally (mainly for Windows users).
1970
1983
1971 2003-05-29 Fernando Perez <fperez@colorado.edu>
1984 2003-05-29 Fernando Perez <fperez@colorado.edu>
1972
1985
1973 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
1986 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
1974 instead of pydoc.help. This fixes a bizarre behavior where
1987 instead of pydoc.help. This fixes a bizarre behavior where
1975 printing '%s' % locals() would trigger the help system. Now
1988 printing '%s' % locals() would trigger the help system. Now
1976 ipython behaves like normal python does.
1989 ipython behaves like normal python does.
1977
1990
1978 Note that if one does 'from pydoc import help', the bizarre
1991 Note that if one does 'from pydoc import help', the bizarre
1979 behavior returns, but this will also happen in normal python, so
1992 behavior returns, but this will also happen in normal python, so
1980 it's not an ipython bug anymore (it has to do with how pydoc.help
1993 it's not an ipython bug anymore (it has to do with how pydoc.help
1981 is implemented).
1994 is implemented).
1982
1995
1983 2003-05-22 Fernando Perez <fperez@colorado.edu>
1996 2003-05-22 Fernando Perez <fperez@colorado.edu>
1984
1997
1985 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
1998 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
1986 return [] instead of None when nothing matches, also match to end
1999 return [] instead of None when nothing matches, also match to end
1987 of line. Patch by Gary Bishop.
2000 of line. Patch by Gary Bishop.
1988
2001
1989 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2002 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
1990 protection as before, for files passed on the command line. This
2003 protection as before, for files passed on the command line. This
1991 prevents the CrashHandler from kicking in if user files call into
2004 prevents the CrashHandler from kicking in if user files call into
1992 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2005 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
1993 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2006 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
1994
2007
1995 2003-05-20 *** Released version 0.4.0
2008 2003-05-20 *** Released version 0.4.0
1996
2009
1997 2003-05-20 Fernando Perez <fperez@colorado.edu>
2010 2003-05-20 Fernando Perez <fperez@colorado.edu>
1998
2011
1999 * setup.py: added support for manpages. It's a bit hackish b/c of
2012 * setup.py: added support for manpages. It's a bit hackish b/c of
2000 a bug in the way the bdist_rpm distutils target handles gzipped
2013 a bug in the way the bdist_rpm distutils target handles gzipped
2001 manpages, but it works. After a patch by Jack.
2014 manpages, but it works. After a patch by Jack.
2002
2015
2003 2003-05-19 Fernando Perez <fperez@colorado.edu>
2016 2003-05-19 Fernando Perez <fperez@colorado.edu>
2004
2017
2005 * IPython/numutils.py: added a mockup of the kinds module, since
2018 * IPython/numutils.py: added a mockup of the kinds module, since
2006 it was recently removed from Numeric. This way, numutils will
2019 it was recently removed from Numeric. This way, numutils will
2007 work for all users even if they are missing kinds.
2020 work for all users even if they are missing kinds.
2008
2021
2009 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2022 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2010 failure, which can occur with SWIG-wrapped extensions. After a
2023 failure, which can occur with SWIG-wrapped extensions. After a
2011 crash report from Prabhu.
2024 crash report from Prabhu.
2012
2025
2013 2003-05-16 Fernando Perez <fperez@colorado.edu>
2026 2003-05-16 Fernando Perez <fperez@colorado.edu>
2014
2027
2015 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2028 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2016 protect ipython from user code which may call directly
2029 protect ipython from user code which may call directly
2017 sys.excepthook (this looks like an ipython crash to the user, even
2030 sys.excepthook (this looks like an ipython crash to the user, even
2018 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2031 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2019 This is especially important to help users of WxWindows, but may
2032 This is especially important to help users of WxWindows, but may
2020 also be useful in other cases.
2033 also be useful in other cases.
2021
2034
2022 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2035 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2023 an optional tb_offset to be specified, and to preserve exception
2036 an optional tb_offset to be specified, and to preserve exception
2024 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2037 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2025
2038
2026 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2039 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2027
2040
2028 2003-05-15 Fernando Perez <fperez@colorado.edu>
2041 2003-05-15 Fernando Perez <fperez@colorado.edu>
2029
2042
2030 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2043 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2031 installing for a new user under Windows.
2044 installing for a new user under Windows.
2032
2045
2033 2003-05-12 Fernando Perez <fperez@colorado.edu>
2046 2003-05-12 Fernando Perez <fperez@colorado.edu>
2034
2047
2035 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2048 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2036 handler for Emacs comint-based lines. Currently it doesn't do
2049 handler for Emacs comint-based lines. Currently it doesn't do
2037 much (but importantly, it doesn't update the history cache). In
2050 much (but importantly, it doesn't update the history cache). In
2038 the future it may be expanded if Alex needs more functionality
2051 the future it may be expanded if Alex needs more functionality
2039 there.
2052 there.
2040
2053
2041 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2054 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2042 info to crash reports.
2055 info to crash reports.
2043
2056
2044 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2057 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2045 just like Python's -c. Also fixed crash with invalid -color
2058 just like Python's -c. Also fixed crash with invalid -color
2046 option value at startup. Thanks to Will French
2059 option value at startup. Thanks to Will French
2047 <wfrench-AT-bestweb.net> for the bug report.
2060 <wfrench-AT-bestweb.net> for the bug report.
2048
2061
2049 2003-05-09 Fernando Perez <fperez@colorado.edu>
2062 2003-05-09 Fernando Perez <fperez@colorado.edu>
2050
2063
2051 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2064 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2052 to EvalDict (it's a mapping, after all) and simplified its code
2065 to EvalDict (it's a mapping, after all) and simplified its code
2053 quite a bit, after a nice discussion on c.l.py where Gustavo
2066 quite a bit, after a nice discussion on c.l.py where Gustavo
2054 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2067 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2055
2068
2056 2003-04-30 Fernando Perez <fperez@colorado.edu>
2069 2003-04-30 Fernando Perez <fperez@colorado.edu>
2057
2070
2058 * IPython/genutils.py (timings_out): modified it to reduce its
2071 * IPython/genutils.py (timings_out): modified it to reduce its
2059 overhead in the common reps==1 case.
2072 overhead in the common reps==1 case.
2060
2073
2061 2003-04-29 Fernando Perez <fperez@colorado.edu>
2074 2003-04-29 Fernando Perez <fperez@colorado.edu>
2062
2075
2063 * IPython/genutils.py (timings_out): Modified to use the resource
2076 * IPython/genutils.py (timings_out): Modified to use the resource
2064 module, which avoids the wraparound problems of time.clock().
2077 module, which avoids the wraparound problems of time.clock().
2065
2078
2066 2003-04-17 *** Released version 0.2.15pre4
2079 2003-04-17 *** Released version 0.2.15pre4
2067
2080
2068 2003-04-17 Fernando Perez <fperez@colorado.edu>
2081 2003-04-17 Fernando Perez <fperez@colorado.edu>
2069
2082
2070 * setup.py (scriptfiles): Split windows-specific stuff over to a
2083 * setup.py (scriptfiles): Split windows-specific stuff over to a
2071 separate file, in an attempt to have a Windows GUI installer.
2084 separate file, in an attempt to have a Windows GUI installer.
2072 That didn't work, but part of the groundwork is done.
2085 That didn't work, but part of the groundwork is done.
2073
2086
2074 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2087 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2075 indent/unindent with 4 spaces. Particularly useful in combination
2088 indent/unindent with 4 spaces. Particularly useful in combination
2076 with the new auto-indent option.
2089 with the new auto-indent option.
2077
2090
2078 2003-04-16 Fernando Perez <fperez@colorado.edu>
2091 2003-04-16 Fernando Perez <fperez@colorado.edu>
2079
2092
2080 * IPython/Magic.py: various replacements of self.rc for
2093 * IPython/Magic.py: various replacements of self.rc for
2081 self.shell.rc. A lot more remains to be done to fully disentangle
2094 self.shell.rc. A lot more remains to be done to fully disentangle
2082 this class from the main Shell class.
2095 this class from the main Shell class.
2083
2096
2084 * IPython/GnuplotRuntime.py: added checks for mouse support so
2097 * IPython/GnuplotRuntime.py: added checks for mouse support so
2085 that we don't try to enable it if the current gnuplot doesn't
2098 that we don't try to enable it if the current gnuplot doesn't
2086 really support it. Also added checks so that we don't try to
2099 really support it. Also added checks so that we don't try to
2087 enable persist under Windows (where Gnuplot doesn't recognize the
2100 enable persist under Windows (where Gnuplot doesn't recognize the
2088 option).
2101 option).
2089
2102
2090 * IPython/iplib.py (InteractiveShell.interact): Added optional
2103 * IPython/iplib.py (InteractiveShell.interact): Added optional
2091 auto-indenting code, after a patch by King C. Shu
2104 auto-indenting code, after a patch by King C. Shu
2092 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2105 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2093 get along well with pasting indented code. If I ever figure out
2106 get along well with pasting indented code. If I ever figure out
2094 how to make that part go well, it will become on by default.
2107 how to make that part go well, it will become on by default.
2095
2108
2096 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2109 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2097 crash ipython if there was an unmatched '%' in the user's prompt
2110 crash ipython if there was an unmatched '%' in the user's prompt
2098 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2111 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2099
2112
2100 * IPython/iplib.py (InteractiveShell.interact): removed the
2113 * IPython/iplib.py (InteractiveShell.interact): removed the
2101 ability to ask the user whether he wants to crash or not at the
2114 ability to ask the user whether he wants to crash or not at the
2102 'last line' exception handler. Calling functions at that point
2115 'last line' exception handler. Calling functions at that point
2103 changes the stack, and the error reports would have incorrect
2116 changes the stack, and the error reports would have incorrect
2104 tracebacks.
2117 tracebacks.
2105
2118
2106 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2119 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2107 pass through a peger a pretty-printed form of any object. After a
2120 pass through a peger a pretty-printed form of any object. After a
2108 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2121 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2109
2122
2110 2003-04-14 Fernando Perez <fperez@colorado.edu>
2123 2003-04-14 Fernando Perez <fperez@colorado.edu>
2111
2124
2112 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2125 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2113 all files in ~ would be modified at first install (instead of
2126 all files in ~ would be modified at first install (instead of
2114 ~/.ipython). This could be potentially disastrous, as the
2127 ~/.ipython). This could be potentially disastrous, as the
2115 modification (make line-endings native) could damage binary files.
2128 modification (make line-endings native) could damage binary files.
2116
2129
2117 2003-04-10 Fernando Perez <fperez@colorado.edu>
2130 2003-04-10 Fernando Perez <fperez@colorado.edu>
2118
2131
2119 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2132 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2120 handle only lines which are invalid python. This now means that
2133 handle only lines which are invalid python. This now means that
2121 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2134 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2122 for the bug report.
2135 for the bug report.
2123
2136
2124 2003-04-01 Fernando Perez <fperez@colorado.edu>
2137 2003-04-01 Fernando Perez <fperez@colorado.edu>
2125
2138
2126 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2139 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2127 where failing to set sys.last_traceback would crash pdb.pm().
2140 where failing to set sys.last_traceback would crash pdb.pm().
2128 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2141 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2129 report.
2142 report.
2130
2143
2131 2003-03-25 Fernando Perez <fperez@colorado.edu>
2144 2003-03-25 Fernando Perez <fperez@colorado.edu>
2132
2145
2133 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2146 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2134 before printing it (it had a lot of spurious blank lines at the
2147 before printing it (it had a lot of spurious blank lines at the
2135 end).
2148 end).
2136
2149
2137 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2150 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2138 output would be sent 21 times! Obviously people don't use this
2151 output would be sent 21 times! Obviously people don't use this
2139 too often, or I would have heard about it.
2152 too often, or I would have heard about it.
2140
2153
2141 2003-03-24 Fernando Perez <fperez@colorado.edu>
2154 2003-03-24 Fernando Perez <fperez@colorado.edu>
2142
2155
2143 * setup.py (scriptfiles): renamed the data_files parameter from
2156 * setup.py (scriptfiles): renamed the data_files parameter from
2144 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2157 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2145 for the patch.
2158 for the patch.
2146
2159
2147 2003-03-20 Fernando Perez <fperez@colorado.edu>
2160 2003-03-20 Fernando Perez <fperez@colorado.edu>
2148
2161
2149 * IPython/genutils.py (error): added error() and fatal()
2162 * IPython/genutils.py (error): added error() and fatal()
2150 functions.
2163 functions.
2151
2164
2152 2003-03-18 *** Released version 0.2.15pre3
2165 2003-03-18 *** Released version 0.2.15pre3
2153
2166
2154 2003-03-18 Fernando Perez <fperez@colorado.edu>
2167 2003-03-18 Fernando Perez <fperez@colorado.edu>
2155
2168
2156 * setupext/install_data_ext.py
2169 * setupext/install_data_ext.py
2157 (install_data_ext.initialize_options): Class contributed by Jack
2170 (install_data_ext.initialize_options): Class contributed by Jack
2158 Moffit for fixing the old distutils hack. He is sending this to
2171 Moffit for fixing the old distutils hack. He is sending this to
2159 the distutils folks so in the future we may not need it as a
2172 the distutils folks so in the future we may not need it as a
2160 private fix.
2173 private fix.
2161
2174
2162 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2175 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2163 changes for Debian packaging. See his patch for full details.
2176 changes for Debian packaging. See his patch for full details.
2164 The old distutils hack of making the ipythonrc* files carry a
2177 The old distutils hack of making the ipythonrc* files carry a
2165 bogus .py extension is gone, at last. Examples were moved to a
2178 bogus .py extension is gone, at last. Examples were moved to a
2166 separate subdir under doc/, and the separate executable scripts
2179 separate subdir under doc/, and the separate executable scripts
2167 now live in their own directory. Overall a great cleanup. The
2180 now live in their own directory. Overall a great cleanup. The
2168 manual was updated to use the new files, and setup.py has been
2181 manual was updated to use the new files, and setup.py has been
2169 fixed for this setup.
2182 fixed for this setup.
2170
2183
2171 * IPython/PyColorize.py (Parser.usage): made non-executable and
2184 * IPython/PyColorize.py (Parser.usage): made non-executable and
2172 created a pycolor wrapper around it to be included as a script.
2185 created a pycolor wrapper around it to be included as a script.
2173
2186
2174 2003-03-12 *** Released version 0.2.15pre2
2187 2003-03-12 *** Released version 0.2.15pre2
2175
2188
2176 2003-03-12 Fernando Perez <fperez@colorado.edu>
2189 2003-03-12 Fernando Perez <fperez@colorado.edu>
2177
2190
2178 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2191 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2179 long-standing problem with garbage characters in some terminals.
2192 long-standing problem with garbage characters in some terminals.
2180 The issue was really that the \001 and \002 escapes must _only_ be
2193 The issue was really that the \001 and \002 escapes must _only_ be
2181 passed to input prompts (which call readline), but _never_ to
2194 passed to input prompts (which call readline), but _never_ to
2182 normal text to be printed on screen. I changed ColorANSI to have
2195 normal text to be printed on screen. I changed ColorANSI to have
2183 two classes: TermColors and InputTermColors, each with the
2196 two classes: TermColors and InputTermColors, each with the
2184 appropriate escapes for input prompts or normal text. The code in
2197 appropriate escapes for input prompts or normal text. The code in
2185 Prompts.py got slightly more complicated, but this very old and
2198 Prompts.py got slightly more complicated, but this very old and
2186 annoying bug is finally fixed.
2199 annoying bug is finally fixed.
2187
2200
2188 All the credit for nailing down the real origin of this problem
2201 All the credit for nailing down the real origin of this problem
2189 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2202 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2190 *Many* thanks to him for spending quite a bit of effort on this.
2203 *Many* thanks to him for spending quite a bit of effort on this.
2191
2204
2192 2003-03-05 *** Released version 0.2.15pre1
2205 2003-03-05 *** Released version 0.2.15pre1
2193
2206
2194 2003-03-03 Fernando Perez <fperez@colorado.edu>
2207 2003-03-03 Fernando Perez <fperez@colorado.edu>
2195
2208
2196 * IPython/FakeModule.py: Moved the former _FakeModule to a
2209 * IPython/FakeModule.py: Moved the former _FakeModule to a
2197 separate file, because it's also needed by Magic (to fix a similar
2210 separate file, because it's also needed by Magic (to fix a similar
2198 pickle-related issue in @run).
2211 pickle-related issue in @run).
2199
2212
2200 2003-03-02 Fernando Perez <fperez@colorado.edu>
2213 2003-03-02 Fernando Perez <fperez@colorado.edu>
2201
2214
2202 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2215 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2203 the autocall option at runtime.
2216 the autocall option at runtime.
2204 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2217 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2205 across Magic.py to start separating Magic from InteractiveShell.
2218 across Magic.py to start separating Magic from InteractiveShell.
2206 (Magic._ofind): Fixed to return proper namespace for dotted
2219 (Magic._ofind): Fixed to return proper namespace for dotted
2207 names. Before, a dotted name would always return 'not currently
2220 names. Before, a dotted name would always return 'not currently
2208 defined', because it would find the 'parent'. s.x would be found,
2221 defined', because it would find the 'parent'. s.x would be found,
2209 but since 'x' isn't defined by itself, it would get confused.
2222 but since 'x' isn't defined by itself, it would get confused.
2210 (Magic.magic_run): Fixed pickling problems reported by Ralf
2223 (Magic.magic_run): Fixed pickling problems reported by Ralf
2211 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2224 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2212 that I'd used when Mike Heeter reported similar issues at the
2225 that I'd used when Mike Heeter reported similar issues at the
2213 top-level, but now for @run. It boils down to injecting the
2226 top-level, but now for @run. It boils down to injecting the
2214 namespace where code is being executed with something that looks
2227 namespace where code is being executed with something that looks
2215 enough like a module to fool pickle.dump(). Since a pickle stores
2228 enough like a module to fool pickle.dump(). Since a pickle stores
2216 a named reference to the importing module, we need this for
2229 a named reference to the importing module, we need this for
2217 pickles to save something sensible.
2230 pickles to save something sensible.
2218
2231
2219 * IPython/ipmaker.py (make_IPython): added an autocall option.
2232 * IPython/ipmaker.py (make_IPython): added an autocall option.
2220
2233
2221 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2234 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2222 the auto-eval code. Now autocalling is an option, and the code is
2235 the auto-eval code. Now autocalling is an option, and the code is
2223 also vastly safer. There is no more eval() involved at all.
2236 also vastly safer. There is no more eval() involved at all.
2224
2237
2225 2003-03-01 Fernando Perez <fperez@colorado.edu>
2238 2003-03-01 Fernando Perez <fperez@colorado.edu>
2226
2239
2227 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2240 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2228 dict with named keys instead of a tuple.
2241 dict with named keys instead of a tuple.
2229
2242
2230 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2243 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2231
2244
2232 * setup.py (make_shortcut): Fixed message about directories
2245 * setup.py (make_shortcut): Fixed message about directories
2233 created during Windows installation (the directories were ok, just
2246 created during Windows installation (the directories were ok, just
2234 the printed message was misleading). Thanks to Chris Liechti
2247 the printed message was misleading). Thanks to Chris Liechti
2235 <cliechti-AT-gmx.net> for the heads up.
2248 <cliechti-AT-gmx.net> for the heads up.
2236
2249
2237 2003-02-21 Fernando Perez <fperez@colorado.edu>
2250 2003-02-21 Fernando Perez <fperez@colorado.edu>
2238
2251
2239 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2252 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2240 of ValueError exception when checking for auto-execution. This
2253 of ValueError exception when checking for auto-execution. This
2241 one is raised by things like Numeric arrays arr.flat when the
2254 one is raised by things like Numeric arrays arr.flat when the
2242 array is non-contiguous.
2255 array is non-contiguous.
2243
2256
2244 2003-01-31 Fernando Perez <fperez@colorado.edu>
2257 2003-01-31 Fernando Perez <fperez@colorado.edu>
2245
2258
2246 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2259 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2247 not return any value at all (even though the command would get
2260 not return any value at all (even though the command would get
2248 executed).
2261 executed).
2249 (xsys): Flush stdout right after printing the command to ensure
2262 (xsys): Flush stdout right after printing the command to ensure
2250 proper ordering of commands and command output in the total
2263 proper ordering of commands and command output in the total
2251 output.
2264 output.
2252 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2265 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2253 system/getoutput as defaults. The old ones are kept for
2266 system/getoutput as defaults. The old ones are kept for
2254 compatibility reasons, so no code which uses this library needs
2267 compatibility reasons, so no code which uses this library needs
2255 changing.
2268 changing.
2256
2269
2257 2003-01-27 *** Released version 0.2.14
2270 2003-01-27 *** Released version 0.2.14
2258
2271
2259 2003-01-25 Fernando Perez <fperez@colorado.edu>
2272 2003-01-25 Fernando Perez <fperez@colorado.edu>
2260
2273
2261 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2274 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2262 functions defined in previous edit sessions could not be re-edited
2275 functions defined in previous edit sessions could not be re-edited
2263 (because the temp files were immediately removed). Now temp files
2276 (because the temp files were immediately removed). Now temp files
2264 are removed only at IPython's exit.
2277 are removed only at IPython's exit.
2265 (Magic.magic_run): Improved @run to perform shell-like expansions
2278 (Magic.magic_run): Improved @run to perform shell-like expansions
2266 on its arguments (~users and $VARS). With this, @run becomes more
2279 on its arguments (~users and $VARS). With this, @run becomes more
2267 like a normal command-line.
2280 like a normal command-line.
2268
2281
2269 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2282 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2270 bugs related to embedding and cleaned up that code. A fairly
2283 bugs related to embedding and cleaned up that code. A fairly
2271 important one was the impossibility to access the global namespace
2284 important one was the impossibility to access the global namespace
2272 through the embedded IPython (only local variables were visible).
2285 through the embedded IPython (only local variables were visible).
2273
2286
2274 2003-01-14 Fernando Perez <fperez@colorado.edu>
2287 2003-01-14 Fernando Perez <fperez@colorado.edu>
2275
2288
2276 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2289 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2277 auto-calling to be a bit more conservative. Now it doesn't get
2290 auto-calling to be a bit more conservative. Now it doesn't get
2278 triggered if any of '!=()<>' are in the rest of the input line, to
2291 triggered if any of '!=()<>' are in the rest of the input line, to
2279 allow comparing callables. Thanks to Alex for the heads up.
2292 allow comparing callables. Thanks to Alex for the heads up.
2280
2293
2281 2003-01-07 Fernando Perez <fperez@colorado.edu>
2294 2003-01-07 Fernando Perez <fperez@colorado.edu>
2282
2295
2283 * IPython/genutils.py (page): fixed estimation of the number of
2296 * IPython/genutils.py (page): fixed estimation of the number of
2284 lines in a string to be paged to simply count newlines. This
2297 lines in a string to be paged to simply count newlines. This
2285 prevents over-guessing due to embedded escape sequences. A better
2298 prevents over-guessing due to embedded escape sequences. A better
2286 long-term solution would involve stripping out the control chars
2299 long-term solution would involve stripping out the control chars
2287 for the count, but it's potentially so expensive I just don't
2300 for the count, but it's potentially so expensive I just don't
2288 think it's worth doing.
2301 think it's worth doing.
2289
2302
2290 2002-12-19 *** Released version 0.2.14pre50
2303 2002-12-19 *** Released version 0.2.14pre50
2291
2304
2292 2002-12-19 Fernando Perez <fperez@colorado.edu>
2305 2002-12-19 Fernando Perez <fperez@colorado.edu>
2293
2306
2294 * tools/release (version): Changed release scripts to inform
2307 * tools/release (version): Changed release scripts to inform
2295 Andrea and build a NEWS file with a list of recent changes.
2308 Andrea and build a NEWS file with a list of recent changes.
2296
2309
2297 * IPython/ColorANSI.py (__all__): changed terminal detection
2310 * IPython/ColorANSI.py (__all__): changed terminal detection
2298 code. Seems to work better for xterms without breaking
2311 code. Seems to work better for xterms without breaking
2299 konsole. Will need more testing to determine if WinXP and Mac OSX
2312 konsole. Will need more testing to determine if WinXP and Mac OSX
2300 also work ok.
2313 also work ok.
2301
2314
2302 2002-12-18 *** Released version 0.2.14pre49
2315 2002-12-18 *** Released version 0.2.14pre49
2303
2316
2304 2002-12-18 Fernando Perez <fperez@colorado.edu>
2317 2002-12-18 Fernando Perez <fperez@colorado.edu>
2305
2318
2306 * Docs: added new info about Mac OSX, from Andrea.
2319 * Docs: added new info about Mac OSX, from Andrea.
2307
2320
2308 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2321 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2309 allow direct plotting of python strings whose format is the same
2322 allow direct plotting of python strings whose format is the same
2310 of gnuplot data files.
2323 of gnuplot data files.
2311
2324
2312 2002-12-16 Fernando Perez <fperez@colorado.edu>
2325 2002-12-16 Fernando Perez <fperez@colorado.edu>
2313
2326
2314 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2327 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2315 value of exit question to be acknowledged.
2328 value of exit question to be acknowledged.
2316
2329
2317 2002-12-03 Fernando Perez <fperez@colorado.edu>
2330 2002-12-03 Fernando Perez <fperez@colorado.edu>
2318
2331
2319 * IPython/ipmaker.py: removed generators, which had been added
2332 * IPython/ipmaker.py: removed generators, which had been added
2320 by mistake in an earlier debugging run. This was causing trouble
2333 by mistake in an earlier debugging run. This was causing trouble
2321 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2334 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2322 for pointing this out.
2335 for pointing this out.
2323
2336
2324 2002-11-17 Fernando Perez <fperez@colorado.edu>
2337 2002-11-17 Fernando Perez <fperez@colorado.edu>
2325
2338
2326 * Manual: updated the Gnuplot section.
2339 * Manual: updated the Gnuplot section.
2327
2340
2328 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2341 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2329 a much better split of what goes in Runtime and what goes in
2342 a much better split of what goes in Runtime and what goes in
2330 Interactive.
2343 Interactive.
2331
2344
2332 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2345 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2333 being imported from iplib.
2346 being imported from iplib.
2334
2347
2335 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2348 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2336 for command-passing. Now the global Gnuplot instance is called
2349 for command-passing. Now the global Gnuplot instance is called
2337 'gp' instead of 'g', which was really a far too fragile and
2350 'gp' instead of 'g', which was really a far too fragile and
2338 common name.
2351 common name.
2339
2352
2340 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2353 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2341 bounding boxes generated by Gnuplot for square plots.
2354 bounding boxes generated by Gnuplot for square plots.
2342
2355
2343 * IPython/genutils.py (popkey): new function added. I should
2356 * IPython/genutils.py (popkey): new function added. I should
2344 suggest this on c.l.py as a dict method, it seems useful.
2357 suggest this on c.l.py as a dict method, it seems useful.
2345
2358
2346 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2359 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2347 to transparently handle PostScript generation. MUCH better than
2360 to transparently handle PostScript generation. MUCH better than
2348 the previous plot_eps/replot_eps (which I removed now). The code
2361 the previous plot_eps/replot_eps (which I removed now). The code
2349 is also fairly clean and well documented now (including
2362 is also fairly clean and well documented now (including
2350 docstrings).
2363 docstrings).
2351
2364
2352 2002-11-13 Fernando Perez <fperez@colorado.edu>
2365 2002-11-13 Fernando Perez <fperez@colorado.edu>
2353
2366
2354 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2367 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2355 (inconsistent with options).
2368 (inconsistent with options).
2356
2369
2357 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2370 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2358 manually disabled, I don't know why. Fixed it.
2371 manually disabled, I don't know why. Fixed it.
2359 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2372 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2360 eps output.
2373 eps output.
2361
2374
2362 2002-11-12 Fernando Perez <fperez@colorado.edu>
2375 2002-11-12 Fernando Perez <fperez@colorado.edu>
2363
2376
2364 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2377 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2365 don't propagate up to caller. Fixes crash reported by François
2378 don't propagate up to caller. Fixes crash reported by François
2366 Pinard.
2379 Pinard.
2367
2380
2368 2002-11-09 Fernando Perez <fperez@colorado.edu>
2381 2002-11-09 Fernando Perez <fperez@colorado.edu>
2369
2382
2370 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2383 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2371 history file for new users.
2384 history file for new users.
2372 (make_IPython): fixed bug where initial install would leave the
2385 (make_IPython): fixed bug where initial install would leave the
2373 user running in the .ipython dir.
2386 user running in the .ipython dir.
2374 (make_IPython): fixed bug where config dir .ipython would be
2387 (make_IPython): fixed bug where config dir .ipython would be
2375 created regardless of the given -ipythondir option. Thanks to Cory
2388 created regardless of the given -ipythondir option. Thanks to Cory
2376 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2389 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2377
2390
2378 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2391 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2379 type confirmations. Will need to use it in all of IPython's code
2392 type confirmations. Will need to use it in all of IPython's code
2380 consistently.
2393 consistently.
2381
2394
2382 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2395 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2383 context to print 31 lines instead of the default 5. This will make
2396 context to print 31 lines instead of the default 5. This will make
2384 the crash reports extremely detailed in case the problem is in
2397 the crash reports extremely detailed in case the problem is in
2385 libraries I don't have access to.
2398 libraries I don't have access to.
2386
2399
2387 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2400 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2388 line of defense' code to still crash, but giving users fair
2401 line of defense' code to still crash, but giving users fair
2389 warning. I don't want internal errors to go unreported: if there's
2402 warning. I don't want internal errors to go unreported: if there's
2390 an internal problem, IPython should crash and generate a full
2403 an internal problem, IPython should crash and generate a full
2391 report.
2404 report.
2392
2405
2393 2002-11-08 Fernando Perez <fperez@colorado.edu>
2406 2002-11-08 Fernando Perez <fperez@colorado.edu>
2394
2407
2395 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2408 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2396 otherwise uncaught exceptions which can appear if people set
2409 otherwise uncaught exceptions which can appear if people set
2397 sys.stdout to something badly broken. Thanks to a crash report
2410 sys.stdout to something badly broken. Thanks to a crash report
2398 from henni-AT-mail.brainbot.com.
2411 from henni-AT-mail.brainbot.com.
2399
2412
2400 2002-11-04 Fernando Perez <fperez@colorado.edu>
2413 2002-11-04 Fernando Perez <fperez@colorado.edu>
2401
2414
2402 * IPython/iplib.py (InteractiveShell.interact): added
2415 * IPython/iplib.py (InteractiveShell.interact): added
2403 __IPYTHON__active to the builtins. It's a flag which goes on when
2416 __IPYTHON__active to the builtins. It's a flag which goes on when
2404 the interaction starts and goes off again when it stops. This
2417 the interaction starts and goes off again when it stops. This
2405 allows embedding code to detect being inside IPython. Before this
2418 allows embedding code to detect being inside IPython. Before this
2406 was done via __IPYTHON__, but that only shows that an IPython
2419 was done via __IPYTHON__, but that only shows that an IPython
2407 instance has been created.
2420 instance has been created.
2408
2421
2409 * IPython/Magic.py (Magic.magic_env): I realized that in a
2422 * IPython/Magic.py (Magic.magic_env): I realized that in a
2410 UserDict, instance.data holds the data as a normal dict. So I
2423 UserDict, instance.data holds the data as a normal dict. So I
2411 modified @env to return os.environ.data instead of rebuilding a
2424 modified @env to return os.environ.data instead of rebuilding a
2412 dict by hand.
2425 dict by hand.
2413
2426
2414 2002-11-02 Fernando Perez <fperez@colorado.edu>
2427 2002-11-02 Fernando Perez <fperez@colorado.edu>
2415
2428
2416 * IPython/genutils.py (warn): changed so that level 1 prints no
2429 * IPython/genutils.py (warn): changed so that level 1 prints no
2417 header. Level 2 is now the default (with 'WARNING' header, as
2430 header. Level 2 is now the default (with 'WARNING' header, as
2418 before). I think I tracked all places where changes were needed in
2431 before). I think I tracked all places where changes were needed in
2419 IPython, but outside code using the old level numbering may have
2432 IPython, but outside code using the old level numbering may have
2420 broken.
2433 broken.
2421
2434
2422 * IPython/iplib.py (InteractiveShell.runcode): added this to
2435 * IPython/iplib.py (InteractiveShell.runcode): added this to
2423 handle the tracebacks in SystemExit traps correctly. The previous
2436 handle the tracebacks in SystemExit traps correctly. The previous
2424 code (through interact) was printing more of the stack than
2437 code (through interact) was printing more of the stack than
2425 necessary, showing IPython internal code to the user.
2438 necessary, showing IPython internal code to the user.
2426
2439
2427 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2440 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2428 default. Now that the default at the confirmation prompt is yes,
2441 default. Now that the default at the confirmation prompt is yes,
2429 it's not so intrusive. François' argument that ipython sessions
2442 it's not so intrusive. François' argument that ipython sessions
2430 tend to be complex enough not to lose them from an accidental C-d,
2443 tend to be complex enough not to lose them from an accidental C-d,
2431 is a valid one.
2444 is a valid one.
2432
2445
2433 * IPython/iplib.py (InteractiveShell.interact): added a
2446 * IPython/iplib.py (InteractiveShell.interact): added a
2434 showtraceback() call to the SystemExit trap, and modified the exit
2447 showtraceback() call to the SystemExit trap, and modified the exit
2435 confirmation to have yes as the default.
2448 confirmation to have yes as the default.
2436
2449
2437 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2450 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2438 this file. It's been gone from the code for a long time, this was
2451 this file. It's been gone from the code for a long time, this was
2439 simply leftover junk.
2452 simply leftover junk.
2440
2453
2441 2002-11-01 Fernando Perez <fperez@colorado.edu>
2454 2002-11-01 Fernando Perez <fperez@colorado.edu>
2442
2455
2443 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2456 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2444 added. If set, IPython now traps EOF and asks for
2457 added. If set, IPython now traps EOF and asks for
2445 confirmation. After a request by François Pinard.
2458 confirmation. After a request by François Pinard.
2446
2459
2447 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2460 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2448 of @abort, and with a new (better) mechanism for handling the
2461 of @abort, and with a new (better) mechanism for handling the
2449 exceptions.
2462 exceptions.
2450
2463
2451 2002-10-27 Fernando Perez <fperez@colorado.edu>
2464 2002-10-27 Fernando Perez <fperez@colorado.edu>
2452
2465
2453 * IPython/usage.py (__doc__): updated the --help information and
2466 * IPython/usage.py (__doc__): updated the --help information and
2454 the ipythonrc file to indicate that -log generates
2467 the ipythonrc file to indicate that -log generates
2455 ./ipython.log. Also fixed the corresponding info in @logstart.
2468 ./ipython.log. Also fixed the corresponding info in @logstart.
2456 This and several other fixes in the manuals thanks to reports by
2469 This and several other fixes in the manuals thanks to reports by
2457 François Pinard <pinard-AT-iro.umontreal.ca>.
2470 François Pinard <pinard-AT-iro.umontreal.ca>.
2458
2471
2459 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2472 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2460 refer to @logstart (instead of @log, which doesn't exist).
2473 refer to @logstart (instead of @log, which doesn't exist).
2461
2474
2462 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2475 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2463 AttributeError crash. Thanks to Christopher Armstrong
2476 AttributeError crash. Thanks to Christopher Armstrong
2464 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2477 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2465 introduced recently (in 0.2.14pre37) with the fix to the eval
2478 introduced recently (in 0.2.14pre37) with the fix to the eval
2466 problem mentioned below.
2479 problem mentioned below.
2467
2480
2468 2002-10-17 Fernando Perez <fperez@colorado.edu>
2481 2002-10-17 Fernando Perez <fperez@colorado.edu>
2469
2482
2470 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2483 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2471 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2484 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2472
2485
2473 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2486 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2474 this function to fix a problem reported by Alex Schmolck. He saw
2487 this function to fix a problem reported by Alex Schmolck. He saw
2475 it with list comprehensions and generators, which were getting
2488 it with list comprehensions and generators, which were getting
2476 called twice. The real problem was an 'eval' call in testing for
2489 called twice. The real problem was an 'eval' call in testing for
2477 automagic which was evaluating the input line silently.
2490 automagic which was evaluating the input line silently.
2478
2491
2479 This is a potentially very nasty bug, if the input has side
2492 This is a potentially very nasty bug, if the input has side
2480 effects which must not be repeated. The code is much cleaner now,
2493 effects which must not be repeated. The code is much cleaner now,
2481 without any blanket 'except' left and with a regexp test for
2494 without any blanket 'except' left and with a regexp test for
2482 actual function names.
2495 actual function names.
2483
2496
2484 But an eval remains, which I'm not fully comfortable with. I just
2497 But an eval remains, which I'm not fully comfortable with. I just
2485 don't know how to find out if an expression could be a callable in
2498 don't know how to find out if an expression could be a callable in
2486 the user's namespace without doing an eval on the string. However
2499 the user's namespace without doing an eval on the string. However
2487 that string is now much more strictly checked so that no code
2500 that string is now much more strictly checked so that no code
2488 slips by, so the eval should only happen for things that can
2501 slips by, so the eval should only happen for things that can
2489 really be only function/method names.
2502 really be only function/method names.
2490
2503
2491 2002-10-15 Fernando Perez <fperez@colorado.edu>
2504 2002-10-15 Fernando Perez <fperez@colorado.edu>
2492
2505
2493 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2506 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2494 OSX information to main manual, removed README_Mac_OSX file from
2507 OSX information to main manual, removed README_Mac_OSX file from
2495 distribution. Also updated credits for recent additions.
2508 distribution. Also updated credits for recent additions.
2496
2509
2497 2002-10-10 Fernando Perez <fperez@colorado.edu>
2510 2002-10-10 Fernando Perez <fperez@colorado.edu>
2498
2511
2499 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2512 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2500 terminal-related issues. Many thanks to Andrea Riciputi
2513 terminal-related issues. Many thanks to Andrea Riciputi
2501 <andrea.riciputi-AT-libero.it> for writing it.
2514 <andrea.riciputi-AT-libero.it> for writing it.
2502
2515
2503 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2516 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2504 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2517 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2505
2518
2506 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2519 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2507 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2520 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2508 <syver-en-AT-online.no> who both submitted patches for this problem.
2521 <syver-en-AT-online.no> who both submitted patches for this problem.
2509
2522
2510 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2523 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2511 global embedding to make sure that things don't overwrite user
2524 global embedding to make sure that things don't overwrite user
2512 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2525 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2513
2526
2514 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2527 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2515 compatibility. Thanks to Hayden Callow
2528 compatibility. Thanks to Hayden Callow
2516 <h.callow-AT-elec.canterbury.ac.nz>
2529 <h.callow-AT-elec.canterbury.ac.nz>
2517
2530
2518 2002-10-04 Fernando Perez <fperez@colorado.edu>
2531 2002-10-04 Fernando Perez <fperez@colorado.edu>
2519
2532
2520 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2533 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2521 Gnuplot.File objects.
2534 Gnuplot.File objects.
2522
2535
2523 2002-07-23 Fernando Perez <fperez@colorado.edu>
2536 2002-07-23 Fernando Perez <fperez@colorado.edu>
2524
2537
2525 * IPython/genutils.py (timing): Added timings() and timing() for
2538 * IPython/genutils.py (timing): Added timings() and timing() for
2526 quick access to the most commonly needed data, the execution
2539 quick access to the most commonly needed data, the execution
2527 times. Old timing() renamed to timings_out().
2540 times. Old timing() renamed to timings_out().
2528
2541
2529 2002-07-18 Fernando Perez <fperez@colorado.edu>
2542 2002-07-18 Fernando Perez <fperez@colorado.edu>
2530
2543
2531 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2544 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2532 bug with nested instances disrupting the parent's tab completion.
2545 bug with nested instances disrupting the parent's tab completion.
2533
2546
2534 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2547 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2535 all_completions code to begin the emacs integration.
2548 all_completions code to begin the emacs integration.
2536
2549
2537 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2550 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2538 argument to allow titling individual arrays when plotting.
2551 argument to allow titling individual arrays when plotting.
2539
2552
2540 2002-07-15 Fernando Perez <fperez@colorado.edu>
2553 2002-07-15 Fernando Perez <fperez@colorado.edu>
2541
2554
2542 * setup.py (make_shortcut): changed to retrieve the value of
2555 * setup.py (make_shortcut): changed to retrieve the value of
2543 'Program Files' directory from the registry (this value changes in
2556 'Program Files' directory from the registry (this value changes in
2544 non-english versions of Windows). Thanks to Thomas Fanslau
2557 non-english versions of Windows). Thanks to Thomas Fanslau
2545 <tfanslau-AT-gmx.de> for the report.
2558 <tfanslau-AT-gmx.de> for the report.
2546
2559
2547 2002-07-10 Fernando Perez <fperez@colorado.edu>
2560 2002-07-10 Fernando Perez <fperez@colorado.edu>
2548
2561
2549 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2562 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2550 a bug in pdb, which crashes if a line with only whitespace is
2563 a bug in pdb, which crashes if a line with only whitespace is
2551 entered. Bug report submitted to sourceforge.
2564 entered. Bug report submitted to sourceforge.
2552
2565
2553 2002-07-09 Fernando Perez <fperez@colorado.edu>
2566 2002-07-09 Fernando Perez <fperez@colorado.edu>
2554
2567
2555 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2568 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2556 reporting exceptions (it's a bug in inspect.py, I just set a
2569 reporting exceptions (it's a bug in inspect.py, I just set a
2557 workaround).
2570 workaround).
2558
2571
2559 2002-07-08 Fernando Perez <fperez@colorado.edu>
2572 2002-07-08 Fernando Perez <fperez@colorado.edu>
2560
2573
2561 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2574 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2562 __IPYTHON__ in __builtins__ to show up in user_ns.
2575 __IPYTHON__ in __builtins__ to show up in user_ns.
2563
2576
2564 2002-07-03 Fernando Perez <fperez@colorado.edu>
2577 2002-07-03 Fernando Perez <fperez@colorado.edu>
2565
2578
2566 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2579 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2567 name from @gp_set_instance to @gp_set_default.
2580 name from @gp_set_instance to @gp_set_default.
2568
2581
2569 * IPython/ipmaker.py (make_IPython): default editor value set to
2582 * IPython/ipmaker.py (make_IPython): default editor value set to
2570 '0' (a string), to match the rc file. Otherwise will crash when
2583 '0' (a string), to match the rc file. Otherwise will crash when
2571 .strip() is called on it.
2584 .strip() is called on it.
2572
2585
2573
2586
2574 2002-06-28 Fernando Perez <fperez@colorado.edu>
2587 2002-06-28 Fernando Perez <fperez@colorado.edu>
2575
2588
2576 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2589 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2577 of files in current directory when a file is executed via
2590 of files in current directory when a file is executed via
2578 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2591 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2579
2592
2580 * setup.py (manfiles): fix for rpm builds, submitted by RA
2593 * setup.py (manfiles): fix for rpm builds, submitted by RA
2581 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2594 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2582
2595
2583 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2596 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2584 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2597 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2585 string!). A. Schmolck caught this one.
2598 string!). A. Schmolck caught this one.
2586
2599
2587 2002-06-27 Fernando Perez <fperez@colorado.edu>
2600 2002-06-27 Fernando Perez <fperez@colorado.edu>
2588
2601
2589 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2602 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2590 defined files at the cmd line. __name__ wasn't being set to
2603 defined files at the cmd line. __name__ wasn't being set to
2591 __main__.
2604 __main__.
2592
2605
2593 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2606 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2594 regular lists and tuples besides Numeric arrays.
2607 regular lists and tuples besides Numeric arrays.
2595
2608
2596 * IPython/Prompts.py (CachedOutput.__call__): Added output
2609 * IPython/Prompts.py (CachedOutput.__call__): Added output
2597 supression for input ending with ';'. Similar to Mathematica and
2610 supression for input ending with ';'. Similar to Mathematica and
2598 Matlab. The _* vars and Out[] list are still updated, just like
2611 Matlab. The _* vars and Out[] list are still updated, just like
2599 Mathematica behaves.
2612 Mathematica behaves.
2600
2613
2601 2002-06-25 Fernando Perez <fperez@colorado.edu>
2614 2002-06-25 Fernando Perez <fperez@colorado.edu>
2602
2615
2603 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2616 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2604 .ini extensions for profiels under Windows.
2617 .ini extensions for profiels under Windows.
2605
2618
2606 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2619 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2607 string form. Fix contributed by Alexander Schmolck
2620 string form. Fix contributed by Alexander Schmolck
2608 <a.schmolck-AT-gmx.net>
2621 <a.schmolck-AT-gmx.net>
2609
2622
2610 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2623 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2611 pre-configured Gnuplot instance.
2624 pre-configured Gnuplot instance.
2612
2625
2613 2002-06-21 Fernando Perez <fperez@colorado.edu>
2626 2002-06-21 Fernando Perez <fperez@colorado.edu>
2614
2627
2615 * IPython/numutils.py (exp_safe): new function, works around the
2628 * IPython/numutils.py (exp_safe): new function, works around the
2616 underflow problems in Numeric.
2629 underflow problems in Numeric.
2617 (log2): New fn. Safe log in base 2: returns exact integer answer
2630 (log2): New fn. Safe log in base 2: returns exact integer answer
2618 for exact integer powers of 2.
2631 for exact integer powers of 2.
2619
2632
2620 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2633 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2621 properly.
2634 properly.
2622
2635
2623 2002-06-20 Fernando Perez <fperez@colorado.edu>
2636 2002-06-20 Fernando Perez <fperez@colorado.edu>
2624
2637
2625 * IPython/genutils.py (timing): new function like
2638 * IPython/genutils.py (timing): new function like
2626 Mathematica's. Similar to time_test, but returns more info.
2639 Mathematica's. Similar to time_test, but returns more info.
2627
2640
2628 2002-06-18 Fernando Perez <fperez@colorado.edu>
2641 2002-06-18 Fernando Perez <fperez@colorado.edu>
2629
2642
2630 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2643 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2631 according to Mike Heeter's suggestions.
2644 according to Mike Heeter's suggestions.
2632
2645
2633 2002-06-16 Fernando Perez <fperez@colorado.edu>
2646 2002-06-16 Fernando Perez <fperez@colorado.edu>
2634
2647
2635 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2648 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2636 system. GnuplotMagic is gone as a user-directory option. New files
2649 system. GnuplotMagic is gone as a user-directory option. New files
2637 make it easier to use all the gnuplot stuff both from external
2650 make it easier to use all the gnuplot stuff both from external
2638 programs as well as from IPython. Had to rewrite part of
2651 programs as well as from IPython. Had to rewrite part of
2639 hardcopy() b/c of a strange bug: often the ps files simply don't
2652 hardcopy() b/c of a strange bug: often the ps files simply don't
2640 get created, and require a repeat of the command (often several
2653 get created, and require a repeat of the command (often several
2641 times).
2654 times).
2642
2655
2643 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2656 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2644 resolve output channel at call time, so that if sys.stderr has
2657 resolve output channel at call time, so that if sys.stderr has
2645 been redirected by user this gets honored.
2658 been redirected by user this gets honored.
2646
2659
2647 2002-06-13 Fernando Perez <fperez@colorado.edu>
2660 2002-06-13 Fernando Perez <fperez@colorado.edu>
2648
2661
2649 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2662 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2650 IPShell. Kept a copy with the old names to avoid breaking people's
2663 IPShell. Kept a copy with the old names to avoid breaking people's
2651 embedded code.
2664 embedded code.
2652
2665
2653 * IPython/ipython: simplified it to the bare minimum after
2666 * IPython/ipython: simplified it to the bare minimum after
2654 Holger's suggestions. Added info about how to use it in
2667 Holger's suggestions. Added info about how to use it in
2655 PYTHONSTARTUP.
2668 PYTHONSTARTUP.
2656
2669
2657 * IPython/Shell.py (IPythonShell): changed the options passing
2670 * IPython/Shell.py (IPythonShell): changed the options passing
2658 from a string with funky %s replacements to a straight list. Maybe
2671 from a string with funky %s replacements to a straight list. Maybe
2659 a bit more typing, but it follows sys.argv conventions, so there's
2672 a bit more typing, but it follows sys.argv conventions, so there's
2660 less special-casing to remember.
2673 less special-casing to remember.
2661
2674
2662 2002-06-12 Fernando Perez <fperez@colorado.edu>
2675 2002-06-12 Fernando Perez <fperez@colorado.edu>
2663
2676
2664 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2677 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2665 command. Thanks to a suggestion by Mike Heeter.
2678 command. Thanks to a suggestion by Mike Heeter.
2666 (Magic.magic_pfile): added behavior to look at filenames if given
2679 (Magic.magic_pfile): added behavior to look at filenames if given
2667 arg is not a defined object.
2680 arg is not a defined object.
2668 (Magic.magic_save): New @save function to save code snippets. Also
2681 (Magic.magic_save): New @save function to save code snippets. Also
2669 a Mike Heeter idea.
2682 a Mike Heeter idea.
2670
2683
2671 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2684 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2672 plot() and replot(). Much more convenient now, especially for
2685 plot() and replot(). Much more convenient now, especially for
2673 interactive use.
2686 interactive use.
2674
2687
2675 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2688 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2676 filenames.
2689 filenames.
2677
2690
2678 2002-06-02 Fernando Perez <fperez@colorado.edu>
2691 2002-06-02 Fernando Perez <fperez@colorado.edu>
2679
2692
2680 * IPython/Struct.py (Struct.__init__): modified to admit
2693 * IPython/Struct.py (Struct.__init__): modified to admit
2681 initialization via another struct.
2694 initialization via another struct.
2682
2695
2683 * IPython/genutils.py (SystemExec.__init__): New stateful
2696 * IPython/genutils.py (SystemExec.__init__): New stateful
2684 interface to xsys and bq. Useful for writing system scripts.
2697 interface to xsys and bq. Useful for writing system scripts.
2685
2698
2686 2002-05-30 Fernando Perez <fperez@colorado.edu>
2699 2002-05-30 Fernando Perez <fperez@colorado.edu>
2687
2700
2688 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2701 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2689 documents. This will make the user download smaller (it's getting
2702 documents. This will make the user download smaller (it's getting
2690 too big).
2703 too big).
2691
2704
2692 2002-05-29 Fernando Perez <fperez@colorado.edu>
2705 2002-05-29 Fernando Perez <fperez@colorado.edu>
2693
2706
2694 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2707 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2695 fix problems with shelve and pickle. Seems to work, but I don't
2708 fix problems with shelve and pickle. Seems to work, but I don't
2696 know if corner cases break it. Thanks to Mike Heeter
2709 know if corner cases break it. Thanks to Mike Heeter
2697 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2710 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2698
2711
2699 2002-05-24 Fernando Perez <fperez@colorado.edu>
2712 2002-05-24 Fernando Perez <fperez@colorado.edu>
2700
2713
2701 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2714 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2702 macros having broken.
2715 macros having broken.
2703
2716
2704 2002-05-21 Fernando Perez <fperez@colorado.edu>
2717 2002-05-21 Fernando Perez <fperez@colorado.edu>
2705
2718
2706 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2719 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2707 introduced logging bug: all history before logging started was
2720 introduced logging bug: all history before logging started was
2708 being written one character per line! This came from the redesign
2721 being written one character per line! This came from the redesign
2709 of the input history as a special list which slices to strings,
2722 of the input history as a special list which slices to strings,
2710 not to lists.
2723 not to lists.
2711
2724
2712 2002-05-20 Fernando Perez <fperez@colorado.edu>
2725 2002-05-20 Fernando Perez <fperez@colorado.edu>
2713
2726
2714 * IPython/Prompts.py (CachedOutput.__init__): made the color table
2727 * IPython/Prompts.py (CachedOutput.__init__): made the color table
2715 be an attribute of all classes in this module. The design of these
2728 be an attribute of all classes in this module. The design of these
2716 classes needs some serious overhauling.
2729 classes needs some serious overhauling.
2717
2730
2718 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
2731 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
2719 which was ignoring '_' in option names.
2732 which was ignoring '_' in option names.
2720
2733
2721 * IPython/ultraTB.py (FormattedTB.__init__): Changed
2734 * IPython/ultraTB.py (FormattedTB.__init__): Changed
2722 'Verbose_novars' to 'Context' and made it the new default. It's a
2735 'Verbose_novars' to 'Context' and made it the new default. It's a
2723 bit more readable and also safer than verbose.
2736 bit more readable and also safer than verbose.
2724
2737
2725 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
2738 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
2726 triple-quoted strings.
2739 triple-quoted strings.
2727
2740
2728 * IPython/OInspect.py (__all__): new module exposing the object
2741 * IPython/OInspect.py (__all__): new module exposing the object
2729 introspection facilities. Now the corresponding magics are dummy
2742 introspection facilities. Now the corresponding magics are dummy
2730 wrappers around this. Having this module will make it much easier
2743 wrappers around this. Having this module will make it much easier
2731 to put these functions into our modified pdb.
2744 to put these functions into our modified pdb.
2732 This new object inspector system uses the new colorizing module,
2745 This new object inspector system uses the new colorizing module,
2733 so source code and other things are nicely syntax highlighted.
2746 so source code and other things are nicely syntax highlighted.
2734
2747
2735 2002-05-18 Fernando Perez <fperez@colorado.edu>
2748 2002-05-18 Fernando Perez <fperez@colorado.edu>
2736
2749
2737 * IPython/ColorANSI.py: Split the coloring tools into a separate
2750 * IPython/ColorANSI.py: Split the coloring tools into a separate
2738 module so I can use them in other code easier (they were part of
2751 module so I can use them in other code easier (they were part of
2739 ultraTB).
2752 ultraTB).
2740
2753
2741 2002-05-17 Fernando Perez <fperez@colorado.edu>
2754 2002-05-17 Fernando Perez <fperez@colorado.edu>
2742
2755
2743 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2756 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2744 fixed it to set the global 'g' also to the called instance, as
2757 fixed it to set the global 'g' also to the called instance, as
2745 long as 'g' was still a gnuplot instance (so it doesn't overwrite
2758 long as 'g' was still a gnuplot instance (so it doesn't overwrite
2746 user's 'g' variables).
2759 user's 'g' variables).
2747
2760
2748 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
2761 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
2749 global variables (aliases to _ih,_oh) so that users which expect
2762 global variables (aliases to _ih,_oh) so that users which expect
2750 In[5] or Out[7] to work aren't unpleasantly surprised.
2763 In[5] or Out[7] to work aren't unpleasantly surprised.
2751 (InputList.__getslice__): new class to allow executing slices of
2764 (InputList.__getslice__): new class to allow executing slices of
2752 input history directly. Very simple class, complements the use of
2765 input history directly. Very simple class, complements the use of
2753 macros.
2766 macros.
2754
2767
2755 2002-05-16 Fernando Perez <fperez@colorado.edu>
2768 2002-05-16 Fernando Perez <fperez@colorado.edu>
2756
2769
2757 * setup.py (docdirbase): make doc directory be just doc/IPython
2770 * setup.py (docdirbase): make doc directory be just doc/IPython
2758 without version numbers, it will reduce clutter for users.
2771 without version numbers, it will reduce clutter for users.
2759
2772
2760 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
2773 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
2761 execfile call to prevent possible memory leak. See for details:
2774 execfile call to prevent possible memory leak. See for details:
2762 http://mail.python.org/pipermail/python-list/2002-February/088476.html
2775 http://mail.python.org/pipermail/python-list/2002-February/088476.html
2763
2776
2764 2002-05-15 Fernando Perez <fperez@colorado.edu>
2777 2002-05-15 Fernando Perez <fperez@colorado.edu>
2765
2778
2766 * IPython/Magic.py (Magic.magic_psource): made the object
2779 * IPython/Magic.py (Magic.magic_psource): made the object
2767 introspection names be more standard: pdoc, pdef, pfile and
2780 introspection names be more standard: pdoc, pdef, pfile and
2768 psource. They all print/page their output, and it makes
2781 psource. They all print/page their output, and it makes
2769 remembering them easier. Kept old names for compatibility as
2782 remembering them easier. Kept old names for compatibility as
2770 aliases.
2783 aliases.
2771
2784
2772 2002-05-14 Fernando Perez <fperez@colorado.edu>
2785 2002-05-14 Fernando Perez <fperez@colorado.edu>
2773
2786
2774 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
2787 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
2775 what the mouse problem was. The trick is to use gnuplot with temp
2788 what the mouse problem was. The trick is to use gnuplot with temp
2776 files and NOT with pipes (for data communication), because having
2789 files and NOT with pipes (for data communication), because having
2777 both pipes and the mouse on is bad news.
2790 both pipes and the mouse on is bad news.
2778
2791
2779 2002-05-13 Fernando Perez <fperez@colorado.edu>
2792 2002-05-13 Fernando Perez <fperez@colorado.edu>
2780
2793
2781 * IPython/Magic.py (Magic._ofind): fixed namespace order search
2794 * IPython/Magic.py (Magic._ofind): fixed namespace order search
2782 bug. Information would be reported about builtins even when
2795 bug. Information would be reported about builtins even when
2783 user-defined functions overrode them.
2796 user-defined functions overrode them.
2784
2797
2785 2002-05-11 Fernando Perez <fperez@colorado.edu>
2798 2002-05-11 Fernando Perez <fperez@colorado.edu>
2786
2799
2787 * IPython/__init__.py (__all__): removed FlexCompleter from
2800 * IPython/__init__.py (__all__): removed FlexCompleter from
2788 __all__ so that things don't fail in platforms without readline.
2801 __all__ so that things don't fail in platforms without readline.
2789
2802
2790 2002-05-10 Fernando Perez <fperez@colorado.edu>
2803 2002-05-10 Fernando Perez <fperez@colorado.edu>
2791
2804
2792 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
2805 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
2793 it requires Numeric, effectively making Numeric a dependency for
2806 it requires Numeric, effectively making Numeric a dependency for
2794 IPython.
2807 IPython.
2795
2808
2796 * Released 0.2.13
2809 * Released 0.2.13
2797
2810
2798 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
2811 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
2799 profiler interface. Now all the major options from the profiler
2812 profiler interface. Now all the major options from the profiler
2800 module are directly supported in IPython, both for single
2813 module are directly supported in IPython, both for single
2801 expressions (@prun) and for full programs (@run -p).
2814 expressions (@prun) and for full programs (@run -p).
2802
2815
2803 2002-05-09 Fernando Perez <fperez@colorado.edu>
2816 2002-05-09 Fernando Perez <fperez@colorado.edu>
2804
2817
2805 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
2818 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
2806 magic properly formatted for screen.
2819 magic properly formatted for screen.
2807
2820
2808 * setup.py (make_shortcut): Changed things to put pdf version in
2821 * setup.py (make_shortcut): Changed things to put pdf version in
2809 doc/ instead of doc/manual (had to change lyxport a bit).
2822 doc/ instead of doc/manual (had to change lyxport a bit).
2810
2823
2811 * IPython/Magic.py (Profile.string_stats): made profile runs go
2824 * IPython/Magic.py (Profile.string_stats): made profile runs go
2812 through pager (they are long and a pager allows searching, saving,
2825 through pager (they are long and a pager allows searching, saving,
2813 etc.)
2826 etc.)
2814
2827
2815 2002-05-08 Fernando Perez <fperez@colorado.edu>
2828 2002-05-08 Fernando Perez <fperez@colorado.edu>
2816
2829
2817 * Released 0.2.12
2830 * Released 0.2.12
2818
2831
2819 2002-05-06 Fernando Perez <fperez@colorado.edu>
2832 2002-05-06 Fernando Perez <fperez@colorado.edu>
2820
2833
2821 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
2834 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
2822 introduced); 'hist n1 n2' was broken.
2835 introduced); 'hist n1 n2' was broken.
2823 (Magic.magic_pdb): added optional on/off arguments to @pdb
2836 (Magic.magic_pdb): added optional on/off arguments to @pdb
2824 (Magic.magic_run): added option -i to @run, which executes code in
2837 (Magic.magic_run): added option -i to @run, which executes code in
2825 the IPython namespace instead of a clean one. Also added @irun as
2838 the IPython namespace instead of a clean one. Also added @irun as
2826 an alias to @run -i.
2839 an alias to @run -i.
2827
2840
2828 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2841 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2829 fixed (it didn't really do anything, the namespaces were wrong).
2842 fixed (it didn't really do anything, the namespaces were wrong).
2830
2843
2831 * IPython/Debugger.py (__init__): Added workaround for python 2.1
2844 * IPython/Debugger.py (__init__): Added workaround for python 2.1
2832
2845
2833 * IPython/__init__.py (__all__): Fixed package namespace, now
2846 * IPython/__init__.py (__all__): Fixed package namespace, now
2834 'import IPython' does give access to IPython.<all> as
2847 'import IPython' does give access to IPython.<all> as
2835 expected. Also renamed __release__ to Release.
2848 expected. Also renamed __release__ to Release.
2836
2849
2837 * IPython/Debugger.py (__license__): created new Pdb class which
2850 * IPython/Debugger.py (__license__): created new Pdb class which
2838 functions like a drop-in for the normal pdb.Pdb but does NOT
2851 functions like a drop-in for the normal pdb.Pdb but does NOT
2839 import readline by default. This way it doesn't muck up IPython's
2852 import readline by default. This way it doesn't muck up IPython's
2840 readline handling, and now tab-completion finally works in the
2853 readline handling, and now tab-completion finally works in the
2841 debugger -- sort of. It completes things globally visible, but the
2854 debugger -- sort of. It completes things globally visible, but the
2842 completer doesn't track the stack as pdb walks it. That's a bit
2855 completer doesn't track the stack as pdb walks it. That's a bit
2843 tricky, and I'll have to implement it later.
2856 tricky, and I'll have to implement it later.
2844
2857
2845 2002-05-05 Fernando Perez <fperez@colorado.edu>
2858 2002-05-05 Fernando Perez <fperez@colorado.edu>
2846
2859
2847 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
2860 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
2848 magic docstrings when printed via ? (explicit \'s were being
2861 magic docstrings when printed via ? (explicit \'s were being
2849 printed).
2862 printed).
2850
2863
2851 * IPython/ipmaker.py (make_IPython): fixed namespace
2864 * IPython/ipmaker.py (make_IPython): fixed namespace
2852 identification bug. Now variables loaded via logs or command-line
2865 identification bug. Now variables loaded via logs or command-line
2853 files are recognized in the interactive namespace by @who.
2866 files are recognized in the interactive namespace by @who.
2854
2867
2855 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
2868 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
2856 log replay system stemming from the string form of Structs.
2869 log replay system stemming from the string form of Structs.
2857
2870
2858 * IPython/Magic.py (Macro.__init__): improved macros to properly
2871 * IPython/Magic.py (Macro.__init__): improved macros to properly
2859 handle magic commands in them.
2872 handle magic commands in them.
2860 (Magic.magic_logstart): usernames are now expanded so 'logstart
2873 (Magic.magic_logstart): usernames are now expanded so 'logstart
2861 ~/mylog' now works.
2874 ~/mylog' now works.
2862
2875
2863 * IPython/iplib.py (complete): fixed bug where paths starting with
2876 * IPython/iplib.py (complete): fixed bug where paths starting with
2864 '/' would be completed as magic names.
2877 '/' would be completed as magic names.
2865
2878
2866 2002-05-04 Fernando Perez <fperez@colorado.edu>
2879 2002-05-04 Fernando Perez <fperez@colorado.edu>
2867
2880
2868 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
2881 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
2869 allow running full programs under the profiler's control.
2882 allow running full programs under the profiler's control.
2870
2883
2871 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
2884 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
2872 mode to report exceptions verbosely but without formatting
2885 mode to report exceptions verbosely but without formatting
2873 variables. This addresses the issue of ipython 'freezing' (it's
2886 variables. This addresses the issue of ipython 'freezing' (it's
2874 not frozen, but caught in an expensive formatting loop) when huge
2887 not frozen, but caught in an expensive formatting loop) when huge
2875 variables are in the context of an exception.
2888 variables are in the context of an exception.
2876 (VerboseTB.text): Added '--->' markers at line where exception was
2889 (VerboseTB.text): Added '--->' markers at line where exception was
2877 triggered. Much clearer to read, especially in NoColor modes.
2890 triggered. Much clearer to read, especially in NoColor modes.
2878
2891
2879 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
2892 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
2880 implemented in reverse when changing to the new parse_options().
2893 implemented in reverse when changing to the new parse_options().
2881
2894
2882 2002-05-03 Fernando Perez <fperez@colorado.edu>
2895 2002-05-03 Fernando Perez <fperez@colorado.edu>
2883
2896
2884 * IPython/Magic.py (Magic.parse_options): new function so that
2897 * IPython/Magic.py (Magic.parse_options): new function so that
2885 magics can parse options easier.
2898 magics can parse options easier.
2886 (Magic.magic_prun): new function similar to profile.run(),
2899 (Magic.magic_prun): new function similar to profile.run(),
2887 suggested by Chris Hart.
2900 suggested by Chris Hart.
2888 (Magic.magic_cd): fixed behavior so that it only changes if
2901 (Magic.magic_cd): fixed behavior so that it only changes if
2889 directory actually is in history.
2902 directory actually is in history.
2890
2903
2891 * IPython/usage.py (__doc__): added information about potential
2904 * IPython/usage.py (__doc__): added information about potential
2892 slowness of Verbose exception mode when there are huge data
2905 slowness of Verbose exception mode when there are huge data
2893 structures to be formatted (thanks to Archie Paulson).
2906 structures to be formatted (thanks to Archie Paulson).
2894
2907
2895 * IPython/ipmaker.py (make_IPython): Changed default logging
2908 * IPython/ipmaker.py (make_IPython): Changed default logging
2896 (when simply called with -log) to use curr_dir/ipython.log in
2909 (when simply called with -log) to use curr_dir/ipython.log in
2897 rotate mode. Fixed crash which was occuring with -log before
2910 rotate mode. Fixed crash which was occuring with -log before
2898 (thanks to Jim Boyle).
2911 (thanks to Jim Boyle).
2899
2912
2900 2002-05-01 Fernando Perez <fperez@colorado.edu>
2913 2002-05-01 Fernando Perez <fperez@colorado.edu>
2901
2914
2902 * Released 0.2.11 for these fixes (mainly the ultraTB one which
2915 * Released 0.2.11 for these fixes (mainly the ultraTB one which
2903 was nasty -- though somewhat of a corner case).
2916 was nasty -- though somewhat of a corner case).
2904
2917
2905 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
2918 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
2906 text (was a bug).
2919 text (was a bug).
2907
2920
2908 2002-04-30 Fernando Perez <fperez@colorado.edu>
2921 2002-04-30 Fernando Perez <fperez@colorado.edu>
2909
2922
2910 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
2923 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
2911 a print after ^D or ^C from the user so that the In[] prompt
2924 a print after ^D or ^C from the user so that the In[] prompt
2912 doesn't over-run the gnuplot one.
2925 doesn't over-run the gnuplot one.
2913
2926
2914 2002-04-29 Fernando Perez <fperez@colorado.edu>
2927 2002-04-29 Fernando Perez <fperez@colorado.edu>
2915
2928
2916 * Released 0.2.10
2929 * Released 0.2.10
2917
2930
2918 * IPython/__release__.py (version): get date dynamically.
2931 * IPython/__release__.py (version): get date dynamically.
2919
2932
2920 * Misc. documentation updates thanks to Arnd's comments. Also ran
2933 * Misc. documentation updates thanks to Arnd's comments. Also ran
2921 a full spellcheck on the manual (hadn't been done in a while).
2934 a full spellcheck on the manual (hadn't been done in a while).
2922
2935
2923 2002-04-27 Fernando Perez <fperez@colorado.edu>
2936 2002-04-27 Fernando Perez <fperez@colorado.edu>
2924
2937
2925 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
2938 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
2926 starting a log in mid-session would reset the input history list.
2939 starting a log in mid-session would reset the input history list.
2927
2940
2928 2002-04-26 Fernando Perez <fperez@colorado.edu>
2941 2002-04-26 Fernando Perez <fperez@colorado.edu>
2929
2942
2930 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
2943 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
2931 all files were being included in an update. Now anything in
2944 all files were being included in an update. Now anything in
2932 UserConfig that matches [A-Za-z]*.py will go (this excludes
2945 UserConfig that matches [A-Za-z]*.py will go (this excludes
2933 __init__.py)
2946 __init__.py)
2934
2947
2935 2002-04-25 Fernando Perez <fperez@colorado.edu>
2948 2002-04-25 Fernando Perez <fperez@colorado.edu>
2936
2949
2937 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
2950 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
2938 to __builtins__ so that any form of embedded or imported code can
2951 to __builtins__ so that any form of embedded or imported code can
2939 test for being inside IPython.
2952 test for being inside IPython.
2940
2953
2941 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
2954 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
2942 changed to GnuplotMagic because it's now an importable module,
2955 changed to GnuplotMagic because it's now an importable module,
2943 this makes the name follow that of the standard Gnuplot module.
2956 this makes the name follow that of the standard Gnuplot module.
2944 GnuplotMagic can now be loaded at any time in mid-session.
2957 GnuplotMagic can now be loaded at any time in mid-session.
2945
2958
2946 2002-04-24 Fernando Perez <fperez@colorado.edu>
2959 2002-04-24 Fernando Perez <fperez@colorado.edu>
2947
2960
2948 * IPython/numutils.py: removed SIUnits. It doesn't properly set
2961 * IPython/numutils.py: removed SIUnits. It doesn't properly set
2949 the globals (IPython has its own namespace) and the
2962 the globals (IPython has its own namespace) and the
2950 PhysicalQuantity stuff is much better anyway.
2963 PhysicalQuantity stuff is much better anyway.
2951
2964
2952 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
2965 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
2953 embedding example to standard user directory for
2966 embedding example to standard user directory for
2954 distribution. Also put it in the manual.
2967 distribution. Also put it in the manual.
2955
2968
2956 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
2969 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
2957 instance as first argument (so it doesn't rely on some obscure
2970 instance as first argument (so it doesn't rely on some obscure
2958 hidden global).
2971 hidden global).
2959
2972
2960 * IPython/UserConfig/ipythonrc.py: put () back in accepted
2973 * IPython/UserConfig/ipythonrc.py: put () back in accepted
2961 delimiters. While it prevents ().TAB from working, it allows
2974 delimiters. While it prevents ().TAB from working, it allows
2962 completions in open (... expressions. This is by far a more common
2975 completions in open (... expressions. This is by far a more common
2963 case.
2976 case.
2964
2977
2965 2002-04-23 Fernando Perez <fperez@colorado.edu>
2978 2002-04-23 Fernando Perez <fperez@colorado.edu>
2966
2979
2967 * IPython/Extensions/InterpreterPasteInput.py: new
2980 * IPython/Extensions/InterpreterPasteInput.py: new
2968 syntax-processing module for pasting lines with >>> or ... at the
2981 syntax-processing module for pasting lines with >>> or ... at the
2969 start.
2982 start.
2970
2983
2971 * IPython/Extensions/PhysicalQ_Interactive.py
2984 * IPython/Extensions/PhysicalQ_Interactive.py
2972 (PhysicalQuantityInteractive.__int__): fixed to work with either
2985 (PhysicalQuantityInteractive.__int__): fixed to work with either
2973 Numeric or math.
2986 Numeric or math.
2974
2987
2975 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
2988 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
2976 provided profiles. Now we have:
2989 provided profiles. Now we have:
2977 -math -> math module as * and cmath with its own namespace.
2990 -math -> math module as * and cmath with its own namespace.
2978 -numeric -> Numeric as *, plus gnuplot & grace
2991 -numeric -> Numeric as *, plus gnuplot & grace
2979 -physics -> same as before
2992 -physics -> same as before
2980
2993
2981 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
2994 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
2982 user-defined magics wouldn't be found by @magic if they were
2995 user-defined magics wouldn't be found by @magic if they were
2983 defined as class methods. Also cleaned up the namespace search
2996 defined as class methods. Also cleaned up the namespace search
2984 logic and the string building (to use %s instead of many repeated
2997 logic and the string building (to use %s instead of many repeated
2985 string adds).
2998 string adds).
2986
2999
2987 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3000 * IPython/UserConfig/example-magic.py (magic_foo): updated example
2988 of user-defined magics to operate with class methods (cleaner, in
3001 of user-defined magics to operate with class methods (cleaner, in
2989 line with the gnuplot code).
3002 line with the gnuplot code).
2990
3003
2991 2002-04-22 Fernando Perez <fperez@colorado.edu>
3004 2002-04-22 Fernando Perez <fperez@colorado.edu>
2992
3005
2993 * setup.py: updated dependency list so that manual is updated when
3006 * setup.py: updated dependency list so that manual is updated when
2994 all included files change.
3007 all included files change.
2995
3008
2996 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3009 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
2997 the delimiter removal option (the fix is ugly right now).
3010 the delimiter removal option (the fix is ugly right now).
2998
3011
2999 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3012 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3000 all of the math profile (quicker loading, no conflict between
3013 all of the math profile (quicker loading, no conflict between
3001 g-9.8 and g-gnuplot).
3014 g-9.8 and g-gnuplot).
3002
3015
3003 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3016 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3004 name of post-mortem files to IPython_crash_report.txt.
3017 name of post-mortem files to IPython_crash_report.txt.
3005
3018
3006 * Cleanup/update of the docs. Added all the new readline info and
3019 * Cleanup/update of the docs. Added all the new readline info and
3007 formatted all lists as 'real lists'.
3020 formatted all lists as 'real lists'.
3008
3021
3009 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3022 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3010 tab-completion options, since the full readline parse_and_bind is
3023 tab-completion options, since the full readline parse_and_bind is
3011 now accessible.
3024 now accessible.
3012
3025
3013 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3026 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3014 handling of readline options. Now users can specify any string to
3027 handling of readline options. Now users can specify any string to
3015 be passed to parse_and_bind(), as well as the delimiters to be
3028 be passed to parse_and_bind(), as well as the delimiters to be
3016 removed.
3029 removed.
3017 (InteractiveShell.__init__): Added __name__ to the global
3030 (InteractiveShell.__init__): Added __name__ to the global
3018 namespace so that things like Itpl which rely on its existence
3031 namespace so that things like Itpl which rely on its existence
3019 don't crash.
3032 don't crash.
3020 (InteractiveShell._prefilter): Defined the default with a _ so
3033 (InteractiveShell._prefilter): Defined the default with a _ so
3021 that prefilter() is easier to override, while the default one
3034 that prefilter() is easier to override, while the default one
3022 remains available.
3035 remains available.
3023
3036
3024 2002-04-18 Fernando Perez <fperez@colorado.edu>
3037 2002-04-18 Fernando Perez <fperez@colorado.edu>
3025
3038
3026 * Added information about pdb in the docs.
3039 * Added information about pdb in the docs.
3027
3040
3028 2002-04-17 Fernando Perez <fperez@colorado.edu>
3041 2002-04-17 Fernando Perez <fperez@colorado.edu>
3029
3042
3030 * IPython/ipmaker.py (make_IPython): added rc_override option to
3043 * IPython/ipmaker.py (make_IPython): added rc_override option to
3031 allow passing config options at creation time which may override
3044 allow passing config options at creation time which may override
3032 anything set in the config files or command line. This is
3045 anything set in the config files or command line. This is
3033 particularly useful for configuring embedded instances.
3046 particularly useful for configuring embedded instances.
3034
3047
3035 2002-04-15 Fernando Perez <fperez@colorado.edu>
3048 2002-04-15 Fernando Perez <fperez@colorado.edu>
3036
3049
3037 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3050 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3038 crash embedded instances because of the input cache falling out of
3051 crash embedded instances because of the input cache falling out of
3039 sync with the output counter.
3052 sync with the output counter.
3040
3053
3041 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3054 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3042 mode which calls pdb after an uncaught exception in IPython itself.
3055 mode which calls pdb after an uncaught exception in IPython itself.
3043
3056
3044 2002-04-14 Fernando Perez <fperez@colorado.edu>
3057 2002-04-14 Fernando Perez <fperez@colorado.edu>
3045
3058
3046 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3059 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3047 readline, fix it back after each call.
3060 readline, fix it back after each call.
3048
3061
3049 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3062 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3050 method to force all access via __call__(), which guarantees that
3063 method to force all access via __call__(), which guarantees that
3051 traceback references are properly deleted.
3064 traceback references are properly deleted.
3052
3065
3053 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3066 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3054 improve printing when pprint is in use.
3067 improve printing when pprint is in use.
3055
3068
3056 2002-04-13 Fernando Perez <fperez@colorado.edu>
3069 2002-04-13 Fernando Perez <fperez@colorado.edu>
3057
3070
3058 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3071 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3059 exceptions aren't caught anymore. If the user triggers one, he
3072 exceptions aren't caught anymore. If the user triggers one, he
3060 should know why he's doing it and it should go all the way up,
3073 should know why he's doing it and it should go all the way up,
3061 just like any other exception. So now @abort will fully kill the
3074 just like any other exception. So now @abort will fully kill the
3062 embedded interpreter and the embedding code (unless that happens
3075 embedded interpreter and the embedding code (unless that happens
3063 to catch SystemExit).
3076 to catch SystemExit).
3064
3077
3065 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3078 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3066 and a debugger() method to invoke the interactive pdb debugger
3079 and a debugger() method to invoke the interactive pdb debugger
3067 after printing exception information. Also added the corresponding
3080 after printing exception information. Also added the corresponding
3068 -pdb option and @pdb magic to control this feature, and updated
3081 -pdb option and @pdb magic to control this feature, and updated
3069 the docs. After a suggestion from Christopher Hart
3082 the docs. After a suggestion from Christopher Hart
3070 (hart-AT-caltech.edu).
3083 (hart-AT-caltech.edu).
3071
3084
3072 2002-04-12 Fernando Perez <fperez@colorado.edu>
3085 2002-04-12 Fernando Perez <fperez@colorado.edu>
3073
3086
3074 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3087 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3075 the exception handlers defined by the user (not the CrashHandler)
3088 the exception handlers defined by the user (not the CrashHandler)
3076 so that user exceptions don't trigger an ipython bug report.
3089 so that user exceptions don't trigger an ipython bug report.
3077
3090
3078 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3091 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3079 configurable (it should have always been so).
3092 configurable (it should have always been so).
3080
3093
3081 2002-03-26 Fernando Perez <fperez@colorado.edu>
3094 2002-03-26 Fernando Perez <fperez@colorado.edu>
3082
3095
3083 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3096 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3084 and there to fix embedding namespace issues. This should all be
3097 and there to fix embedding namespace issues. This should all be
3085 done in a more elegant way.
3098 done in a more elegant way.
3086
3099
3087 2002-03-25 Fernando Perez <fperez@colorado.edu>
3100 2002-03-25 Fernando Perez <fperez@colorado.edu>
3088
3101
3089 * IPython/genutils.py (get_home_dir): Try to make it work under
3102 * IPython/genutils.py (get_home_dir): Try to make it work under
3090 win9x also.
3103 win9x also.
3091
3104
3092 2002-03-20 Fernando Perez <fperez@colorado.edu>
3105 2002-03-20 Fernando Perez <fperez@colorado.edu>
3093
3106
3094 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3107 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3095 sys.displayhook untouched upon __init__.
3108 sys.displayhook untouched upon __init__.
3096
3109
3097 2002-03-19 Fernando Perez <fperez@colorado.edu>
3110 2002-03-19 Fernando Perez <fperez@colorado.edu>
3098
3111
3099 * Released 0.2.9 (for embedding bug, basically).
3112 * Released 0.2.9 (for embedding bug, basically).
3100
3113
3101 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3114 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3102 exceptions so that enclosing shell's state can be restored.
3115 exceptions so that enclosing shell's state can be restored.
3103
3116
3104 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3117 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3105 naming conventions in the .ipython/ dir.
3118 naming conventions in the .ipython/ dir.
3106
3119
3107 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3120 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3108 from delimiters list so filenames with - in them get expanded.
3121 from delimiters list so filenames with - in them get expanded.
3109
3122
3110 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3123 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3111 sys.displayhook not being properly restored after an embedded call.
3124 sys.displayhook not being properly restored after an embedded call.
3112
3125
3113 2002-03-18 Fernando Perez <fperez@colorado.edu>
3126 2002-03-18 Fernando Perez <fperez@colorado.edu>
3114
3127
3115 * Released 0.2.8
3128 * Released 0.2.8
3116
3129
3117 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3130 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3118 some files weren't being included in a -upgrade.
3131 some files weren't being included in a -upgrade.
3119 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3132 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3120 on' so that the first tab completes.
3133 on' so that the first tab completes.
3121 (InteractiveShell.handle_magic): fixed bug with spaces around
3134 (InteractiveShell.handle_magic): fixed bug with spaces around
3122 quotes breaking many magic commands.
3135 quotes breaking many magic commands.
3123
3136
3124 * setup.py: added note about ignoring the syntax error messages at
3137 * setup.py: added note about ignoring the syntax error messages at
3125 installation.
3138 installation.
3126
3139
3127 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3140 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3128 streamlining the gnuplot interface, now there's only one magic @gp.
3141 streamlining the gnuplot interface, now there's only one magic @gp.
3129
3142
3130 2002-03-17 Fernando Perez <fperez@colorado.edu>
3143 2002-03-17 Fernando Perez <fperez@colorado.edu>
3131
3144
3132 * IPython/UserConfig/magic_gnuplot.py: new name for the
3145 * IPython/UserConfig/magic_gnuplot.py: new name for the
3133 example-magic_pm.py file. Much enhanced system, now with a shell
3146 example-magic_pm.py file. Much enhanced system, now with a shell
3134 for communicating directly with gnuplot, one command at a time.
3147 for communicating directly with gnuplot, one command at a time.
3135
3148
3136 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3149 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3137 setting __name__=='__main__'.
3150 setting __name__=='__main__'.
3138
3151
3139 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3152 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3140 mini-shell for accessing gnuplot from inside ipython. Should
3153 mini-shell for accessing gnuplot from inside ipython. Should
3141 extend it later for grace access too. Inspired by Arnd's
3154 extend it later for grace access too. Inspired by Arnd's
3142 suggestion.
3155 suggestion.
3143
3156
3144 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3157 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3145 calling magic functions with () in their arguments. Thanks to Arnd
3158 calling magic functions with () in their arguments. Thanks to Arnd
3146 Baecker for pointing this to me.
3159 Baecker for pointing this to me.
3147
3160
3148 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3161 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3149 infinitely for integer or complex arrays (only worked with floats).
3162 infinitely for integer or complex arrays (only worked with floats).
3150
3163
3151 2002-03-16 Fernando Perez <fperez@colorado.edu>
3164 2002-03-16 Fernando Perez <fperez@colorado.edu>
3152
3165
3153 * setup.py: Merged setup and setup_windows into a single script
3166 * setup.py: Merged setup and setup_windows into a single script
3154 which properly handles things for windows users.
3167 which properly handles things for windows users.
3155
3168
3156 2002-03-15 Fernando Perez <fperez@colorado.edu>
3169 2002-03-15 Fernando Perez <fperez@colorado.edu>
3157
3170
3158 * Big change to the manual: now the magics are all automatically
3171 * Big change to the manual: now the magics are all automatically
3159 documented. This information is generated from their docstrings
3172 documented. This information is generated from their docstrings
3160 and put in a latex file included by the manual lyx file. This way
3173 and put in a latex file included by the manual lyx file. This way
3161 we get always up to date information for the magics. The manual
3174 we get always up to date information for the magics. The manual
3162 now also has proper version information, also auto-synced.
3175 now also has proper version information, also auto-synced.
3163
3176
3164 For this to work, an undocumented --magic_docstrings option was added.
3177 For this to work, an undocumented --magic_docstrings option was added.
3165
3178
3166 2002-03-13 Fernando Perez <fperez@colorado.edu>
3179 2002-03-13 Fernando Perez <fperez@colorado.edu>
3167
3180
3168 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3181 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3169 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3182 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3170
3183
3171 2002-03-12 Fernando Perez <fperez@colorado.edu>
3184 2002-03-12 Fernando Perez <fperez@colorado.edu>
3172
3185
3173 * IPython/ultraTB.py (TermColors): changed color escapes again to
3186 * IPython/ultraTB.py (TermColors): changed color escapes again to
3174 fix the (old, reintroduced) line-wrapping bug. Basically, if
3187 fix the (old, reintroduced) line-wrapping bug. Basically, if
3175 \001..\002 aren't given in the color escapes, lines get wrapped
3188 \001..\002 aren't given in the color escapes, lines get wrapped
3176 weirdly. But giving those screws up old xterms and emacs terms. So
3189 weirdly. But giving those screws up old xterms and emacs terms. So
3177 I added some logic for emacs terms to be ok, but I can't identify old
3190 I added some logic for emacs terms to be ok, but I can't identify old
3178 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3191 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3179
3192
3180 2002-03-10 Fernando Perez <fperez@colorado.edu>
3193 2002-03-10 Fernando Perez <fperez@colorado.edu>
3181
3194
3182 * IPython/usage.py (__doc__): Various documentation cleanups and
3195 * IPython/usage.py (__doc__): Various documentation cleanups and
3183 updates, both in usage docstrings and in the manual.
3196 updates, both in usage docstrings and in the manual.
3184
3197
3185 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3198 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3186 handling of caching. Set minimum acceptabe value for having a
3199 handling of caching. Set minimum acceptabe value for having a
3187 cache at 20 values.
3200 cache at 20 values.
3188
3201
3189 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3202 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3190 install_first_time function to a method, renamed it and added an
3203 install_first_time function to a method, renamed it and added an
3191 'upgrade' mode. Now people can update their config directory with
3204 'upgrade' mode. Now people can update their config directory with
3192 a simple command line switch (-upgrade, also new).
3205 a simple command line switch (-upgrade, also new).
3193
3206
3194 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3207 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3195 @file (convenient for automagic users under Python >= 2.2).
3208 @file (convenient for automagic users under Python >= 2.2).
3196 Removed @files (it seemed more like a plural than an abbrev. of
3209 Removed @files (it seemed more like a plural than an abbrev. of
3197 'file show').
3210 'file show').
3198
3211
3199 * IPython/iplib.py (install_first_time): Fixed crash if there were
3212 * IPython/iplib.py (install_first_time): Fixed crash if there were
3200 backup files ('~') in .ipython/ install directory.
3213 backup files ('~') in .ipython/ install directory.
3201
3214
3202 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3215 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3203 system. Things look fine, but these changes are fairly
3216 system. Things look fine, but these changes are fairly
3204 intrusive. Test them for a few days.
3217 intrusive. Test them for a few days.
3205
3218
3206 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3219 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3207 the prompts system. Now all in/out prompt strings are user
3220 the prompts system. Now all in/out prompt strings are user
3208 controllable. This is particularly useful for embedding, as one
3221 controllable. This is particularly useful for embedding, as one
3209 can tag embedded instances with particular prompts.
3222 can tag embedded instances with particular prompts.
3210
3223
3211 Also removed global use of sys.ps1/2, which now allows nested
3224 Also removed global use of sys.ps1/2, which now allows nested
3212 embeddings without any problems. Added command-line options for
3225 embeddings without any problems. Added command-line options for
3213 the prompt strings.
3226 the prompt strings.
3214
3227
3215 2002-03-08 Fernando Perez <fperez@colorado.edu>
3228 2002-03-08 Fernando Perez <fperez@colorado.edu>
3216
3229
3217 * IPython/UserConfig/example-embed-short.py (ipshell): added
3230 * IPython/UserConfig/example-embed-short.py (ipshell): added
3218 example file with the bare minimum code for embedding.
3231 example file with the bare minimum code for embedding.
3219
3232
3220 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3233 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3221 functionality for the embeddable shell to be activated/deactivated
3234 functionality for the embeddable shell to be activated/deactivated
3222 either globally or at each call.
3235 either globally or at each call.
3223
3236
3224 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3237 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3225 rewriting the prompt with '--->' for auto-inputs with proper
3238 rewriting the prompt with '--->' for auto-inputs with proper
3226 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3239 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3227 this is handled by the prompts class itself, as it should.
3240 this is handled by the prompts class itself, as it should.
3228
3241
3229 2002-03-05 Fernando Perez <fperez@colorado.edu>
3242 2002-03-05 Fernando Perez <fperez@colorado.edu>
3230
3243
3231 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3244 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3232 @logstart to avoid name clashes with the math log function.
3245 @logstart to avoid name clashes with the math log function.
3233
3246
3234 * Big updates to X/Emacs section of the manual.
3247 * Big updates to X/Emacs section of the manual.
3235
3248
3236 * Removed ipython_emacs. Milan explained to me how to pass
3249 * Removed ipython_emacs. Milan explained to me how to pass
3237 arguments to ipython through Emacs. Some day I'm going to end up
3250 arguments to ipython through Emacs. Some day I'm going to end up
3238 learning some lisp...
3251 learning some lisp...
3239
3252
3240 2002-03-04 Fernando Perez <fperez@colorado.edu>
3253 2002-03-04 Fernando Perez <fperez@colorado.edu>
3241
3254
3242 * IPython/ipython_emacs: Created script to be used as the
3255 * IPython/ipython_emacs: Created script to be used as the
3243 py-python-command Emacs variable so we can pass IPython
3256 py-python-command Emacs variable so we can pass IPython
3244 parameters. I can't figure out how to tell Emacs directly to pass
3257 parameters. I can't figure out how to tell Emacs directly to pass
3245 parameters to IPython, so a dummy shell script will do it.
3258 parameters to IPython, so a dummy shell script will do it.
3246
3259
3247 Other enhancements made for things to work better under Emacs'
3260 Other enhancements made for things to work better under Emacs'
3248 various types of terminals. Many thanks to Milan Zamazal
3261 various types of terminals. Many thanks to Milan Zamazal
3249 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3262 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3250
3263
3251 2002-03-01 Fernando Perez <fperez@colorado.edu>
3264 2002-03-01 Fernando Perez <fperez@colorado.edu>
3252
3265
3253 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3266 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3254 that loading of readline is now optional. This gives better
3267 that loading of readline is now optional. This gives better
3255 control to emacs users.
3268 control to emacs users.
3256
3269
3257 * IPython/ultraTB.py (__date__): Modified color escape sequences
3270 * IPython/ultraTB.py (__date__): Modified color escape sequences
3258 and now things work fine under xterm and in Emacs' term buffers
3271 and now things work fine under xterm and in Emacs' term buffers
3259 (though not shell ones). Well, in emacs you get colors, but all
3272 (though not shell ones). Well, in emacs you get colors, but all
3260 seem to be 'light' colors (no difference between dark and light
3273 seem to be 'light' colors (no difference between dark and light
3261 ones). But the garbage chars are gone, and also in xterms. It
3274 ones). But the garbage chars are gone, and also in xterms. It
3262 seems that now I'm using 'cleaner' ansi sequences.
3275 seems that now I'm using 'cleaner' ansi sequences.
3263
3276
3264 2002-02-21 Fernando Perez <fperez@colorado.edu>
3277 2002-02-21 Fernando Perez <fperez@colorado.edu>
3265
3278
3266 * Released 0.2.7 (mainly to publish the scoping fix).
3279 * Released 0.2.7 (mainly to publish the scoping fix).
3267
3280
3268 * IPython/Logger.py (Logger.logstate): added. A corresponding
3281 * IPython/Logger.py (Logger.logstate): added. A corresponding
3269 @logstate magic was created.
3282 @logstate magic was created.
3270
3283
3271 * IPython/Magic.py: fixed nested scoping problem under Python
3284 * IPython/Magic.py: fixed nested scoping problem under Python
3272 2.1.x (automagic wasn't working).
3285 2.1.x (automagic wasn't working).
3273
3286
3274 2002-02-20 Fernando Perez <fperez@colorado.edu>
3287 2002-02-20 Fernando Perez <fperez@colorado.edu>
3275
3288
3276 * Released 0.2.6.
3289 * Released 0.2.6.
3277
3290
3278 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3291 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3279 option so that logs can come out without any headers at all.
3292 option so that logs can come out without any headers at all.
3280
3293
3281 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3294 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3282 SciPy.
3295 SciPy.
3283
3296
3284 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3297 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3285 that embedded IPython calls don't require vars() to be explicitly
3298 that embedded IPython calls don't require vars() to be explicitly
3286 passed. Now they are extracted from the caller's frame (code
3299 passed. Now they are extracted from the caller's frame (code
3287 snatched from Eric Jones' weave). Added better documentation to
3300 snatched from Eric Jones' weave). Added better documentation to
3288 the section on embedding and the example file.
3301 the section on embedding and the example file.
3289
3302
3290 * IPython/genutils.py (page): Changed so that under emacs, it just
3303 * IPython/genutils.py (page): Changed so that under emacs, it just
3291 prints the string. You can then page up and down in the emacs
3304 prints the string. You can then page up and down in the emacs
3292 buffer itself. This is how the builtin help() works.
3305 buffer itself. This is how the builtin help() works.
3293
3306
3294 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3307 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3295 macro scoping: macros need to be executed in the user's namespace
3308 macro scoping: macros need to be executed in the user's namespace
3296 to work as if they had been typed by the user.
3309 to work as if they had been typed by the user.
3297
3310
3298 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3311 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3299 execute automatically (no need to type 'exec...'). They then
3312 execute automatically (no need to type 'exec...'). They then
3300 behave like 'true macros'. The printing system was also modified
3313 behave like 'true macros'. The printing system was also modified
3301 for this to work.
3314 for this to work.
3302
3315
3303 2002-02-19 Fernando Perez <fperez@colorado.edu>
3316 2002-02-19 Fernando Perez <fperez@colorado.edu>
3304
3317
3305 * IPython/genutils.py (page_file): new function for paging files
3318 * IPython/genutils.py (page_file): new function for paging files
3306 in an OS-independent way. Also necessary for file viewing to work
3319 in an OS-independent way. Also necessary for file viewing to work
3307 well inside Emacs buffers.
3320 well inside Emacs buffers.
3308 (page): Added checks for being in an emacs buffer.
3321 (page): Added checks for being in an emacs buffer.
3309 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3322 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3310 same bug in iplib.
3323 same bug in iplib.
3311
3324
3312 2002-02-18 Fernando Perez <fperez@colorado.edu>
3325 2002-02-18 Fernando Perez <fperez@colorado.edu>
3313
3326
3314 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3327 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3315 of readline so that IPython can work inside an Emacs buffer.
3328 of readline so that IPython can work inside an Emacs buffer.
3316
3329
3317 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3330 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3318 method signatures (they weren't really bugs, but it looks cleaner
3331 method signatures (they weren't really bugs, but it looks cleaner
3319 and keeps PyChecker happy).
3332 and keeps PyChecker happy).
3320
3333
3321 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3334 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3322 for implementing various user-defined hooks. Currently only
3335 for implementing various user-defined hooks. Currently only
3323 display is done.
3336 display is done.
3324
3337
3325 * IPython/Prompts.py (CachedOutput._display): changed display
3338 * IPython/Prompts.py (CachedOutput._display): changed display
3326 functions so that they can be dynamically changed by users easily.
3339 functions so that they can be dynamically changed by users easily.
3327
3340
3328 * IPython/Extensions/numeric_formats.py (num_display): added an
3341 * IPython/Extensions/numeric_formats.py (num_display): added an
3329 extension for printing NumPy arrays in flexible manners. It
3342 extension for printing NumPy arrays in flexible manners. It
3330 doesn't do anything yet, but all the structure is in
3343 doesn't do anything yet, but all the structure is in
3331 place. Ultimately the plan is to implement output format control
3344 place. Ultimately the plan is to implement output format control
3332 like in Octave.
3345 like in Octave.
3333
3346
3334 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3347 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3335 methods are found at run-time by all the automatic machinery.
3348 methods are found at run-time by all the automatic machinery.
3336
3349
3337 2002-02-17 Fernando Perez <fperez@colorado.edu>
3350 2002-02-17 Fernando Perez <fperez@colorado.edu>
3338
3351
3339 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3352 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3340 whole file a little.
3353 whole file a little.
3341
3354
3342 * ToDo: closed this document. Now there's a new_design.lyx
3355 * ToDo: closed this document. Now there's a new_design.lyx
3343 document for all new ideas. Added making a pdf of it for the
3356 document for all new ideas. Added making a pdf of it for the
3344 end-user distro.
3357 end-user distro.
3345
3358
3346 * IPython/Logger.py (Logger.switch_log): Created this to replace
3359 * IPython/Logger.py (Logger.switch_log): Created this to replace
3347 logon() and logoff(). It also fixes a nasty crash reported by
3360 logon() and logoff(). It also fixes a nasty crash reported by
3348 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3361 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3349
3362
3350 * IPython/iplib.py (complete): got auto-completion to work with
3363 * IPython/iplib.py (complete): got auto-completion to work with
3351 automagic (I had wanted this for a long time).
3364 automagic (I had wanted this for a long time).
3352
3365
3353 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3366 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3354 to @file, since file() is now a builtin and clashes with automagic
3367 to @file, since file() is now a builtin and clashes with automagic
3355 for @file.
3368 for @file.
3356
3369
3357 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3370 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3358 of this was previously in iplib, which had grown to more than 2000
3371 of this was previously in iplib, which had grown to more than 2000
3359 lines, way too long. No new functionality, but it makes managing
3372 lines, way too long. No new functionality, but it makes managing
3360 the code a bit easier.
3373 the code a bit easier.
3361
3374
3362 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3375 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3363 information to crash reports.
3376 information to crash reports.
3364
3377
3365 2002-02-12 Fernando Perez <fperez@colorado.edu>
3378 2002-02-12 Fernando Perez <fperez@colorado.edu>
3366
3379
3367 * Released 0.2.5.
3380 * Released 0.2.5.
3368
3381
3369 2002-02-11 Fernando Perez <fperez@colorado.edu>
3382 2002-02-11 Fernando Perez <fperez@colorado.edu>
3370
3383
3371 * Wrote a relatively complete Windows installer. It puts
3384 * Wrote a relatively complete Windows installer. It puts
3372 everything in place, creates Start Menu entries and fixes the
3385 everything in place, creates Start Menu entries and fixes the
3373 color issues. Nothing fancy, but it works.
3386 color issues. Nothing fancy, but it works.
3374
3387
3375 2002-02-10 Fernando Perez <fperez@colorado.edu>
3388 2002-02-10 Fernando Perez <fperez@colorado.edu>
3376
3389
3377 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3390 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3378 os.path.expanduser() call so that we can type @run ~/myfile.py and
3391 os.path.expanduser() call so that we can type @run ~/myfile.py and
3379 have thigs work as expected.
3392 have thigs work as expected.
3380
3393
3381 * IPython/genutils.py (page): fixed exception handling so things
3394 * IPython/genutils.py (page): fixed exception handling so things
3382 work both in Unix and Windows correctly. Quitting a pager triggers
3395 work both in Unix and Windows correctly. Quitting a pager triggers
3383 an IOError/broken pipe in Unix, and in windows not finding a pager
3396 an IOError/broken pipe in Unix, and in windows not finding a pager
3384 is also an IOError, so I had to actually look at the return value
3397 is also an IOError, so I had to actually look at the return value
3385 of the exception, not just the exception itself. Should be ok now.
3398 of the exception, not just the exception itself. Should be ok now.
3386
3399
3387 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3400 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3388 modified to allow case-insensitive color scheme changes.
3401 modified to allow case-insensitive color scheme changes.
3389
3402
3390 2002-02-09 Fernando Perez <fperez@colorado.edu>
3403 2002-02-09 Fernando Perez <fperez@colorado.edu>
3391
3404
3392 * IPython/genutils.py (native_line_ends): new function to leave
3405 * IPython/genutils.py (native_line_ends): new function to leave
3393 user config files with os-native line-endings.
3406 user config files with os-native line-endings.
3394
3407
3395 * README and manual updates.
3408 * README and manual updates.
3396
3409
3397 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3410 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3398 instead of StringType to catch Unicode strings.
3411 instead of StringType to catch Unicode strings.
3399
3412
3400 * IPython/genutils.py (filefind): fixed bug for paths with
3413 * IPython/genutils.py (filefind): fixed bug for paths with
3401 embedded spaces (very common in Windows).
3414 embedded spaces (very common in Windows).
3402
3415
3403 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3416 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3404 files under Windows, so that they get automatically associated
3417 files under Windows, so that they get automatically associated
3405 with a text editor. Windows makes it a pain to handle
3418 with a text editor. Windows makes it a pain to handle
3406 extension-less files.
3419 extension-less files.
3407
3420
3408 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3421 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3409 warning about readline only occur for Posix. In Windows there's no
3422 warning about readline only occur for Posix. In Windows there's no
3410 way to get readline, so why bother with the warning.
3423 way to get readline, so why bother with the warning.
3411
3424
3412 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3425 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3413 for __str__ instead of dir(self), since dir() changed in 2.2.
3426 for __str__ instead of dir(self), since dir() changed in 2.2.
3414
3427
3415 * Ported to Windows! Tested on XP, I suspect it should work fine
3428 * Ported to Windows! Tested on XP, I suspect it should work fine
3416 on NT/2000, but I don't think it will work on 98 et al. That
3429 on NT/2000, but I don't think it will work on 98 et al. That
3417 series of Windows is such a piece of junk anyway that I won't try
3430 series of Windows is such a piece of junk anyway that I won't try
3418 porting it there. The XP port was straightforward, showed a few
3431 porting it there. The XP port was straightforward, showed a few
3419 bugs here and there (fixed all), in particular some string
3432 bugs here and there (fixed all), in particular some string
3420 handling stuff which required considering Unicode strings (which
3433 handling stuff which required considering Unicode strings (which
3421 Windows uses). This is good, but hasn't been too tested :) No
3434 Windows uses). This is good, but hasn't been too tested :) No
3422 fancy installer yet, I'll put a note in the manual so people at
3435 fancy installer yet, I'll put a note in the manual so people at
3423 least make manually a shortcut.
3436 least make manually a shortcut.
3424
3437
3425 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3438 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3426 into a single one, "colors". This now controls both prompt and
3439 into a single one, "colors". This now controls both prompt and
3427 exception color schemes, and can be changed both at startup
3440 exception color schemes, and can be changed both at startup
3428 (either via command-line switches or via ipythonrc files) and at
3441 (either via command-line switches or via ipythonrc files) and at
3429 runtime, with @colors.
3442 runtime, with @colors.
3430 (Magic.magic_run): renamed @prun to @run and removed the old
3443 (Magic.magic_run): renamed @prun to @run and removed the old
3431 @run. The two were too similar to warrant keeping both.
3444 @run. The two were too similar to warrant keeping both.
3432
3445
3433 2002-02-03 Fernando Perez <fperez@colorado.edu>
3446 2002-02-03 Fernando Perez <fperez@colorado.edu>
3434
3447
3435 * IPython/iplib.py (install_first_time): Added comment on how to
3448 * IPython/iplib.py (install_first_time): Added comment on how to
3436 configure the color options for first-time users. Put a <return>
3449 configure the color options for first-time users. Put a <return>
3437 request at the end so that small-terminal users get a chance to
3450 request at the end so that small-terminal users get a chance to
3438 read the startup info.
3451 read the startup info.
3439
3452
3440 2002-01-23 Fernando Perez <fperez@colorado.edu>
3453 2002-01-23 Fernando Perez <fperez@colorado.edu>
3441
3454
3442 * IPython/iplib.py (CachedOutput.update): Changed output memory
3455 * IPython/iplib.py (CachedOutput.update): Changed output memory
3443 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3456 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3444 input history we still use _i. Did this b/c these variable are
3457 input history we still use _i. Did this b/c these variable are
3445 very commonly used in interactive work, so the less we need to
3458 very commonly used in interactive work, so the less we need to
3446 type the better off we are.
3459 type the better off we are.
3447 (Magic.magic_prun): updated @prun to better handle the namespaces
3460 (Magic.magic_prun): updated @prun to better handle the namespaces
3448 the file will run in, including a fix for __name__ not being set
3461 the file will run in, including a fix for __name__ not being set
3449 before.
3462 before.
3450
3463
3451 2002-01-20 Fernando Perez <fperez@colorado.edu>
3464 2002-01-20 Fernando Perez <fperez@colorado.edu>
3452
3465
3453 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3466 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3454 extra garbage for Python 2.2. Need to look more carefully into
3467 extra garbage for Python 2.2. Need to look more carefully into
3455 this later.
3468 this later.
3456
3469
3457 2002-01-19 Fernando Perez <fperez@colorado.edu>
3470 2002-01-19 Fernando Perez <fperez@colorado.edu>
3458
3471
3459 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3472 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3460 display SyntaxError exceptions properly formatted when they occur
3473 display SyntaxError exceptions properly formatted when they occur
3461 (they can be triggered by imported code).
3474 (they can be triggered by imported code).
3462
3475
3463 2002-01-18 Fernando Perez <fperez@colorado.edu>
3476 2002-01-18 Fernando Perez <fperez@colorado.edu>
3464
3477
3465 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3478 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3466 SyntaxError exceptions are reported nicely formatted, instead of
3479 SyntaxError exceptions are reported nicely formatted, instead of
3467 spitting out only offset information as before.
3480 spitting out only offset information as before.
3468 (Magic.magic_prun): Added the @prun function for executing
3481 (Magic.magic_prun): Added the @prun function for executing
3469 programs with command line args inside IPython.
3482 programs with command line args inside IPython.
3470
3483
3471 2002-01-16 Fernando Perez <fperez@colorado.edu>
3484 2002-01-16 Fernando Perez <fperez@colorado.edu>
3472
3485
3473 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3486 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3474 to *not* include the last item given in a range. This brings their
3487 to *not* include the last item given in a range. This brings their
3475 behavior in line with Python's slicing:
3488 behavior in line with Python's slicing:
3476 a[n1:n2] -> a[n1]...a[n2-1]
3489 a[n1:n2] -> a[n1]...a[n2-1]
3477 It may be a bit less convenient, but I prefer to stick to Python's
3490 It may be a bit less convenient, but I prefer to stick to Python's
3478 conventions *everywhere*, so users never have to wonder.
3491 conventions *everywhere*, so users never have to wonder.
3479 (Magic.magic_macro): Added @macro function to ease the creation of
3492 (Magic.magic_macro): Added @macro function to ease the creation of
3480 macros.
3493 macros.
3481
3494
3482 2002-01-05 Fernando Perez <fperez@colorado.edu>
3495 2002-01-05 Fernando Perez <fperez@colorado.edu>
3483
3496
3484 * Released 0.2.4.
3497 * Released 0.2.4.
3485
3498
3486 * IPython/iplib.py (Magic.magic_pdef):
3499 * IPython/iplib.py (Magic.magic_pdef):
3487 (InteractiveShell.safe_execfile): report magic lines and error
3500 (InteractiveShell.safe_execfile): report magic lines and error
3488 lines without line numbers so one can easily copy/paste them for
3501 lines without line numbers so one can easily copy/paste them for
3489 re-execution.
3502 re-execution.
3490
3503
3491 * Updated manual with recent changes.
3504 * Updated manual with recent changes.
3492
3505
3493 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3506 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3494 docstring printing when class? is called. Very handy for knowing
3507 docstring printing when class? is called. Very handy for knowing
3495 how to create class instances (as long as __init__ is well
3508 how to create class instances (as long as __init__ is well
3496 documented, of course :)
3509 documented, of course :)
3497 (Magic.magic_doc): print both class and constructor docstrings.
3510 (Magic.magic_doc): print both class and constructor docstrings.
3498 (Magic.magic_pdef): give constructor info if passed a class and
3511 (Magic.magic_pdef): give constructor info if passed a class and
3499 __call__ info for callable object instances.
3512 __call__ info for callable object instances.
3500
3513
3501 2002-01-04 Fernando Perez <fperez@colorado.edu>
3514 2002-01-04 Fernando Perez <fperez@colorado.edu>
3502
3515
3503 * Made deep_reload() off by default. It doesn't always work
3516 * Made deep_reload() off by default. It doesn't always work
3504 exactly as intended, so it's probably safer to have it off. It's
3517 exactly as intended, so it's probably safer to have it off. It's
3505 still available as dreload() anyway, so nothing is lost.
3518 still available as dreload() anyway, so nothing is lost.
3506
3519
3507 2002-01-02 Fernando Perez <fperez@colorado.edu>
3520 2002-01-02 Fernando Perez <fperez@colorado.edu>
3508
3521
3509 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3522 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3510 so I wanted an updated release).
3523 so I wanted an updated release).
3511
3524
3512 2001-12-27 Fernando Perez <fperez@colorado.edu>
3525 2001-12-27 Fernando Perez <fperez@colorado.edu>
3513
3526
3514 * IPython/iplib.py (InteractiveShell.interact): Added the original
3527 * IPython/iplib.py (InteractiveShell.interact): Added the original
3515 code from 'code.py' for this module in order to change the
3528 code from 'code.py' for this module in order to change the
3516 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3529 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3517 the history cache would break when the user hit Ctrl-C, and
3530 the history cache would break when the user hit Ctrl-C, and
3518 interact() offers no way to add any hooks to it.
3531 interact() offers no way to add any hooks to it.
3519
3532
3520 2001-12-23 Fernando Perez <fperez@colorado.edu>
3533 2001-12-23 Fernando Perez <fperez@colorado.edu>
3521
3534
3522 * setup.py: added check for 'MANIFEST' before trying to remove
3535 * setup.py: added check for 'MANIFEST' before trying to remove
3523 it. Thanks to Sean Reifschneider.
3536 it. Thanks to Sean Reifschneider.
3524
3537
3525 2001-12-22 Fernando Perez <fperez@colorado.edu>
3538 2001-12-22 Fernando Perez <fperez@colorado.edu>
3526
3539
3527 * Released 0.2.2.
3540 * Released 0.2.2.
3528
3541
3529 * Finished (reasonably) writing the manual. Later will add the
3542 * Finished (reasonably) writing the manual. Later will add the
3530 python-standard navigation stylesheets, but for the time being
3543 python-standard navigation stylesheets, but for the time being
3531 it's fairly complete. Distribution will include html and pdf
3544 it's fairly complete. Distribution will include html and pdf
3532 versions.
3545 versions.
3533
3546
3534 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3547 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3535 (MayaVi author).
3548 (MayaVi author).
3536
3549
3537 2001-12-21 Fernando Perez <fperez@colorado.edu>
3550 2001-12-21 Fernando Perez <fperez@colorado.edu>
3538
3551
3539 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3552 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3540 good public release, I think (with the manual and the distutils
3553 good public release, I think (with the manual and the distutils
3541 installer). The manual can use some work, but that can go
3554 installer). The manual can use some work, but that can go
3542 slowly. Otherwise I think it's quite nice for end users. Next
3555 slowly. Otherwise I think it's quite nice for end users. Next
3543 summer, rewrite the guts of it...
3556 summer, rewrite the guts of it...
3544
3557
3545 * Changed format of ipythonrc files to use whitespace as the
3558 * Changed format of ipythonrc files to use whitespace as the
3546 separator instead of an explicit '='. Cleaner.
3559 separator instead of an explicit '='. Cleaner.
3547
3560
3548 2001-12-20 Fernando Perez <fperez@colorado.edu>
3561 2001-12-20 Fernando Perez <fperez@colorado.edu>
3549
3562
3550 * Started a manual in LyX. For now it's just a quick merge of the
3563 * Started a manual in LyX. For now it's just a quick merge of the
3551 various internal docstrings and READMEs. Later it may grow into a
3564 various internal docstrings and READMEs. Later it may grow into a
3552 nice, full-blown manual.
3565 nice, full-blown manual.
3553
3566
3554 * Set up a distutils based installer. Installation should now be
3567 * Set up a distutils based installer. Installation should now be
3555 trivially simple for end-users.
3568 trivially simple for end-users.
3556
3569
3557 2001-12-11 Fernando Perez <fperez@colorado.edu>
3570 2001-12-11 Fernando Perez <fperez@colorado.edu>
3558
3571
3559 * Released 0.2.0. First public release, announced it at
3572 * Released 0.2.0. First public release, announced it at
3560 comp.lang.python. From now on, just bugfixes...
3573 comp.lang.python. From now on, just bugfixes...
3561
3574
3562 * Went through all the files, set copyright/license notices and
3575 * Went through all the files, set copyright/license notices and
3563 cleaned up things. Ready for release.
3576 cleaned up things. Ready for release.
3564
3577
3565 2001-12-10 Fernando Perez <fperez@colorado.edu>
3578 2001-12-10 Fernando Perez <fperez@colorado.edu>
3566
3579
3567 * Changed the first-time installer not to use tarfiles. It's more
3580 * Changed the first-time installer not to use tarfiles. It's more
3568 robust now and less unix-dependent. Also makes it easier for
3581 robust now and less unix-dependent. Also makes it easier for
3569 people to later upgrade versions.
3582 people to later upgrade versions.
3570
3583
3571 * Changed @exit to @abort to reflect the fact that it's pretty
3584 * Changed @exit to @abort to reflect the fact that it's pretty
3572 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3585 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3573 becomes significant only when IPyhton is embedded: in that case,
3586 becomes significant only when IPyhton is embedded: in that case,
3574 C-D closes IPython only, but @abort kills the enclosing program
3587 C-D closes IPython only, but @abort kills the enclosing program
3575 too (unless it had called IPython inside a try catching
3588 too (unless it had called IPython inside a try catching
3576 SystemExit).
3589 SystemExit).
3577
3590
3578 * Created Shell module which exposes the actuall IPython Shell
3591 * Created Shell module which exposes the actuall IPython Shell
3579 classes, currently the normal and the embeddable one. This at
3592 classes, currently the normal and the embeddable one. This at
3580 least offers a stable interface we won't need to change when
3593 least offers a stable interface we won't need to change when
3581 (later) the internals are rewritten. That rewrite will be confined
3594 (later) the internals are rewritten. That rewrite will be confined
3582 to iplib and ipmaker, but the Shell interface should remain as is.
3595 to iplib and ipmaker, but the Shell interface should remain as is.
3583
3596
3584 * Added embed module which offers an embeddable IPShell object,
3597 * Added embed module which offers an embeddable IPShell object,
3585 useful to fire up IPython *inside* a running program. Great for
3598 useful to fire up IPython *inside* a running program. Great for
3586 debugging or dynamical data analysis.
3599 debugging or dynamical data analysis.
3587
3600
3588 2001-12-08 Fernando Perez <fperez@colorado.edu>
3601 2001-12-08 Fernando Perez <fperez@colorado.edu>
3589
3602
3590 * Fixed small bug preventing seeing info from methods of defined
3603 * Fixed small bug preventing seeing info from methods of defined
3591 objects (incorrect namespace in _ofind()).
3604 objects (incorrect namespace in _ofind()).
3592
3605
3593 * Documentation cleanup. Moved the main usage docstrings to a
3606 * Documentation cleanup. Moved the main usage docstrings to a
3594 separate file, usage.py (cleaner to maintain, and hopefully in the
3607 separate file, usage.py (cleaner to maintain, and hopefully in the
3595 future some perlpod-like way of producing interactive, man and
3608 future some perlpod-like way of producing interactive, man and
3596 html docs out of it will be found).
3609 html docs out of it will be found).
3597
3610
3598 * Added @profile to see your profile at any time.
3611 * Added @profile to see your profile at any time.
3599
3612
3600 * Added @p as an alias for 'print'. It's especially convenient if
3613 * Added @p as an alias for 'print'. It's especially convenient if
3601 using automagic ('p x' prints x).
3614 using automagic ('p x' prints x).
3602
3615
3603 * Small cleanups and fixes after a pychecker run.
3616 * Small cleanups and fixes after a pychecker run.
3604
3617
3605 * Changed the @cd command to handle @cd - and @cd -<n> for
3618 * Changed the @cd command to handle @cd - and @cd -<n> for
3606 visiting any directory in _dh.
3619 visiting any directory in _dh.
3607
3620
3608 * Introduced _dh, a history of visited directories. @dhist prints
3621 * Introduced _dh, a history of visited directories. @dhist prints
3609 it out with numbers.
3622 it out with numbers.
3610
3623
3611 2001-12-07 Fernando Perez <fperez@colorado.edu>
3624 2001-12-07 Fernando Perez <fperez@colorado.edu>
3612
3625
3613 * Released 0.1.22
3626 * Released 0.1.22
3614
3627
3615 * Made initialization a bit more robust against invalid color
3628 * Made initialization a bit more robust against invalid color
3616 options in user input (exit, not traceback-crash).
3629 options in user input (exit, not traceback-crash).
3617
3630
3618 * Changed the bug crash reporter to write the report only in the
3631 * Changed the bug crash reporter to write the report only in the
3619 user's .ipython directory. That way IPython won't litter people's
3632 user's .ipython directory. That way IPython won't litter people's
3620 hard disks with crash files all over the place. Also print on
3633 hard disks with crash files all over the place. Also print on
3621 screen the necessary mail command.
3634 screen the necessary mail command.
3622
3635
3623 * With the new ultraTB, implemented LightBG color scheme for light
3636 * With the new ultraTB, implemented LightBG color scheme for light
3624 background terminals. A lot of people like white backgrounds, so I
3637 background terminals. A lot of people like white backgrounds, so I
3625 guess we should at least give them something readable.
3638 guess we should at least give them something readable.
3626
3639
3627 2001-12-06 Fernando Perez <fperez@colorado.edu>
3640 2001-12-06 Fernando Perez <fperez@colorado.edu>
3628
3641
3629 * Modified the structure of ultraTB. Now there's a proper class
3642 * Modified the structure of ultraTB. Now there's a proper class
3630 for tables of color schemes which allow adding schemes easily and
3643 for tables of color schemes which allow adding schemes easily and
3631 switching the active scheme without creating a new instance every
3644 switching the active scheme without creating a new instance every
3632 time (which was ridiculous). The syntax for creating new schemes
3645 time (which was ridiculous). The syntax for creating new schemes
3633 is also cleaner. I think ultraTB is finally done, with a clean
3646 is also cleaner. I think ultraTB is finally done, with a clean
3634 class structure. Names are also much cleaner (now there's proper
3647 class structure. Names are also much cleaner (now there's proper
3635 color tables, no need for every variable to also have 'color' in
3648 color tables, no need for every variable to also have 'color' in
3636 its name).
3649 its name).
3637
3650
3638 * Broke down genutils into separate files. Now genutils only
3651 * Broke down genutils into separate files. Now genutils only
3639 contains utility functions, and classes have been moved to their
3652 contains utility functions, and classes have been moved to their
3640 own files (they had enough independent functionality to warrant
3653 own files (they had enough independent functionality to warrant
3641 it): ConfigLoader, OutputTrap, Struct.
3654 it): ConfigLoader, OutputTrap, Struct.
3642
3655
3643 2001-12-05 Fernando Perez <fperez@colorado.edu>
3656 2001-12-05 Fernando Perez <fperez@colorado.edu>
3644
3657
3645 * IPython turns 21! Released version 0.1.21, as a candidate for
3658 * IPython turns 21! Released version 0.1.21, as a candidate for
3646 public consumption. If all goes well, release in a few days.
3659 public consumption. If all goes well, release in a few days.
3647
3660
3648 * Fixed path bug (files in Extensions/ directory wouldn't be found
3661 * Fixed path bug (files in Extensions/ directory wouldn't be found
3649 unless IPython/ was explicitly in sys.path).
3662 unless IPython/ was explicitly in sys.path).
3650
3663
3651 * Extended the FlexCompleter class as MagicCompleter to allow
3664 * Extended the FlexCompleter class as MagicCompleter to allow
3652 completion of @-starting lines.
3665 completion of @-starting lines.
3653
3666
3654 * Created __release__.py file as a central repository for release
3667 * Created __release__.py file as a central repository for release
3655 info that other files can read from.
3668 info that other files can read from.
3656
3669
3657 * Fixed small bug in logging: when logging was turned on in
3670 * Fixed small bug in logging: when logging was turned on in
3658 mid-session, old lines with special meanings (!@?) were being
3671 mid-session, old lines with special meanings (!@?) were being
3659 logged without the prepended comment, which is necessary since
3672 logged without the prepended comment, which is necessary since
3660 they are not truly valid python syntax. This should make session
3673 they are not truly valid python syntax. This should make session
3661 restores produce less errors.
3674 restores produce less errors.
3662
3675
3663 * The namespace cleanup forced me to make a FlexCompleter class
3676 * The namespace cleanup forced me to make a FlexCompleter class
3664 which is nothing but a ripoff of rlcompleter, but with selectable
3677 which is nothing but a ripoff of rlcompleter, but with selectable
3665 namespace (rlcompleter only works in __main__.__dict__). I'll try
3678 namespace (rlcompleter only works in __main__.__dict__). I'll try
3666 to submit a note to the authors to see if this change can be
3679 to submit a note to the authors to see if this change can be
3667 incorporated in future rlcompleter releases (Dec.6: done)
3680 incorporated in future rlcompleter releases (Dec.6: done)
3668
3681
3669 * More fixes to namespace handling. It was a mess! Now all
3682 * More fixes to namespace handling. It was a mess! Now all
3670 explicit references to __main__.__dict__ are gone (except when
3683 explicit references to __main__.__dict__ are gone (except when
3671 really needed) and everything is handled through the namespace
3684 really needed) and everything is handled through the namespace
3672 dicts in the IPython instance. We seem to be getting somewhere
3685 dicts in the IPython instance. We seem to be getting somewhere
3673 with this, finally...
3686 with this, finally...
3674
3687
3675 * Small documentation updates.
3688 * Small documentation updates.
3676
3689
3677 * Created the Extensions directory under IPython (with an
3690 * Created the Extensions directory under IPython (with an
3678 __init__.py). Put the PhysicalQ stuff there. This directory should
3691 __init__.py). Put the PhysicalQ stuff there. This directory should
3679 be used for all special-purpose extensions.
3692 be used for all special-purpose extensions.
3680
3693
3681 * File renaming:
3694 * File renaming:
3682 ipythonlib --> ipmaker
3695 ipythonlib --> ipmaker
3683 ipplib --> iplib
3696 ipplib --> iplib
3684 This makes a bit more sense in terms of what these files actually do.
3697 This makes a bit more sense in terms of what these files actually do.
3685
3698
3686 * Moved all the classes and functions in ipythonlib to ipplib, so
3699 * Moved all the classes and functions in ipythonlib to ipplib, so
3687 now ipythonlib only has make_IPython(). This will ease up its
3700 now ipythonlib only has make_IPython(). This will ease up its
3688 splitting in smaller functional chunks later.
3701 splitting in smaller functional chunks later.
3689
3702
3690 * Cleaned up (done, I think) output of @whos. Better column
3703 * Cleaned up (done, I think) output of @whos. Better column
3691 formatting, and now shows str(var) for as much as it can, which is
3704 formatting, and now shows str(var) for as much as it can, which is
3692 typically what one gets with a 'print var'.
3705 typically what one gets with a 'print var'.
3693
3706
3694 2001-12-04 Fernando Perez <fperez@colorado.edu>
3707 2001-12-04 Fernando Perez <fperez@colorado.edu>
3695
3708
3696 * Fixed namespace problems. Now builtin/IPyhton/user names get
3709 * Fixed namespace problems. Now builtin/IPyhton/user names get
3697 properly reported in their namespace. Internal namespace handling
3710 properly reported in their namespace. Internal namespace handling
3698 is finally getting decent (not perfect yet, but much better than
3711 is finally getting decent (not perfect yet, but much better than
3699 the ad-hoc mess we had).
3712 the ad-hoc mess we had).
3700
3713
3701 * Removed -exit option. If people just want to run a python
3714 * Removed -exit option. If people just want to run a python
3702 script, that's what the normal interpreter is for. Less
3715 script, that's what the normal interpreter is for. Less
3703 unnecessary options, less chances for bugs.
3716 unnecessary options, less chances for bugs.
3704
3717
3705 * Added a crash handler which generates a complete post-mortem if
3718 * Added a crash handler which generates a complete post-mortem if
3706 IPython crashes. This will help a lot in tracking bugs down the
3719 IPython crashes. This will help a lot in tracking bugs down the
3707 road.
3720 road.
3708
3721
3709 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3722 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3710 which were boud to functions being reassigned would bypass the
3723 which were boud to functions being reassigned would bypass the
3711 logger, breaking the sync of _il with the prompt counter. This
3724 logger, breaking the sync of _il with the prompt counter. This
3712 would then crash IPython later when a new line was logged.
3725 would then crash IPython later when a new line was logged.
3713
3726
3714 2001-12-02 Fernando Perez <fperez@colorado.edu>
3727 2001-12-02 Fernando Perez <fperez@colorado.edu>
3715
3728
3716 * Made IPython a package. This means people don't have to clutter
3729 * Made IPython a package. This means people don't have to clutter
3717 their sys.path with yet another directory. Changed the INSTALL
3730 their sys.path with yet another directory. Changed the INSTALL
3718 file accordingly.
3731 file accordingly.
3719
3732
3720 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
3733 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
3721 sorts its output (so @who shows it sorted) and @whos formats the
3734 sorts its output (so @who shows it sorted) and @whos formats the
3722 table according to the width of the first column. Nicer, easier to
3735 table according to the width of the first column. Nicer, easier to
3723 read. Todo: write a generic table_format() which takes a list of
3736 read. Todo: write a generic table_format() which takes a list of
3724 lists and prints it nicely formatted, with optional row/column
3737 lists and prints it nicely formatted, with optional row/column
3725 separators and proper padding and justification.
3738 separators and proper padding and justification.
3726
3739
3727 * Released 0.1.20
3740 * Released 0.1.20
3728
3741
3729 * Fixed bug in @log which would reverse the inputcache list (a
3742 * Fixed bug in @log which would reverse the inputcache list (a
3730 copy operation was missing).
3743 copy operation was missing).
3731
3744
3732 * Code cleanup. @config was changed to use page(). Better, since
3745 * Code cleanup. @config was changed to use page(). Better, since
3733 its output is always quite long.
3746 its output is always quite long.
3734
3747
3735 * Itpl is back as a dependency. I was having too many problems
3748 * Itpl is back as a dependency. I was having too many problems
3736 getting the parametric aliases to work reliably, and it's just
3749 getting the parametric aliases to work reliably, and it's just
3737 easier to code weird string operations with it than playing %()s
3750 easier to code weird string operations with it than playing %()s
3738 games. It's only ~6k, so I don't think it's too big a deal.
3751 games. It's only ~6k, so I don't think it's too big a deal.
3739
3752
3740 * Found (and fixed) a very nasty bug with history. !lines weren't
3753 * Found (and fixed) a very nasty bug with history. !lines weren't
3741 getting cached, and the out of sync caches would crash
3754 getting cached, and the out of sync caches would crash
3742 IPython. Fixed it by reorganizing the prefilter/handlers/logger
3755 IPython. Fixed it by reorganizing the prefilter/handlers/logger
3743 division of labor a bit better. Bug fixed, cleaner structure.
3756 division of labor a bit better. Bug fixed, cleaner structure.
3744
3757
3745 2001-12-01 Fernando Perez <fperez@colorado.edu>
3758 2001-12-01 Fernando Perez <fperez@colorado.edu>
3746
3759
3747 * Released 0.1.19
3760 * Released 0.1.19
3748
3761
3749 * Added option -n to @hist to prevent line number printing. Much
3762 * Added option -n to @hist to prevent line number printing. Much
3750 easier to copy/paste code this way.
3763 easier to copy/paste code this way.
3751
3764
3752 * Created global _il to hold the input list. Allows easy
3765 * Created global _il to hold the input list. Allows easy
3753 re-execution of blocks of code by slicing it (inspired by Janko's
3766 re-execution of blocks of code by slicing it (inspired by Janko's
3754 comment on 'macros').
3767 comment on 'macros').
3755
3768
3756 * Small fixes and doc updates.
3769 * Small fixes and doc updates.
3757
3770
3758 * Rewrote @history function (was @h). Renamed it to @hist, @h is
3771 * Rewrote @history function (was @h). Renamed it to @hist, @h is
3759 much too fragile with automagic. Handles properly multi-line
3772 much too fragile with automagic. Handles properly multi-line
3760 statements and takes parameters.
3773 statements and takes parameters.
3761
3774
3762 2001-11-30 Fernando Perez <fperez@colorado.edu>
3775 2001-11-30 Fernando Perez <fperez@colorado.edu>
3763
3776
3764 * Version 0.1.18 released.
3777 * Version 0.1.18 released.
3765
3778
3766 * Fixed nasty namespace bug in initial module imports.
3779 * Fixed nasty namespace bug in initial module imports.
3767
3780
3768 * Added copyright/license notes to all code files (except
3781 * Added copyright/license notes to all code files (except
3769 DPyGetOpt). For the time being, LGPL. That could change.
3782 DPyGetOpt). For the time being, LGPL. That could change.
3770
3783
3771 * Rewrote a much nicer README, updated INSTALL, cleaned up
3784 * Rewrote a much nicer README, updated INSTALL, cleaned up
3772 ipythonrc-* samples.
3785 ipythonrc-* samples.
3773
3786
3774 * Overall code/documentation cleanup. Basically ready for
3787 * Overall code/documentation cleanup. Basically ready for
3775 release. Only remaining thing: licence decision (LGPL?).
3788 release. Only remaining thing: licence decision (LGPL?).
3776
3789
3777 * Converted load_config to a class, ConfigLoader. Now recursion
3790 * Converted load_config to a class, ConfigLoader. Now recursion
3778 control is better organized. Doesn't include the same file twice.
3791 control is better organized. Doesn't include the same file twice.
3779
3792
3780 2001-11-29 Fernando Perez <fperez@colorado.edu>
3793 2001-11-29 Fernando Perez <fperez@colorado.edu>
3781
3794
3782 * Got input history working. Changed output history variables from
3795 * Got input history working. Changed output history variables from
3783 _p to _o so that _i is for input and _o for output. Just cleaner
3796 _p to _o so that _i is for input and _o for output. Just cleaner
3784 convention.
3797 convention.
3785
3798
3786 * Implemented parametric aliases. This pretty much allows the
3799 * Implemented parametric aliases. This pretty much allows the
3787 alias system to offer full-blown shell convenience, I think.
3800 alias system to offer full-blown shell convenience, I think.
3788
3801
3789 * Version 0.1.17 released, 0.1.18 opened.
3802 * Version 0.1.17 released, 0.1.18 opened.
3790
3803
3791 * dot_ipython/ipythonrc (alias): added documentation.
3804 * dot_ipython/ipythonrc (alias): added documentation.
3792 (xcolor): Fixed small bug (xcolors -> xcolor)
3805 (xcolor): Fixed small bug (xcolors -> xcolor)
3793
3806
3794 * Changed the alias system. Now alias is a magic command to define
3807 * Changed the alias system. Now alias is a magic command to define
3795 aliases just like the shell. Rationale: the builtin magics should
3808 aliases just like the shell. Rationale: the builtin magics should
3796 be there for things deeply connected to IPython's
3809 be there for things deeply connected to IPython's
3797 architecture. And this is a much lighter system for what I think
3810 architecture. And this is a much lighter system for what I think
3798 is the really important feature: allowing users to define quickly
3811 is the really important feature: allowing users to define quickly
3799 magics that will do shell things for them, so they can customize
3812 magics that will do shell things for them, so they can customize
3800 IPython easily to match their work habits. If someone is really
3813 IPython easily to match their work habits. If someone is really
3801 desperate to have another name for a builtin alias, they can
3814 desperate to have another name for a builtin alias, they can
3802 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
3815 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
3803 works.
3816 works.
3804
3817
3805 2001-11-28 Fernando Perez <fperez@colorado.edu>
3818 2001-11-28 Fernando Perez <fperez@colorado.edu>
3806
3819
3807 * Changed @file so that it opens the source file at the proper
3820 * Changed @file so that it opens the source file at the proper
3808 line. Since it uses less, if your EDITOR environment is
3821 line. Since it uses less, if your EDITOR environment is
3809 configured, typing v will immediately open your editor of choice
3822 configured, typing v will immediately open your editor of choice
3810 right at the line where the object is defined. Not as quick as
3823 right at the line where the object is defined. Not as quick as
3811 having a direct @edit command, but for all intents and purposes it
3824 having a direct @edit command, but for all intents and purposes it
3812 works. And I don't have to worry about writing @edit to deal with
3825 works. And I don't have to worry about writing @edit to deal with
3813 all the editors, less does that.
3826 all the editors, less does that.
3814
3827
3815 * Version 0.1.16 released, 0.1.17 opened.
3828 * Version 0.1.16 released, 0.1.17 opened.
3816
3829
3817 * Fixed some nasty bugs in the page/page_dumb combo that could
3830 * Fixed some nasty bugs in the page/page_dumb combo that could
3818 crash IPython.
3831 crash IPython.
3819
3832
3820 2001-11-27 Fernando Perez <fperez@colorado.edu>
3833 2001-11-27 Fernando Perez <fperez@colorado.edu>
3821
3834
3822 * Version 0.1.15 released, 0.1.16 opened.
3835 * Version 0.1.15 released, 0.1.16 opened.
3823
3836
3824 * Finally got ? and ?? to work for undefined things: now it's
3837 * Finally got ? and ?? to work for undefined things: now it's
3825 possible to type {}.get? and get information about the get method
3838 possible to type {}.get? and get information about the get method
3826 of dicts, or os.path? even if only os is defined (so technically
3839 of dicts, or os.path? even if only os is defined (so technically
3827 os.path isn't). Works at any level. For example, after import os,
3840 os.path isn't). Works at any level. For example, after import os,
3828 os?, os.path?, os.path.abspath? all work. This is great, took some
3841 os?, os.path?, os.path.abspath? all work. This is great, took some
3829 work in _ofind.
3842 work in _ofind.
3830
3843
3831 * Fixed more bugs with logging. The sanest way to do it was to add
3844 * Fixed more bugs with logging. The sanest way to do it was to add
3832 to @log a 'mode' parameter. Killed two in one shot (this mode
3845 to @log a 'mode' parameter. Killed two in one shot (this mode
3833 option was a request of Janko's). I think it's finally clean
3846 option was a request of Janko's). I think it's finally clean
3834 (famous last words).
3847 (famous last words).
3835
3848
3836 * Added a page_dumb() pager which does a decent job of paging on
3849 * Added a page_dumb() pager which does a decent job of paging on
3837 screen, if better things (like less) aren't available. One less
3850 screen, if better things (like less) aren't available. One less
3838 unix dependency (someday maybe somebody will port this to
3851 unix dependency (someday maybe somebody will port this to
3839 windows).
3852 windows).
3840
3853
3841 * Fixed problem in magic_log: would lock of logging out if log
3854 * Fixed problem in magic_log: would lock of logging out if log
3842 creation failed (because it would still think it had succeeded).
3855 creation failed (because it would still think it had succeeded).
3843
3856
3844 * Improved the page() function using curses to auto-detect screen
3857 * Improved the page() function using curses to auto-detect screen
3845 size. Now it can make a much better decision on whether to print
3858 size. Now it can make a much better decision on whether to print
3846 or page a string. Option screen_length was modified: a value 0
3859 or page a string. Option screen_length was modified: a value 0
3847 means auto-detect, and that's the default now.
3860 means auto-detect, and that's the default now.
3848
3861
3849 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
3862 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
3850 go out. I'll test it for a few days, then talk to Janko about
3863 go out. I'll test it for a few days, then talk to Janko about
3851 licences and announce it.
3864 licences and announce it.
3852
3865
3853 * Fixed the length of the auto-generated ---> prompt which appears
3866 * Fixed the length of the auto-generated ---> prompt which appears
3854 for auto-parens and auto-quotes. Getting this right isn't trivial,
3867 for auto-parens and auto-quotes. Getting this right isn't trivial,
3855 with all the color escapes, different prompt types and optional
3868 with all the color escapes, different prompt types and optional
3856 separators. But it seems to be working in all the combinations.
3869 separators. But it seems to be working in all the combinations.
3857
3870
3858 2001-11-26 Fernando Perez <fperez@colorado.edu>
3871 2001-11-26 Fernando Perez <fperez@colorado.edu>
3859
3872
3860 * Wrote a regexp filter to get option types from the option names
3873 * Wrote a regexp filter to get option types from the option names
3861 string. This eliminates the need to manually keep two duplicate
3874 string. This eliminates the need to manually keep two duplicate
3862 lists.
3875 lists.
3863
3876
3864 * Removed the unneeded check_option_names. Now options are handled
3877 * Removed the unneeded check_option_names. Now options are handled
3865 in a much saner manner and it's easy to visually check that things
3878 in a much saner manner and it's easy to visually check that things
3866 are ok.
3879 are ok.
3867
3880
3868 * Updated version numbers on all files I modified to carry a
3881 * Updated version numbers on all files I modified to carry a
3869 notice so Janko and Nathan have clear version markers.
3882 notice so Janko and Nathan have clear version markers.
3870
3883
3871 * Updated docstring for ultraTB with my changes. I should send
3884 * Updated docstring for ultraTB with my changes. I should send
3872 this to Nathan.
3885 this to Nathan.
3873
3886
3874 * Lots of small fixes. Ran everything through pychecker again.
3887 * Lots of small fixes. Ran everything through pychecker again.
3875
3888
3876 * Made loading of deep_reload an cmd line option. If it's not too
3889 * Made loading of deep_reload an cmd line option. If it's not too
3877 kosher, now people can just disable it. With -nodeep_reload it's
3890 kosher, now people can just disable it. With -nodeep_reload it's
3878 still available as dreload(), it just won't overwrite reload().
3891 still available as dreload(), it just won't overwrite reload().
3879
3892
3880 * Moved many options to the no| form (-opt and -noopt
3893 * Moved many options to the no| form (-opt and -noopt
3881 accepted). Cleaner.
3894 accepted). Cleaner.
3882
3895
3883 * Changed magic_log so that if called with no parameters, it uses
3896 * Changed magic_log so that if called with no parameters, it uses
3884 'rotate' mode. That way auto-generated logs aren't automatically
3897 'rotate' mode. That way auto-generated logs aren't automatically
3885 over-written. For normal logs, now a backup is made if it exists
3898 over-written. For normal logs, now a backup is made if it exists
3886 (only 1 level of backups). A new 'backup' mode was added to the
3899 (only 1 level of backups). A new 'backup' mode was added to the
3887 Logger class to support this. This was a request by Janko.
3900 Logger class to support this. This was a request by Janko.
3888
3901
3889 * Added @logoff/@logon to stop/restart an active log.
3902 * Added @logoff/@logon to stop/restart an active log.
3890
3903
3891 * Fixed a lot of bugs in log saving/replay. It was pretty
3904 * Fixed a lot of bugs in log saving/replay. It was pretty
3892 broken. Now special lines (!@,/) appear properly in the command
3905 broken. Now special lines (!@,/) appear properly in the command
3893 history after a log replay.
3906 history after a log replay.
3894
3907
3895 * Tried and failed to implement full session saving via pickle. My
3908 * Tried and failed to implement full session saving via pickle. My
3896 idea was to pickle __main__.__dict__, but modules can't be
3909 idea was to pickle __main__.__dict__, but modules can't be
3897 pickled. This would be a better alternative to replaying logs, but
3910 pickled. This would be a better alternative to replaying logs, but
3898 seems quite tricky to get to work. Changed -session to be called
3911 seems quite tricky to get to work. Changed -session to be called
3899 -logplay, which more accurately reflects what it does. And if we
3912 -logplay, which more accurately reflects what it does. And if we
3900 ever get real session saving working, -session is now available.
3913 ever get real session saving working, -session is now available.
3901
3914
3902 * Implemented color schemes for prompts also. As for tracebacks,
3915 * Implemented color schemes for prompts also. As for tracebacks,
3903 currently only NoColor and Linux are supported. But now the
3916 currently only NoColor and Linux are supported. But now the
3904 infrastructure is in place, based on a generic ColorScheme
3917 infrastructure is in place, based on a generic ColorScheme
3905 class. So writing and activating new schemes both for the prompts
3918 class. So writing and activating new schemes both for the prompts
3906 and the tracebacks should be straightforward.
3919 and the tracebacks should be straightforward.
3907
3920
3908 * Version 0.1.13 released, 0.1.14 opened.
3921 * Version 0.1.13 released, 0.1.14 opened.
3909
3922
3910 * Changed handling of options for output cache. Now counter is
3923 * Changed handling of options for output cache. Now counter is
3911 hardwired starting at 1 and one specifies the maximum number of
3924 hardwired starting at 1 and one specifies the maximum number of
3912 entries *in the outcache* (not the max prompt counter). This is
3925 entries *in the outcache* (not the max prompt counter). This is
3913 much better, since many statements won't increase the cache
3926 much better, since many statements won't increase the cache
3914 count. It also eliminated some confusing options, now there's only
3927 count. It also eliminated some confusing options, now there's only
3915 one: cache_size.
3928 one: cache_size.
3916
3929
3917 * Added 'alias' magic function and magic_alias option in the
3930 * Added 'alias' magic function and magic_alias option in the
3918 ipythonrc file. Now the user can easily define whatever names he
3931 ipythonrc file. Now the user can easily define whatever names he
3919 wants for the magic functions without having to play weird
3932 wants for the magic functions without having to play weird
3920 namespace games. This gives IPython a real shell-like feel.
3933 namespace games. This gives IPython a real shell-like feel.
3921
3934
3922 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
3935 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
3923 @ or not).
3936 @ or not).
3924
3937
3925 This was one of the last remaining 'visible' bugs (that I know
3938 This was one of the last remaining 'visible' bugs (that I know
3926 of). I think if I can clean up the session loading so it works
3939 of). I think if I can clean up the session loading so it works
3927 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
3940 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
3928 about licensing).
3941 about licensing).
3929
3942
3930 2001-11-25 Fernando Perez <fperez@colorado.edu>
3943 2001-11-25 Fernando Perez <fperez@colorado.edu>
3931
3944
3932 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
3945 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
3933 there's a cleaner distinction between what ? and ?? show.
3946 there's a cleaner distinction between what ? and ?? show.
3934
3947
3935 * Added screen_length option. Now the user can define his own
3948 * Added screen_length option. Now the user can define his own
3936 screen size for page() operations.
3949 screen size for page() operations.
3937
3950
3938 * Implemented magic shell-like functions with automatic code
3951 * Implemented magic shell-like functions with automatic code
3939 generation. Now adding another function is just a matter of adding
3952 generation. Now adding another function is just a matter of adding
3940 an entry to a dict, and the function is dynamically generated at
3953 an entry to a dict, and the function is dynamically generated at
3941 run-time. Python has some really cool features!
3954 run-time. Python has some really cool features!
3942
3955
3943 * Renamed many options to cleanup conventions a little. Now all
3956 * Renamed many options to cleanup conventions a little. Now all
3944 are lowercase, and only underscores where needed. Also in the code
3957 are lowercase, and only underscores where needed. Also in the code
3945 option name tables are clearer.
3958 option name tables are clearer.
3946
3959
3947 * Changed prompts a little. Now input is 'In [n]:' instead of
3960 * Changed prompts a little. Now input is 'In [n]:' instead of
3948 'In[n]:='. This allows it the numbers to be aligned with the
3961 'In[n]:='. This allows it the numbers to be aligned with the
3949 Out[n] numbers, and removes usage of ':=' which doesn't exist in
3962 Out[n] numbers, and removes usage of ':=' which doesn't exist in
3950 Python (it was a Mathematica thing). The '...' continuation prompt
3963 Python (it was a Mathematica thing). The '...' continuation prompt
3951 was also changed a little to align better.
3964 was also changed a little to align better.
3952
3965
3953 * Fixed bug when flushing output cache. Not all _p<n> variables
3966 * Fixed bug when flushing output cache. Not all _p<n> variables
3954 exist, so their deletion needs to be wrapped in a try:
3967 exist, so their deletion needs to be wrapped in a try:
3955
3968
3956 * Figured out how to properly use inspect.formatargspec() (it
3969 * Figured out how to properly use inspect.formatargspec() (it
3957 requires the args preceded by *). So I removed all the code from
3970 requires the args preceded by *). So I removed all the code from
3958 _get_pdef in Magic, which was just replicating that.
3971 _get_pdef in Magic, which was just replicating that.
3959
3972
3960 * Added test to prefilter to allow redefining magic function names
3973 * Added test to prefilter to allow redefining magic function names
3961 as variables. This is ok, since the @ form is always available,
3974 as variables. This is ok, since the @ form is always available,
3962 but whe should allow the user to define a variable called 'ls' if
3975 but whe should allow the user to define a variable called 'ls' if
3963 he needs it.
3976 he needs it.
3964
3977
3965 * Moved the ToDo information from README into a separate ToDo.
3978 * Moved the ToDo information from README into a separate ToDo.
3966
3979
3967 * General code cleanup and small bugfixes. I think it's close to a
3980 * General code cleanup and small bugfixes. I think it's close to a
3968 state where it can be released, obviously with a big 'beta'
3981 state where it can be released, obviously with a big 'beta'
3969 warning on it.
3982 warning on it.
3970
3983
3971 * Got the magic function split to work. Now all magics are defined
3984 * Got the magic function split to work. Now all magics are defined
3972 in a separate class. It just organizes things a bit, and now
3985 in a separate class. It just organizes things a bit, and now
3973 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
3986 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
3974 was too long).
3987 was too long).
3975
3988
3976 * Changed @clear to @reset to avoid potential confusions with
3989 * Changed @clear to @reset to avoid potential confusions with
3977 the shell command clear. Also renamed @cl to @clear, which does
3990 the shell command clear. Also renamed @cl to @clear, which does
3978 exactly what people expect it to from their shell experience.
3991 exactly what people expect it to from their shell experience.
3979
3992
3980 Added a check to the @reset command (since it's so
3993 Added a check to the @reset command (since it's so
3981 destructive, it's probably a good idea to ask for confirmation).
3994 destructive, it's probably a good idea to ask for confirmation).
3982 But now reset only works for full namespace resetting. Since the
3995 But now reset only works for full namespace resetting. Since the
3983 del keyword is already there for deleting a few specific
3996 del keyword is already there for deleting a few specific
3984 variables, I don't see the point of having a redundant magic
3997 variables, I don't see the point of having a redundant magic
3985 function for the same task.
3998 function for the same task.
3986
3999
3987 2001-11-24 Fernando Perez <fperez@colorado.edu>
4000 2001-11-24 Fernando Perez <fperez@colorado.edu>
3988
4001
3989 * Updated the builtin docs (esp. the ? ones).
4002 * Updated the builtin docs (esp. the ? ones).
3990
4003
3991 * Ran all the code through pychecker. Not terribly impressed with
4004 * Ran all the code through pychecker. Not terribly impressed with
3992 it: lots of spurious warnings and didn't really find anything of
4005 it: lots of spurious warnings and didn't really find anything of
3993 substance (just a few modules being imported and not used).
4006 substance (just a few modules being imported and not used).
3994
4007
3995 * Implemented the new ultraTB functionality into IPython. New
4008 * Implemented the new ultraTB functionality into IPython. New
3996 option: xcolors. This chooses color scheme. xmode now only selects
4009 option: xcolors. This chooses color scheme. xmode now only selects
3997 between Plain and Verbose. Better orthogonality.
4010 between Plain and Verbose. Better orthogonality.
3998
4011
3999 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4012 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4000 mode and color scheme for the exception handlers. Now it's
4013 mode and color scheme for the exception handlers. Now it's
4001 possible to have the verbose traceback with no coloring.
4014 possible to have the verbose traceback with no coloring.
4002
4015
4003 2001-11-23 Fernando Perez <fperez@colorado.edu>
4016 2001-11-23 Fernando Perez <fperez@colorado.edu>
4004
4017
4005 * Version 0.1.12 released, 0.1.13 opened.
4018 * Version 0.1.12 released, 0.1.13 opened.
4006
4019
4007 * Removed option to set auto-quote and auto-paren escapes by
4020 * Removed option to set auto-quote and auto-paren escapes by
4008 user. The chances of breaking valid syntax are just too high. If
4021 user. The chances of breaking valid syntax are just too high. If
4009 someone *really* wants, they can always dig into the code.
4022 someone *really* wants, they can always dig into the code.
4010
4023
4011 * Made prompt separators configurable.
4024 * Made prompt separators configurable.
4012
4025
4013 2001-11-22 Fernando Perez <fperez@colorado.edu>
4026 2001-11-22 Fernando Perez <fperez@colorado.edu>
4014
4027
4015 * Small bugfixes in many places.
4028 * Small bugfixes in many places.
4016
4029
4017 * Removed the MyCompleter class from ipplib. It seemed redundant
4030 * Removed the MyCompleter class from ipplib. It seemed redundant
4018 with the C-p,C-n history search functionality. Less code to
4031 with the C-p,C-n history search functionality. Less code to
4019 maintain.
4032 maintain.
4020
4033
4021 * Moved all the original ipython.py code into ipythonlib.py. Right
4034 * Moved all the original ipython.py code into ipythonlib.py. Right
4022 now it's just one big dump into a function called make_IPython, so
4035 now it's just one big dump into a function called make_IPython, so
4023 no real modularity has been gained. But at least it makes the
4036 no real modularity has been gained. But at least it makes the
4024 wrapper script tiny, and since ipythonlib is a module, it gets
4037 wrapper script tiny, and since ipythonlib is a module, it gets
4025 compiled and startup is much faster.
4038 compiled and startup is much faster.
4026
4039
4027 This is a reasobably 'deep' change, so we should test it for a
4040 This is a reasobably 'deep' change, so we should test it for a
4028 while without messing too much more with the code.
4041 while without messing too much more with the code.
4029
4042
4030 2001-11-21 Fernando Perez <fperez@colorado.edu>
4043 2001-11-21 Fernando Perez <fperez@colorado.edu>
4031
4044
4032 * Version 0.1.11 released, 0.1.12 opened for further work.
4045 * Version 0.1.11 released, 0.1.12 opened for further work.
4033
4046
4034 * Removed dependency on Itpl. It was only needed in one place. It
4047 * Removed dependency on Itpl. It was only needed in one place. It
4035 would be nice if this became part of python, though. It makes life
4048 would be nice if this became part of python, though. It makes life
4036 *a lot* easier in some cases.
4049 *a lot* easier in some cases.
4037
4050
4038 * Simplified the prefilter code a bit. Now all handlers are
4051 * Simplified the prefilter code a bit. Now all handlers are
4039 expected to explicitly return a value (at least a blank string).
4052 expected to explicitly return a value (at least a blank string).
4040
4053
4041 * Heavy edits in ipplib. Removed the help system altogether. Now
4054 * Heavy edits in ipplib. Removed the help system altogether. Now
4042 obj?/?? is used for inspecting objects, a magic @doc prints
4055 obj?/?? is used for inspecting objects, a magic @doc prints
4043 docstrings, and full-blown Python help is accessed via the 'help'
4056 docstrings, and full-blown Python help is accessed via the 'help'
4044 keyword. This cleans up a lot of code (less to maintain) and does
4057 keyword. This cleans up a lot of code (less to maintain) and does
4045 the job. Since 'help' is now a standard Python component, might as
4058 the job. Since 'help' is now a standard Python component, might as
4046 well use it and remove duplicate functionality.
4059 well use it and remove duplicate functionality.
4047
4060
4048 Also removed the option to use ipplib as a standalone program. By
4061 Also removed the option to use ipplib as a standalone program. By
4049 now it's too dependent on other parts of IPython to function alone.
4062 now it's too dependent on other parts of IPython to function alone.
4050
4063
4051 * Fixed bug in genutils.pager. It would crash if the pager was
4064 * Fixed bug in genutils.pager. It would crash if the pager was
4052 exited immediately after opening (broken pipe).
4065 exited immediately after opening (broken pipe).
4053
4066
4054 * Trimmed down the VerboseTB reporting a little. The header is
4067 * Trimmed down the VerboseTB reporting a little. The header is
4055 much shorter now and the repeated exception arguments at the end
4068 much shorter now and the repeated exception arguments at the end
4056 have been removed. For interactive use the old header seemed a bit
4069 have been removed. For interactive use the old header seemed a bit
4057 excessive.
4070 excessive.
4058
4071
4059 * Fixed small bug in output of @whos for variables with multi-word
4072 * Fixed small bug in output of @whos for variables with multi-word
4060 types (only first word was displayed).
4073 types (only first word was displayed).
4061
4074
4062 2001-11-17 Fernando Perez <fperez@colorado.edu>
4075 2001-11-17 Fernando Perez <fperez@colorado.edu>
4063
4076
4064 * Version 0.1.10 released, 0.1.11 opened for further work.
4077 * Version 0.1.10 released, 0.1.11 opened for further work.
4065
4078
4066 * Modified dirs and friends. dirs now *returns* the stack (not
4079 * Modified dirs and friends. dirs now *returns* the stack (not
4067 prints), so one can manipulate it as a variable. Convenient to
4080 prints), so one can manipulate it as a variable. Convenient to
4068 travel along many directories.
4081 travel along many directories.
4069
4082
4070 * Fixed bug in magic_pdef: would only work with functions with
4083 * Fixed bug in magic_pdef: would only work with functions with
4071 arguments with default values.
4084 arguments with default values.
4072
4085
4073 2001-11-14 Fernando Perez <fperez@colorado.edu>
4086 2001-11-14 Fernando Perez <fperez@colorado.edu>
4074
4087
4075 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4088 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4076 example with IPython. Various other minor fixes and cleanups.
4089 example with IPython. Various other minor fixes and cleanups.
4077
4090
4078 * Version 0.1.9 released, 0.1.10 opened for further work.
4091 * Version 0.1.9 released, 0.1.10 opened for further work.
4079
4092
4080 * Added sys.path to the list of directories searched in the
4093 * Added sys.path to the list of directories searched in the
4081 execfile= option. It used to be the current directory and the
4094 execfile= option. It used to be the current directory and the
4082 user's IPYTHONDIR only.
4095 user's IPYTHONDIR only.
4083
4096
4084 2001-11-13 Fernando Perez <fperez@colorado.edu>
4097 2001-11-13 Fernando Perez <fperez@colorado.edu>
4085
4098
4086 * Reinstated the raw_input/prefilter separation that Janko had
4099 * Reinstated the raw_input/prefilter separation that Janko had
4087 initially. This gives a more convenient setup for extending the
4100 initially. This gives a more convenient setup for extending the
4088 pre-processor from the outside: raw_input always gets a string,
4101 pre-processor from the outside: raw_input always gets a string,
4089 and prefilter has to process it. We can then redefine prefilter
4102 and prefilter has to process it. We can then redefine prefilter
4090 from the outside and implement extensions for special
4103 from the outside and implement extensions for special
4091 purposes.
4104 purposes.
4092
4105
4093 Today I got one for inputting PhysicalQuantity objects
4106 Today I got one for inputting PhysicalQuantity objects
4094 (from Scientific) without needing any function calls at
4107 (from Scientific) without needing any function calls at
4095 all. Extremely convenient, and it's all done as a user-level
4108 all. Extremely convenient, and it's all done as a user-level
4096 extension (no IPython code was touched). Now instead of:
4109 extension (no IPython code was touched). Now instead of:
4097 a = PhysicalQuantity(4.2,'m/s**2')
4110 a = PhysicalQuantity(4.2,'m/s**2')
4098 one can simply say
4111 one can simply say
4099 a = 4.2 m/s**2
4112 a = 4.2 m/s**2
4100 or even
4113 or even
4101 a = 4.2 m/s^2
4114 a = 4.2 m/s^2
4102
4115
4103 I use this, but it's also a proof of concept: IPython really is
4116 I use this, but it's also a proof of concept: IPython really is
4104 fully user-extensible, even at the level of the parsing of the
4117 fully user-extensible, even at the level of the parsing of the
4105 command line. It's not trivial, but it's perfectly doable.
4118 command line. It's not trivial, but it's perfectly doable.
4106
4119
4107 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4120 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4108 the problem of modules being loaded in the inverse order in which
4121 the problem of modules being loaded in the inverse order in which
4109 they were defined in
4122 they were defined in
4110
4123
4111 * Version 0.1.8 released, 0.1.9 opened for further work.
4124 * Version 0.1.8 released, 0.1.9 opened for further work.
4112
4125
4113 * Added magics pdef, source and file. They respectively show the
4126 * Added magics pdef, source and file. They respectively show the
4114 definition line ('prototype' in C), source code and full python
4127 definition line ('prototype' in C), source code and full python
4115 file for any callable object. The object inspector oinfo uses
4128 file for any callable object. The object inspector oinfo uses
4116 these to show the same information.
4129 these to show the same information.
4117
4130
4118 * Version 0.1.7 released, 0.1.8 opened for further work.
4131 * Version 0.1.7 released, 0.1.8 opened for further work.
4119
4132
4120 * Separated all the magic functions into a class called Magic. The
4133 * Separated all the magic functions into a class called Magic. The
4121 InteractiveShell class was becoming too big for Xemacs to handle
4134 InteractiveShell class was becoming too big for Xemacs to handle
4122 (de-indenting a line would lock it up for 10 seconds while it
4135 (de-indenting a line would lock it up for 10 seconds while it
4123 backtracked on the whole class!)
4136 backtracked on the whole class!)
4124
4137
4125 FIXME: didn't work. It can be done, but right now namespaces are
4138 FIXME: didn't work. It can be done, but right now namespaces are
4126 all messed up. Do it later (reverted it for now, so at least
4139 all messed up. Do it later (reverted it for now, so at least
4127 everything works as before).
4140 everything works as before).
4128
4141
4129 * Got the object introspection system (magic_oinfo) working! I
4142 * Got the object introspection system (magic_oinfo) working! I
4130 think this is pretty much ready for release to Janko, so he can
4143 think this is pretty much ready for release to Janko, so he can
4131 test it for a while and then announce it. Pretty much 100% of what
4144 test it for a while and then announce it. Pretty much 100% of what
4132 I wanted for the 'phase 1' release is ready. Happy, tired.
4145 I wanted for the 'phase 1' release is ready. Happy, tired.
4133
4146
4134 2001-11-12 Fernando Perez <fperez@colorado.edu>
4147 2001-11-12 Fernando Perez <fperez@colorado.edu>
4135
4148
4136 * Version 0.1.6 released, 0.1.7 opened for further work.
4149 * Version 0.1.6 released, 0.1.7 opened for further work.
4137
4150
4138 * Fixed bug in printing: it used to test for truth before
4151 * Fixed bug in printing: it used to test for truth before
4139 printing, so 0 wouldn't print. Now checks for None.
4152 printing, so 0 wouldn't print. Now checks for None.
4140
4153
4141 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4154 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4142 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4155 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4143 reaches by hand into the outputcache. Think of a better way to do
4156 reaches by hand into the outputcache. Think of a better way to do
4144 this later.
4157 this later.
4145
4158
4146 * Various small fixes thanks to Nathan's comments.
4159 * Various small fixes thanks to Nathan's comments.
4147
4160
4148 * Changed magic_pprint to magic_Pprint. This way it doesn't
4161 * Changed magic_pprint to magic_Pprint. This way it doesn't
4149 collide with pprint() and the name is consistent with the command
4162 collide with pprint() and the name is consistent with the command
4150 line option.
4163 line option.
4151
4164
4152 * Changed prompt counter behavior to be fully like
4165 * Changed prompt counter behavior to be fully like
4153 Mathematica's. That is, even input that doesn't return a result
4166 Mathematica's. That is, even input that doesn't return a result
4154 raises the prompt counter. The old behavior was kind of confusing
4167 raises the prompt counter. The old behavior was kind of confusing
4155 (getting the same prompt number several times if the operation
4168 (getting the same prompt number several times if the operation
4156 didn't return a result).
4169 didn't return a result).
4157
4170
4158 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4171 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4159
4172
4160 * Fixed -Classic mode (wasn't working anymore).
4173 * Fixed -Classic mode (wasn't working anymore).
4161
4174
4162 * Added colored prompts using Nathan's new code. Colors are
4175 * Added colored prompts using Nathan's new code. Colors are
4163 currently hardwired, they can be user-configurable. For
4176 currently hardwired, they can be user-configurable. For
4164 developers, they can be chosen in file ipythonlib.py, at the
4177 developers, they can be chosen in file ipythonlib.py, at the
4165 beginning of the CachedOutput class def.
4178 beginning of the CachedOutput class def.
4166
4179
4167 2001-11-11 Fernando Perez <fperez@colorado.edu>
4180 2001-11-11 Fernando Perez <fperez@colorado.edu>
4168
4181
4169 * Version 0.1.5 released, 0.1.6 opened for further work.
4182 * Version 0.1.5 released, 0.1.6 opened for further work.
4170
4183
4171 * Changed magic_env to *return* the environment as a dict (not to
4184 * Changed magic_env to *return* the environment as a dict (not to
4172 print it). This way it prints, but it can also be processed.
4185 print it). This way it prints, but it can also be processed.
4173
4186
4174 * Added Verbose exception reporting to interactive
4187 * Added Verbose exception reporting to interactive
4175 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4188 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4176 traceback. Had to make some changes to the ultraTB file. This is
4189 traceback. Had to make some changes to the ultraTB file. This is
4177 probably the last 'big' thing in my mental todo list. This ties
4190 probably the last 'big' thing in my mental todo list. This ties
4178 in with the next entry:
4191 in with the next entry:
4179
4192
4180 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4193 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4181 has to specify is Plain, Color or Verbose for all exception
4194 has to specify is Plain, Color or Verbose for all exception
4182 handling.
4195 handling.
4183
4196
4184 * Removed ShellServices option. All this can really be done via
4197 * Removed ShellServices option. All this can really be done via
4185 the magic system. It's easier to extend, cleaner and has automatic
4198 the magic system. It's easier to extend, cleaner and has automatic
4186 namespace protection and documentation.
4199 namespace protection and documentation.
4187
4200
4188 2001-11-09 Fernando Perez <fperez@colorado.edu>
4201 2001-11-09 Fernando Perez <fperez@colorado.edu>
4189
4202
4190 * Fixed bug in output cache flushing (missing parameter to
4203 * Fixed bug in output cache flushing (missing parameter to
4191 __init__). Other small bugs fixed (found using pychecker).
4204 __init__). Other small bugs fixed (found using pychecker).
4192
4205
4193 * Version 0.1.4 opened for bugfixing.
4206 * Version 0.1.4 opened for bugfixing.
4194
4207
4195 2001-11-07 Fernando Perez <fperez@colorado.edu>
4208 2001-11-07 Fernando Perez <fperez@colorado.edu>
4196
4209
4197 * Version 0.1.3 released, mainly because of the raw_input bug.
4210 * Version 0.1.3 released, mainly because of the raw_input bug.
4198
4211
4199 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4212 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4200 and when testing for whether things were callable, a call could
4213 and when testing for whether things were callable, a call could
4201 actually be made to certain functions. They would get called again
4214 actually be made to certain functions. They would get called again
4202 once 'really' executed, with a resulting double call. A disaster
4215 once 'really' executed, with a resulting double call. A disaster
4203 in many cases (list.reverse() would never work!).
4216 in many cases (list.reverse() would never work!).
4204
4217
4205 * Removed prefilter() function, moved its code to raw_input (which
4218 * Removed prefilter() function, moved its code to raw_input (which
4206 after all was just a near-empty caller for prefilter). This saves
4219 after all was just a near-empty caller for prefilter). This saves
4207 a function call on every prompt, and simplifies the class a tiny bit.
4220 a function call on every prompt, and simplifies the class a tiny bit.
4208
4221
4209 * Fix _ip to __ip name in magic example file.
4222 * Fix _ip to __ip name in magic example file.
4210
4223
4211 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4224 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4212 work with non-gnu versions of tar.
4225 work with non-gnu versions of tar.
4213
4226
4214 2001-11-06 Fernando Perez <fperez@colorado.edu>
4227 2001-11-06 Fernando Perez <fperez@colorado.edu>
4215
4228
4216 * Version 0.1.2. Just to keep track of the recent changes.
4229 * Version 0.1.2. Just to keep track of the recent changes.
4217
4230
4218 * Fixed nasty bug in output prompt routine. It used to check 'if
4231 * Fixed nasty bug in output prompt routine. It used to check 'if
4219 arg != None...'. Problem is, this fails if arg implements a
4232 arg != None...'. Problem is, this fails if arg implements a
4220 special comparison (__cmp__) which disallows comparing to
4233 special comparison (__cmp__) which disallows comparing to
4221 None. Found it when trying to use the PhysicalQuantity module from
4234 None. Found it when trying to use the PhysicalQuantity module from
4222 ScientificPython.
4235 ScientificPython.
4223
4236
4224 2001-11-05 Fernando Perez <fperez@colorado.edu>
4237 2001-11-05 Fernando Perez <fperez@colorado.edu>
4225
4238
4226 * Also added dirs. Now the pushd/popd/dirs family functions
4239 * Also added dirs. Now the pushd/popd/dirs family functions
4227 basically like the shell, with the added convenience of going home
4240 basically like the shell, with the added convenience of going home
4228 when called with no args.
4241 when called with no args.
4229
4242
4230 * pushd/popd slightly modified to mimic shell behavior more
4243 * pushd/popd slightly modified to mimic shell behavior more
4231 closely.
4244 closely.
4232
4245
4233 * Added env,pushd,popd from ShellServices as magic functions. I
4246 * Added env,pushd,popd from ShellServices as magic functions. I
4234 think the cleanest will be to port all desired functions from
4247 think the cleanest will be to port all desired functions from
4235 ShellServices as magics and remove ShellServices altogether. This
4248 ShellServices as magics and remove ShellServices altogether. This
4236 will provide a single, clean way of adding functionality
4249 will provide a single, clean way of adding functionality
4237 (shell-type or otherwise) to IP.
4250 (shell-type or otherwise) to IP.
4238
4251
4239 2001-11-04 Fernando Perez <fperez@colorado.edu>
4252 2001-11-04 Fernando Perez <fperez@colorado.edu>
4240
4253
4241 * Added .ipython/ directory to sys.path. This way users can keep
4254 * Added .ipython/ directory to sys.path. This way users can keep
4242 customizations there and access them via import.
4255 customizations there and access them via import.
4243
4256
4244 2001-11-03 Fernando Perez <fperez@colorado.edu>
4257 2001-11-03 Fernando Perez <fperez@colorado.edu>
4245
4258
4246 * Opened version 0.1.1 for new changes.
4259 * Opened version 0.1.1 for new changes.
4247
4260
4248 * Changed version number to 0.1.0: first 'public' release, sent to
4261 * Changed version number to 0.1.0: first 'public' release, sent to
4249 Nathan and Janko.
4262 Nathan and Janko.
4250
4263
4251 * Lots of small fixes and tweaks.
4264 * Lots of small fixes and tweaks.
4252
4265
4253 * Minor changes to whos format. Now strings are shown, snipped if
4266 * Minor changes to whos format. Now strings are shown, snipped if
4254 too long.
4267 too long.
4255
4268
4256 * Changed ShellServices to work on __main__ so they show up in @who
4269 * Changed ShellServices to work on __main__ so they show up in @who
4257
4270
4258 * Help also works with ? at the end of a line:
4271 * Help also works with ? at the end of a line:
4259 ?sin and sin?
4272 ?sin and sin?
4260 both produce the same effect. This is nice, as often I use the
4273 both produce the same effect. This is nice, as often I use the
4261 tab-complete to find the name of a method, but I used to then have
4274 tab-complete to find the name of a method, but I used to then have
4262 to go to the beginning of the line to put a ? if I wanted more
4275 to go to the beginning of the line to put a ? if I wanted more
4263 info. Now I can just add the ? and hit return. Convenient.
4276 info. Now I can just add the ? and hit return. Convenient.
4264
4277
4265 2001-11-02 Fernando Perez <fperez@colorado.edu>
4278 2001-11-02 Fernando Perez <fperez@colorado.edu>
4266
4279
4267 * Python version check (>=2.1) added.
4280 * Python version check (>=2.1) added.
4268
4281
4269 * Added LazyPython documentation. At this point the docs are quite
4282 * Added LazyPython documentation. At this point the docs are quite
4270 a mess. A cleanup is in order.
4283 a mess. A cleanup is in order.
4271
4284
4272 * Auto-installer created. For some bizarre reason, the zipfiles
4285 * Auto-installer created. For some bizarre reason, the zipfiles
4273 module isn't working on my system. So I made a tar version
4286 module isn't working on my system. So I made a tar version
4274 (hopefully the command line options in various systems won't kill
4287 (hopefully the command line options in various systems won't kill
4275 me).
4288 me).
4276
4289
4277 * Fixes to Struct in genutils. Now all dictionary-like methods are
4290 * Fixes to Struct in genutils. Now all dictionary-like methods are
4278 protected (reasonably).
4291 protected (reasonably).
4279
4292
4280 * Added pager function to genutils and changed ? to print usage
4293 * Added pager function to genutils and changed ? to print usage
4281 note through it (it was too long).
4294 note through it (it was too long).
4282
4295
4283 * Added the LazyPython functionality. Works great! I changed the
4296 * Added the LazyPython functionality. Works great! I changed the
4284 auto-quote escape to ';', it's on home row and next to '. But
4297 auto-quote escape to ';', it's on home row and next to '. But
4285 both auto-quote and auto-paren (still /) escapes are command-line
4298 both auto-quote and auto-paren (still /) escapes are command-line
4286 parameters.
4299 parameters.
4287
4300
4288
4301
4289 2001-11-01 Fernando Perez <fperez@colorado.edu>
4302 2001-11-01 Fernando Perez <fperez@colorado.edu>
4290
4303
4291 * Version changed to 0.0.7. Fairly large change: configuration now
4304 * Version changed to 0.0.7. Fairly large change: configuration now
4292 is all stored in a directory, by default .ipython. There, all
4305 is all stored in a directory, by default .ipython. There, all
4293 config files have normal looking names (not .names)
4306 config files have normal looking names (not .names)
4294
4307
4295 * Version 0.0.6 Released first to Lucas and Archie as a test
4308 * Version 0.0.6 Released first to Lucas and Archie as a test
4296 run. Since it's the first 'semi-public' release, change version to
4309 run. Since it's the first 'semi-public' release, change version to
4297 > 0.0.6 for any changes now.
4310 > 0.0.6 for any changes now.
4298
4311
4299 * Stuff I had put in the ipplib.py changelog:
4312 * Stuff I had put in the ipplib.py changelog:
4300
4313
4301 Changes to InteractiveShell:
4314 Changes to InteractiveShell:
4302
4315
4303 - Made the usage message a parameter.
4316 - Made the usage message a parameter.
4304
4317
4305 - Require the name of the shell variable to be given. It's a bit
4318 - Require the name of the shell variable to be given. It's a bit
4306 of a hack, but allows the name 'shell' not to be hardwire in the
4319 of a hack, but allows the name 'shell' not to be hardwire in the
4307 magic (@) handler, which is problematic b/c it requires
4320 magic (@) handler, which is problematic b/c it requires
4308 polluting the global namespace with 'shell'. This in turn is
4321 polluting the global namespace with 'shell'. This in turn is
4309 fragile: if a user redefines a variable called shell, things
4322 fragile: if a user redefines a variable called shell, things
4310 break.
4323 break.
4311
4324
4312 - magic @: all functions available through @ need to be defined
4325 - magic @: all functions available through @ need to be defined
4313 as magic_<name>, even though they can be called simply as
4326 as magic_<name>, even though they can be called simply as
4314 @<name>. This allows the special command @magic to gather
4327 @<name>. This allows the special command @magic to gather
4315 information automatically about all existing magic functions,
4328 information automatically about all existing magic functions,
4316 even if they are run-time user extensions, by parsing the shell
4329 even if they are run-time user extensions, by parsing the shell
4317 instance __dict__ looking for special magic_ names.
4330 instance __dict__ looking for special magic_ names.
4318
4331
4319 - mainloop: added *two* local namespace parameters. This allows
4332 - mainloop: added *two* local namespace parameters. This allows
4320 the class to differentiate between parameters which were there
4333 the class to differentiate between parameters which were there
4321 before and after command line initialization was processed. This
4334 before and after command line initialization was processed. This
4322 way, later @who can show things loaded at startup by the
4335 way, later @who can show things loaded at startup by the
4323 user. This trick was necessary to make session saving/reloading
4336 user. This trick was necessary to make session saving/reloading
4324 really work: ideally after saving/exiting/reloading a session,
4337 really work: ideally after saving/exiting/reloading a session,
4325 *everythin* should look the same, including the output of @who. I
4338 *everythin* should look the same, including the output of @who. I
4326 was only able to make this work with this double namespace
4339 was only able to make this work with this double namespace
4327 trick.
4340 trick.
4328
4341
4329 - added a header to the logfile which allows (almost) full
4342 - added a header to the logfile which allows (almost) full
4330 session restoring.
4343 session restoring.
4331
4344
4332 - prepend lines beginning with @ or !, with a and log
4345 - prepend lines beginning with @ or !, with a and log
4333 them. Why? !lines: may be useful to know what you did @lines:
4346 them. Why? !lines: may be useful to know what you did @lines:
4334 they may affect session state. So when restoring a session, at
4347 they may affect session state. So when restoring a session, at
4335 least inform the user of their presence. I couldn't quite get
4348 least inform the user of their presence. I couldn't quite get
4336 them to properly re-execute, but at least the user is warned.
4349 them to properly re-execute, but at least the user is warned.
4337
4350
4338 * Started ChangeLog.
4351 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now