##// END OF EJS Templates
ipapi rehaul, moved api methods to class IPApi. Usage didn't change...
vivainio -
Show More
@@ -1,101 +1,102 b''
1 1 # -*- coding: utf-8 -*-
2 2 """ IPython extension: add %rehashdir magic
3 3
4 4 Usage:
5 5
6 6 %rehashdir c:/bin c:/tools
7 7 - Add all executables under c:/bin and c:/tools to alias table, in
8 8 order to make them directly executable from any directory.
9 9
10 10 This also serves as an example on how to extend ipython
11 11 with new magic functions.
12 12
13 13 Unlike rest of ipython, this requires Python 2.4 (optional
14 14 extensions are allowed to do that).
15 15
16 16 To install, add
17 17
18 18 "import_mod ext_rehashdir"
19 19
20 20 To your ipythonrc or just execute "import rehash_dir" in ipython
21 21 prompt.
22 22
23 23
24 24 $Id: InterpreterExec.py 994 2006-01-08 08:29:44Z fperez $
25 25 """
26 26
27 import IPython.ipapi as ip
27 import IPython.ipapi
28 ip = IPython.ipapi.get()
28 29
29 30
30 31 import os,re,fnmatch
31 32
32 @ip.asmagic("rehashdir")
33 33 def rehashdir_f(self,arg):
34 34 """ Add executables in all specified dirs to alias table
35 35
36 36 Usage:
37 37
38 38 %rehashdir c:/bin c:/tools
39 39 - Add all executables under c:/bin and c:/tools to alias table, in
40 40 order to make them directly executable from any directory.
41 41
42 42 Without arguments, add all executables in current directory.
43 43
44 44 """
45 45
46 46 # most of the code copied from Magic.magic_rehashx
47 47
48 48 def isjunk(fname):
49 49 junk = ['*~']
50 50 for j in junk:
51 51 if fnmatch.fnmatch(fname, j):
52 52 return True
53 53 return False
54 54
55 55 if not arg:
56 56 arg = '.'
57 57 path = map(os.path.abspath,arg.split())
58 58 alias_table = self.shell.alias_table
59 59
60 60 if os.name == 'posix':
61 61 isexec = lambda fname:os.path.isfile(fname) and \
62 62 os.access(fname,os.X_OK)
63 63 else:
64 64
65 65 try:
66 66 winext = os.environ['pathext'].replace(';','|').replace('.','')
67 67 except KeyError:
68 68 winext = 'exe|com|bat|py'
69 69
70 70 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
71 71 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
72 72 savedir = os.getcwd()
73 73 try:
74 74 # write the whole loop for posix/Windows so we don't have an if in
75 75 # the innermost part
76 76 if os.name == 'posix':
77 77 for pdir in path:
78 78 os.chdir(pdir)
79 79 for ff in os.listdir(pdir):
80 80 if isexec(ff) and not isjunk(ff):
81 81 # each entry in the alias table must be (N,name),
82 82 # where N is the number of positional arguments of the
83 83 # alias.
84 84 src,tgt = os.path.splitext(ff)[0], os.path.abspath(ff)
85 85 print "Aliasing:",src,"->",tgt
86 86 alias_table[src] = (0,tgt)
87 87 else:
88 88 for pdir in path:
89 89 os.chdir(pdir)
90 90 for ff in os.listdir(pdir):
91 91 if isexec(ff) and not isjunk(ff):
92 92 src, tgt = execre.sub(r'\1',ff), os.path.abspath(ff)
93 93 print "Aliasing:",src,"->",tgt
94 94 alias_table[src] = (0,tgt)
95 95 # Make sure the alias table doesn't contain keywords or builtins
96 96 self.shell.alias_table_validate()
97 97 # Call again init_auto_alias() so we get 'rm -i' and other
98 98 # modified aliases since %rehashx will probably clobber them
99 99 self.shell.init_auto_alias()
100 100 finally:
101 101 os.chdir(savedir)
102 ip.expose_magic("rehashdir",rehashdir_f)
@@ -1,955 +1,955 b''
1 1 # -*- coding: utf-8 -*-
2 2 """IPython Shell classes.
3 3
4 4 All the matplotlib support code was co-developed with John Hunter,
5 5 matplotlib's author.
6 6
7 $Id: Shell.py 1058 2006-01-22 14:30:01Z vivainio $"""
7 $Id: Shell.py 1079 2006-01-24 21:52:31Z vivainio $"""
8 8
9 9 #*****************************************************************************
10 10 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
11 11 #
12 12 # Distributed under the terms of the BSD License. The full license is in
13 13 # the file COPYING, distributed as part of this software.
14 14 #*****************************************************************************
15 15
16 16 from IPython import Release
17 17 __author__ = '%s <%s>' % Release.authors['Fernando']
18 18 __license__ = Release.license
19 19
20 20 # Code begins
21 21 import __builtin__
22 22 import __main__
23 23 import Queue
24 24 import os
25 25 import signal
26 26 import sys
27 27 import threading
28 28 import time
29 29
30 30 import IPython
31 31 from IPython import ultraTB
32 32 from IPython.genutils import Term,warn,error,flag_calls
33 33 from IPython.iplib import InteractiveShell
34 34 from IPython.ipmaker import make_IPython
35 35 from IPython.Magic import Magic
36 36 from IPython.ipstruct import Struct
37 37
38 38 # global flag to pass around information about Ctrl-C without exceptions
39 39 KBINT = False
40 40
41 41 # global flag to turn on/off Tk support.
42 42 USE_TK = False
43 43
44 44 #-----------------------------------------------------------------------------
45 45 # This class is trivial now, but I want to have it in to publish a clean
46 46 # interface. Later when the internals are reorganized, code that uses this
47 47 # shouldn't have to change.
48 48
49 49 class IPShell:
50 50 """Create an IPython instance."""
51 51
52 52 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
53 53 debug=1,shell_class=InteractiveShell):
54 54 self.IP = make_IPython(argv,user_ns=user_ns,user_global_ns=user_global_ns,
55 55 debug=debug,shell_class=shell_class)
56 56
57 57 def mainloop(self,sys_exit=0,banner=None):
58 58 self.IP.mainloop(banner)
59 59 if sys_exit:
60 60 sys.exit()
61 61
62 62 #-----------------------------------------------------------------------------
63 63 class IPShellEmbed:
64 64 """Allow embedding an IPython shell into a running program.
65 65
66 66 Instances of this class are callable, with the __call__ method being an
67 67 alias to the embed() method of an InteractiveShell instance.
68 68
69 69 Usage (see also the example-embed.py file for a running example):
70 70
71 71 ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override])
72 72
73 73 - argv: list containing valid command-line options for IPython, as they
74 74 would appear in sys.argv[1:].
75 75
76 76 For example, the following command-line options:
77 77
78 78 $ ipython -prompt_in1 'Input <\\#>' -colors LightBG
79 79
80 80 would be passed in the argv list as:
81 81
82 82 ['-prompt_in1','Input <\\#>','-colors','LightBG']
83 83
84 84 - banner: string which gets printed every time the interpreter starts.
85 85
86 86 - exit_msg: string which gets printed every time the interpreter exits.
87 87
88 88 - rc_override: a dict or Struct of configuration options such as those
89 89 used by IPython. These options are read from your ~/.ipython/ipythonrc
90 90 file when the Shell object is created. Passing an explicit rc_override
91 91 dict with any options you want allows you to override those values at
92 92 creation time without having to modify the file. This way you can create
93 93 embeddable instances configured in any way you want without editing any
94 94 global files (thus keeping your interactive IPython configuration
95 95 unchanged).
96 96
97 97 Then the ipshell instance can be called anywhere inside your code:
98 98
99 99 ipshell(header='') -> Opens up an IPython shell.
100 100
101 101 - header: string printed by the IPython shell upon startup. This can let
102 102 you know where in your code you are when dropping into the shell. Note
103 103 that 'banner' gets prepended to all calls, so header is used for
104 104 location-specific information.
105 105
106 106 For more details, see the __call__ method below.
107 107
108 108 When the IPython shell is exited with Ctrl-D, normal program execution
109 109 resumes.
110 110
111 111 This functionality was inspired by a posting on comp.lang.python by cmkl
112 112 <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and
113 113 by the IDL stop/continue commands."""
114 114
115 115 def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None):
116 116 """Note that argv here is a string, NOT a list."""
117 117 self.set_banner(banner)
118 118 self.set_exit_msg(exit_msg)
119 119 self.set_dummy_mode(0)
120 120
121 121 # sys.displayhook is a global, we need to save the user's original
122 122 # Don't rely on __displayhook__, as the user may have changed that.
123 123 self.sys_displayhook_ori = sys.displayhook
124 124
125 125 # save readline completer status
126 126 try:
127 127 #print 'Save completer',sys.ipcompleter # dbg
128 128 self.sys_ipcompleter_ori = sys.ipcompleter
129 129 except:
130 130 pass # not nested with IPython
131 131
132 132 # FIXME. Passing user_ns breaks namespace handling.
133 133 #self.IP = make_IPython(argv,user_ns=__main__.__dict__)
134 134 self.IP = make_IPython(argv,rc_override=rc_override,embedded=True)
135 135
136 136 # copy our own displayhook also
137 137 self.sys_displayhook_embed = sys.displayhook
138 138 # and leave the system's display hook clean
139 139 sys.displayhook = self.sys_displayhook_ori
140 140 # don't use the ipython crash handler so that user exceptions aren't
141 141 # trapped
142 142 sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors,
143 143 mode = self.IP.rc.xmode,
144 144 call_pdb = self.IP.rc.pdb)
145 145 self.restore_system_completer()
146 146
147 147 def restore_system_completer(self):
148 148 """Restores the readline completer which was in place.
149 149
150 150 This allows embedded IPython within IPython not to disrupt the
151 151 parent's completion.
152 152 """
153 153
154 154 try:
155 155 self.IP.readline.set_completer(self.sys_ipcompleter_ori)
156 156 sys.ipcompleter = self.sys_ipcompleter_ori
157 157 except:
158 158 pass
159 159
160 160 def __call__(self,header='',local_ns=None,global_ns=None,dummy=None):
161 161 """Activate the interactive interpreter.
162 162
163 163 __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start
164 164 the interpreter shell with the given local and global namespaces, and
165 165 optionally print a header string at startup.
166 166
167 167 The shell can be globally activated/deactivated using the
168 168 set/get_dummy_mode methods. This allows you to turn off a shell used
169 169 for debugging globally.
170 170
171 171 However, *each* time you call the shell you can override the current
172 172 state of dummy_mode with the optional keyword parameter 'dummy'. For
173 173 example, if you set dummy mode on with IPShell.set_dummy_mode(1), you
174 174 can still have a specific call work by making it as IPShell(dummy=0).
175 175
176 176 The optional keyword parameter dummy controls whether the call
177 177 actually does anything. """
178 178
179 179 # Allow the dummy parameter to override the global __dummy_mode
180 180 if dummy or (dummy != 0 and self.__dummy_mode):
181 181 return
182 182
183 183 # Set global subsystems (display,completions) to our values
184 184 sys.displayhook = self.sys_displayhook_embed
185 185 if self.IP.has_readline:
186 186 self.IP.readline.set_completer(self.IP.Completer.complete)
187 187
188 188 if self.banner and header:
189 189 format = '%s\n%s\n'
190 190 else:
191 191 format = '%s%s\n'
192 192 banner = format % (self.banner,header)
193 193
194 194 # Call the embedding code with a stack depth of 1 so it can skip over
195 195 # our call and get the original caller's namespaces.
196 196 self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1)
197 197
198 198 if self.exit_msg:
199 199 print self.exit_msg
200 200
201 201 # Restore global systems (display, completion)
202 202 sys.displayhook = self.sys_displayhook_ori
203 203 self.restore_system_completer()
204 204
205 205 def set_dummy_mode(self,dummy):
206 206 """Sets the embeddable shell's dummy mode parameter.
207 207
208 208 set_dummy_mode(dummy): dummy = 0 or 1.
209 209
210 210 This parameter is persistent and makes calls to the embeddable shell
211 211 silently return without performing any action. This allows you to
212 212 globally activate or deactivate a shell you're using with a single call.
213 213
214 214 If you need to manually"""
215 215
216 216 if dummy not in [0,1,False,True]:
217 217 raise ValueError,'dummy parameter must be boolean'
218 218 self.__dummy_mode = dummy
219 219
220 220 def get_dummy_mode(self):
221 221 """Return the current value of the dummy mode parameter.
222 222 """
223 223 return self.__dummy_mode
224 224
225 225 def set_banner(self,banner):
226 226 """Sets the global banner.
227 227
228 228 This banner gets prepended to every header printed when the shell
229 229 instance is called."""
230 230
231 231 self.banner = banner
232 232
233 233 def set_exit_msg(self,exit_msg):
234 234 """Sets the global exit_msg.
235 235
236 236 This exit message gets printed upon exiting every time the embedded
237 237 shell is called. It is None by default. """
238 238
239 239 self.exit_msg = exit_msg
240 240
241 241 #-----------------------------------------------------------------------------
242 242 def sigint_handler (signum,stack_frame):
243 243 """Sigint handler for threaded apps.
244 244
245 245 This is a horrible hack to pass information about SIGINT _without_ using
246 246 exceptions, since I haven't been able to properly manage cross-thread
247 247 exceptions in GTK/WX. In fact, I don't think it can be done (or at least
248 248 that's my understanding from a c.l.py thread where this was discussed)."""
249 249
250 250 global KBINT
251 251
252 252 print '\nKeyboardInterrupt - Press <Enter> to continue.',
253 253 Term.cout.flush()
254 254 # Set global flag so that runsource can know that Ctrl-C was hit
255 255 KBINT = True
256 256
257 257 class MTInteractiveShell(InteractiveShell):
258 258 """Simple multi-threaded shell."""
259 259
260 260 # Threading strategy taken from:
261 261 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian
262 262 # McErlean and John Finlay. Modified with corrections by Antoon Pardon,
263 263 # from the pygtk mailing list, to avoid lockups with system calls.
264 264
265 265 # class attribute to indicate whether the class supports threads or not.
266 266 # Subclasses with thread support should override this as needed.
267 267 isthreaded = True
268 268
269 269 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
270 270 user_ns=None,user_global_ns=None,banner2='',**kw):
271 271 """Similar to the normal InteractiveShell, but with threading control"""
272 272
273 273 InteractiveShell.__init__(self,name,usage,rc,user_ns,
274 274 user_global_ns,banner2)
275 275
276 276 # Locking control variable. We need to use a norma lock, not an RLock
277 277 # here. I'm not exactly sure why, it seems to me like it should be
278 278 # the opposite, but we deadlock with an RLock. Puzzled...
279 279 self.thread_ready = threading.Condition(threading.Lock())
280 280
281 281 # A queue to hold the code to be executed. A scalar variable is NOT
282 282 # enough, because uses like macros cause reentrancy.
283 283 self.code_queue = Queue.Queue()
284 284
285 285 # Stuff to do at closing time
286 286 self._kill = False
287 287 on_kill = kw.get('on_kill')
288 288 if on_kill is None:
289 289 on_kill = []
290 290 # Check that all things to kill are callable:
291 291 for t in on_kill:
292 292 if not callable(t):
293 293 raise TypeError,'on_kill must be a list of callables'
294 294 self.on_kill = on_kill
295 295
296 296 def runsource(self, source, filename="<input>", symbol="single"):
297 297 """Compile and run some source in the interpreter.
298 298
299 299 Modified version of code.py's runsource(), to handle threading issues.
300 300 See the original for full docstring details."""
301 301
302 302 global KBINT
303 303
304 304 # If Ctrl-C was typed, we reset the flag and return right away
305 305 if KBINT:
306 306 KBINT = False
307 307 return False
308 308
309 309 try:
310 310 code = self.compile(source, filename, symbol)
311 311 except (OverflowError, SyntaxError, ValueError):
312 312 # Case 1
313 313 self.showsyntaxerror(filename)
314 314 return False
315 315
316 316 if code is None:
317 317 # Case 2
318 318 return True
319 319
320 320 # Case 3
321 321 # Store code in queue, so the execution thread can handle it.
322 322
323 323 # Note that with macros and other applications, we MAY re-enter this
324 324 # section, so we have to acquire the lock with non-blocking semantics,
325 325 # else we deadlock.
326 326 got_lock = self.thread_ready.acquire(False)
327 327 self.code_queue.put(code)
328 328 if got_lock:
329 329 self.thread_ready.wait() # Wait until processed in timeout interval
330 330 self.thread_ready.release()
331 331
332 332 return False
333 333
334 334 def runcode(self):
335 335 """Execute a code object.
336 336
337 337 Multithreaded wrapper around IPython's runcode()."""
338 338
339 339 # lock thread-protected stuff
340 340 self.thread_ready.acquire(False)
341 341
342 342 # Install sigint handler
343 343 try:
344 344 signal.signal(signal.SIGINT, sigint_handler)
345 345 except SystemError:
346 346 # This happens under Windows, which seems to have all sorts
347 347 # of problems with signal handling. Oh well...
348 348 pass
349 349
350 350 if self._kill:
351 351 print >>Term.cout, 'Closing threads...',
352 352 Term.cout.flush()
353 353 for tokill in self.on_kill:
354 354 tokill()
355 355 print >>Term.cout, 'Done.'
356 356
357 357 # Flush queue of pending code by calling the run methood of the parent
358 358 # class with all items which may be in the queue.
359 359 while 1:
360 360 try:
361 361 code_to_run = self.code_queue.get_nowait()
362 362 except Queue.Empty:
363 363 break
364 364 self.thread_ready.notify()
365 365 InteractiveShell.runcode(self,code_to_run)
366 366
367 367 # We're done with thread-protected variables
368 368 self.thread_ready.release()
369 369 # This MUST return true for gtk threading to work
370 370 return True
371 371
372 372 def kill (self):
373 373 """Kill the thread, returning when it has been shut down."""
374 374 self.thread_ready.acquire(False)
375 375 self._kill = True
376 376 self.thread_ready.release()
377 377
378 378 class MatplotlibShellBase:
379 379 """Mixin class to provide the necessary modifications to regular IPython
380 380 shell classes for matplotlib support.
381 381
382 382 Given Python's MRO, this should be used as the FIRST class in the
383 383 inheritance hierarchy, so that it overrides the relevant methods."""
384 384
385 385 def _matplotlib_config(self,name):
386 386 """Return items needed to setup the user's shell with matplotlib"""
387 387
388 388 # Initialize matplotlib to interactive mode always
389 389 import matplotlib
390 390 from matplotlib import backends
391 391 matplotlib.interactive(True)
392 392
393 393 def use(arg):
394 394 """IPython wrapper for matplotlib's backend switcher.
395 395
396 396 In interactive use, we can not allow switching to a different
397 397 interactive backend, since thread conflicts will most likely crash
398 398 the python interpreter. This routine does a safety check first,
399 399 and refuses to perform a dangerous switch. It still allows
400 400 switching to non-interactive backends."""
401 401
402 402 if arg in backends.interactive_bk and arg != self.mpl_backend:
403 403 m=('invalid matplotlib backend switch.\n'
404 404 'This script attempted to switch to the interactive '
405 405 'backend: `%s`\n'
406 406 'Your current choice of interactive backend is: `%s`\n\n'
407 407 'Switching interactive matplotlib backends at runtime\n'
408 408 'would crash the python interpreter, '
409 409 'and IPython has blocked it.\n\n'
410 410 'You need to either change your choice of matplotlib backend\n'
411 411 'by editing your .matplotlibrc file, or run this script as a \n'
412 412 'standalone file from the command line, not using IPython.\n' %
413 413 (arg,self.mpl_backend) )
414 414 raise RuntimeError, m
415 415 else:
416 416 self.mpl_use(arg)
417 417 self.mpl_use._called = True
418 418
419 419 self.matplotlib = matplotlib
420 420 self.mpl_backend = matplotlib.rcParams['backend']
421 421
422 422 # we also need to block switching of interactive backends by use()
423 423 self.mpl_use = matplotlib.use
424 424 self.mpl_use._called = False
425 425 # overwrite the original matplotlib.use with our wrapper
426 426 matplotlib.use = use
427 427
428 428 # This must be imported last in the matplotlib series, after
429 429 # backend/interactivity choices have been made
430 430 try:
431 431 import matplotlib.pylab as pylab
432 432 self.pylab = pylab
433 433 self.pylab_name = 'pylab'
434 434 except ImportError:
435 435 import matplotlib.matlab as matlab
436 436 self.pylab = matlab
437 437 self.pylab_name = 'matlab'
438 438
439 439 self.pylab.show._needmain = False
440 440 # We need to detect at runtime whether show() is called by the user.
441 441 # For this, we wrap it into a decorator which adds a 'called' flag.
442 442 self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive)
443 443
444 444 # Build a user namespace initialized with matplotlib/matlab features.
445 445 user_ns = {'__name__':'__main__',
446 446 '__builtins__' : __builtin__ }
447 447
448 448 # Be careful not to remove the final \n in the code string below, or
449 449 # things will break badly with py22 (I think it's a python bug, 2.3 is
450 450 # OK).
451 451 pname = self.pylab_name # Python can't interpolate dotted var names
452 452 exec ("import matplotlib\n"
453 453 "import matplotlib.%(pname)s as %(pname)s\n"
454 454 "from matplotlib.%(pname)s import *\n" % locals()) in user_ns
455 455
456 456 # Build matplotlib info banner
457 457 b="""
458 458 Welcome to pylab, a matplotlib-based Python environment.
459 459 For more information, type 'help(pylab)'.
460 460 """
461 461 return user_ns,b
462 462
463 463 def mplot_exec(self,fname,*where,**kw):
464 464 """Execute a matplotlib script.
465 465
466 466 This is a call to execfile(), but wrapped in safeties to properly
467 467 handle interactive rendering and backend switching."""
468 468
469 469 #print '*** Matplotlib runner ***' # dbg
470 470 # turn off rendering until end of script
471 471 isInteractive = self.matplotlib.rcParams['interactive']
472 472 self.matplotlib.interactive(False)
473 473 self.safe_execfile(fname,*where,**kw)
474 474 self.matplotlib.interactive(isInteractive)
475 475 # make rendering call now, if the user tried to do it
476 476 if self.pylab.draw_if_interactive.called:
477 477 self.pylab.draw()
478 478 self.pylab.draw_if_interactive.called = False
479 479
480 480 # if a backend switch was performed, reverse it now
481 481 if self.mpl_use._called:
482 482 self.matplotlib.rcParams['backend'] = self.mpl_backend
483 483
484 484 def magic_run(self,parameter_s=''):
485 485 Magic.magic_run(self,parameter_s,runner=self.mplot_exec)
486 486
487 487 # Fix the docstring so users see the original as well
488 488 magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__,
489 489 "\n *** Modified %run for Matplotlib,"
490 490 " with proper interactive handling ***")
491 491
492 492 # Now we provide 2 versions of a matplotlib-aware IPython base shells, single
493 493 # and multithreaded. Note that these are meant for internal use, the IPShell*
494 494 # classes below are the ones meant for public consumption.
495 495
496 496 class MatplotlibShell(MatplotlibShellBase,InteractiveShell):
497 497 """Single-threaded shell with matplotlib support."""
498 498
499 499 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
500 500 user_ns=None,user_global_ns=None,**kw):
501 501 user_ns,b2 = self._matplotlib_config(name)
502 502 InteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns,
503 503 banner2=b2,**kw)
504 504
505 505 class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell):
506 506 """Multi-threaded shell with matplotlib support."""
507 507
508 508 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
509 509 user_ns=None,user_global_ns=None, **kw):
510 510 user_ns,b2 = self._matplotlib_config(name)
511 511 MTInteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns,
512 512 banner2=b2,**kw)
513 513
514 514 #-----------------------------------------------------------------------------
515 515 # Utility functions for the different GUI enabled IPShell* classes.
516 516
517 517 def get_tk():
518 518 """Tries to import Tkinter and returns a withdrawn Tkinter root
519 519 window. If Tkinter is already imported or not available, this
520 520 returns None. This function calls `hijack_tk` underneath.
521 521 """
522 522 if not USE_TK or sys.modules.has_key('Tkinter'):
523 523 return None
524 524 else:
525 525 try:
526 526 import Tkinter
527 527 except ImportError:
528 528 return None
529 529 else:
530 530 hijack_tk()
531 531 r = Tkinter.Tk()
532 532 r.withdraw()
533 533 return r
534 534
535 535 def hijack_tk():
536 536 """Modifies Tkinter's mainloop with a dummy so when a module calls
537 537 mainloop, it does not block.
538 538
539 539 """
540 540 def misc_mainloop(self, n=0):
541 541 pass
542 542 def tkinter_mainloop(n=0):
543 543 pass
544 544
545 545 import Tkinter
546 546 Tkinter.Misc.mainloop = misc_mainloop
547 547 Tkinter.mainloop = tkinter_mainloop
548 548
549 549 def update_tk(tk):
550 550 """Updates the Tkinter event loop. This is typically called from
551 551 the respective WX or GTK mainloops.
552 552 """
553 553 if tk:
554 554 tk.update()
555 555
556 556 def hijack_wx():
557 557 """Modifies wxPython's MainLoop with a dummy so user code does not
558 558 block IPython. The hijacked mainloop function is returned.
559 559 """
560 560 def dummy_mainloop(*args, **kw):
561 561 pass
562 562 import wxPython
563 563 ver = wxPython.__version__
564 564 orig_mainloop = None
565 565 if ver[:3] >= '2.5':
566 566 import wx
567 567 if hasattr(wx, '_core_'): core = getattr(wx, '_core_')
568 568 elif hasattr(wx, '_core'): core = getattr(wx, '_core')
569 569 else: raise AttributeError('Could not find wx core module')
570 570 orig_mainloop = core.PyApp_MainLoop
571 571 core.PyApp_MainLoop = dummy_mainloop
572 572 elif ver[:3] == '2.4':
573 573 orig_mainloop = wxPython.wxc.wxPyApp_MainLoop
574 574 wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop
575 575 else:
576 576 warn("Unable to find either wxPython version 2.4 or >= 2.5.")
577 577 return orig_mainloop
578 578
579 579 def hijack_gtk():
580 580 """Modifies pyGTK's mainloop with a dummy so user code does not
581 581 block IPython. This function returns the original `gtk.mainloop`
582 582 function that has been hijacked.
583 583 """
584 584 def dummy_mainloop(*args, **kw):
585 585 pass
586 586 import gtk
587 587 if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main
588 588 else: orig_mainloop = gtk.mainloop
589 589 gtk.mainloop = dummy_mainloop
590 590 gtk.main = dummy_mainloop
591 591 return orig_mainloop
592 592
593 593 #-----------------------------------------------------------------------------
594 594 # The IPShell* classes below are the ones meant to be run by external code as
595 595 # IPython instances. Note that unless a specific threading strategy is
596 596 # desired, the factory function start() below should be used instead (it
597 597 # selects the proper threaded class).
598 598
599 599 class IPShellGTK(threading.Thread):
600 600 """Run a gtk mainloop() in a separate thread.
601 601
602 602 Python commands can be passed to the thread where they will be executed.
603 603 This is implemented by periodically checking for passed code using a
604 604 GTK timeout callback."""
605 605
606 606 TIMEOUT = 100 # Millisecond interval between timeouts.
607 607
608 608 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
609 609 debug=1,shell_class=MTInteractiveShell):
610 610
611 611 import gtk
612 612
613 613 self.gtk = gtk
614 614 self.gtk_mainloop = hijack_gtk()
615 615
616 616 # Allows us to use both Tk and GTK.
617 617 self.tk = get_tk()
618 618
619 619 if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit
620 620 else: mainquit = self.gtk.mainquit
621 621
622 622 self.IP = make_IPython(argv,user_ns=user_ns,
623 623 user_global_ns=user_global_ns,
624 624 debug=debug,
625 625 shell_class=shell_class,
626 626 on_kill=[mainquit])
627 627
628 628 # HACK: slot for banner in self; it will be passed to the mainloop
629 629 # method only and .run() needs it. The actual value will be set by
630 630 # .mainloop().
631 631 self._banner = None
632 632
633 633 threading.Thread.__init__(self)
634 634
635 635 def run(self):
636 636 self.IP.mainloop(self._banner)
637 637 self.IP.kill()
638 638
639 639 def mainloop(self,sys_exit=0,banner=None):
640 640
641 641 self._banner = banner
642 642
643 643 if self.gtk.pygtk_version >= (2,4,0):
644 644 import gobject
645 645 gobject.idle_add(self.on_timer)
646 646 else:
647 647 self.gtk.idle_add(self.on_timer)
648 648
649 649 if sys.platform != 'win32':
650 650 try:
651 651 if self.gtk.gtk_version[0] >= 2:
652 652 self.gtk.threads_init()
653 653 except AttributeError:
654 654 pass
655 655 except RuntimeError:
656 656 error('Your pyGTK likely has not been compiled with '
657 657 'threading support.\n'
658 658 'The exception printout is below.\n'
659 659 'You can either rebuild pyGTK with threads, or '
660 660 'try using \n'
661 661 'matplotlib with a different backend (like Tk or WX).\n'
662 662 'Note that matplotlib will most likely not work in its '
663 663 'current state!')
664 664 self.IP.InteractiveTB()
665 665 self.start()
666 666 self.gtk.threads_enter()
667 667 self.gtk_mainloop()
668 668 self.gtk.threads_leave()
669 669 self.join()
670 670
671 671 def on_timer(self):
672 672 """Called when GTK is idle.
673 673
674 674 Must return True always, otherwise GTK stops calling it"""
675 675
676 676 update_tk(self.tk)
677 677 self.IP.runcode()
678 678 time.sleep(0.01)
679 679 return True
680 680
681 681 class IPShellWX(threading.Thread):
682 682 """Run a wx mainloop() in a separate thread.
683 683
684 684 Python commands can be passed to the thread where they will be executed.
685 685 This is implemented by periodically checking for passed code using a
686 686 GTK timeout callback."""
687 687
688 688 TIMEOUT = 100 # Millisecond interval between timeouts.
689 689
690 690 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
691 691 debug=1,shell_class=MTInteractiveShell):
692 692
693 693 self.IP = make_IPython(argv,user_ns=user_ns,
694 694 user_global_ns=user_global_ns,
695 695 debug=debug,
696 696 shell_class=shell_class,
697 697 on_kill=[self.wxexit])
698 698
699 699 wantedwxversion=self.IP.rc.wxversion
700 700 if wantedwxversion!="0":
701 701 try:
702 702 import wxversion
703 703 except ImportError:
704 704 error('The wxversion module is needed for WX version selection')
705 705 else:
706 706 try:
707 707 wxversion.select(wantedwxversion)
708 708 except:
709 709 self.IP.InteractiveTB()
710 710 error('Requested wxPython version %s could not be loaded' %
711 711 wantedwxversion)
712 712
713 713 import wxPython.wx as wx
714 714
715 715 threading.Thread.__init__(self)
716 716 self.wx = wx
717 717 self.wx_mainloop = hijack_wx()
718 718
719 719 # Allows us to use both Tk and GTK.
720 720 self.tk = get_tk()
721 721
722 722
723 723 # HACK: slot for banner in self; it will be passed to the mainloop
724 724 # method only and .run() needs it. The actual value will be set by
725 725 # .mainloop().
726 726 self._banner = None
727 727
728 728 self.app = None
729 729
730 730 def wxexit(self, *args):
731 731 if self.app is not None:
732 732 self.app.agent.timer.Stop()
733 733 self.app.ExitMainLoop()
734 734
735 735 def run(self):
736 736 self.IP.mainloop(self._banner)
737 737 self.IP.kill()
738 738
739 739 def mainloop(self,sys_exit=0,banner=None):
740 740
741 741 self._banner = banner
742 742
743 743 self.start()
744 744
745 745 class TimerAgent(self.wx.wxMiniFrame):
746 746 wx = self.wx
747 747 IP = self.IP
748 748 tk = self.tk
749 749 def __init__(self, parent, interval):
750 750 style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ
751 751 self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200),
752 752 size=(100, 100),style=style)
753 753 self.Show(False)
754 754 self.interval = interval
755 755 self.timerId = self.wx.wxNewId()
756 756
757 757 def StartWork(self):
758 758 self.timer = self.wx.wxTimer(self, self.timerId)
759 759 self.wx.EVT_TIMER(self, self.timerId, self.OnTimer)
760 760 self.timer.Start(self.interval)
761 761
762 762 def OnTimer(self, event):
763 763 update_tk(self.tk)
764 764 self.IP.runcode()
765 765
766 766 class App(self.wx.wxApp):
767 767 wx = self.wx
768 768 TIMEOUT = self.TIMEOUT
769 769 def OnInit(self):
770 770 'Create the main window and insert the custom frame'
771 771 self.agent = TimerAgent(None, self.TIMEOUT)
772 772 self.agent.Show(self.wx.false)
773 773 self.agent.StartWork()
774 774 return self.wx.true
775 775
776 776 self.app = App(redirect=False)
777 777 self.wx_mainloop(self.app)
778 778 self.join()
779 779
780 780
781 781 class IPShellQt(threading.Thread):
782 782 """Run a Qt event loop in a separate thread.
783 783
784 784 Python commands can be passed to the thread where they will be executed.
785 785 This is implemented by periodically checking for passed code using a
786 786 Qt timer / slot."""
787 787
788 788 TIMEOUT = 100 # Millisecond interval between timeouts.
789 789
790 790 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
791 791 debug=0,shell_class=MTInteractiveShell):
792 792
793 793 import qt
794 794
795 795 class newQApplication:
796 796 def __init__( self ):
797 797 self.QApplication = qt.QApplication
798 798
799 799 def __call__( *args, **kwargs ):
800 800 return qt.qApp
801 801
802 802 def exec_loop( *args, **kwargs ):
803 803 pass
804 804
805 805 def __getattr__( self, name ):
806 806 return getattr( self.QApplication, name )
807 807
808 808 qt.QApplication = newQApplication()
809 809
810 810 # Allows us to use both Tk and QT.
811 811 self.tk = get_tk()
812 812
813 813 self.IP = make_IPython(argv,user_ns=user_ns,
814 814 user_global_ns=user_global_ns,
815 815 debug=debug,
816 816 shell_class=shell_class,
817 817 on_kill=[qt.qApp.exit])
818 818
819 819 # HACK: slot for banner in self; it will be passed to the mainloop
820 820 # method only and .run() needs it. The actual value will be set by
821 821 # .mainloop().
822 822 self._banner = None
823 823
824 824 threading.Thread.__init__(self)
825 825
826 826 def run(self):
827 827 self.IP.mainloop(self._banner)
828 828 self.IP.kill()
829 829
830 830 def mainloop(self,sys_exit=0,banner=None):
831 831
832 832 import qt
833 833
834 834 self._banner = banner
835 835
836 836 if qt.QApplication.startingUp():
837 837 a = qt.QApplication.QApplication(sys.argv)
838 838 self.timer = qt.QTimer()
839 839 qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer )
840 840
841 841 self.start()
842 842 self.timer.start( self.TIMEOUT, True )
843 843 while True:
844 844 if self.IP._kill: break
845 845 qt.qApp.exec_loop()
846 846 self.join()
847 847
848 848 def on_timer(self):
849 849 update_tk(self.tk)
850 850 result = self.IP.runcode()
851 851 self.timer.start( self.TIMEOUT, True )
852 852 return result
853 853
854 854 # A set of matplotlib public IPython shell classes, for single-threaded
855 855 # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use.
856 856 class IPShellMatplotlib(IPShell):
857 857 """Subclass IPShell with MatplotlibShell as the internal shell.
858 858
859 859 Single-threaded class, meant for the Tk* and FLTK* backends.
860 860
861 861 Having this on a separate class simplifies the external driver code."""
862 862
863 863 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
864 864 IPShell.__init__(self,argv,user_ns,user_global_ns,debug,
865 865 shell_class=MatplotlibShell)
866 866
867 867 class IPShellMatplotlibGTK(IPShellGTK):
868 868 """Subclass IPShellGTK with MatplotlibMTShell as the internal shell.
869 869
870 870 Multi-threaded class, meant for the GTK* backends."""
871 871
872 872 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
873 873 IPShellGTK.__init__(self,argv,user_ns,user_global_ns,debug,
874 874 shell_class=MatplotlibMTShell)
875 875
876 876 class IPShellMatplotlibWX(IPShellWX):
877 877 """Subclass IPShellWX with MatplotlibMTShell as the internal shell.
878 878
879 879 Multi-threaded class, meant for the WX* backends."""
880 880
881 881 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
882 882 IPShellWX.__init__(self,argv,user_ns,user_global_ns,debug,
883 883 shell_class=MatplotlibMTShell)
884 884
885 885 class IPShellMatplotlibQt(IPShellQt):
886 886 """Subclass IPShellQt with MatplotlibMTShell as the internal shell.
887 887
888 888 Multi-threaded class, meant for the Qt* backends."""
889 889
890 890 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
891 891 IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug,
892 892 shell_class=MatplotlibMTShell)
893 893
894 894 #-----------------------------------------------------------------------------
895 895 # Factory functions to actually start the proper thread-aware shell
896 896
897 897 def _matplotlib_shell_class():
898 898 """Factory function to handle shell class selection for matplotlib.
899 899
900 900 The proper shell class to use depends on the matplotlib backend, since
901 901 each backend requires a different threading strategy."""
902 902
903 903 try:
904 904 import matplotlib
905 905 except ImportError:
906 906 error('matplotlib could NOT be imported! Starting normal IPython.')
907 907 sh_class = IPShell
908 908 else:
909 909 backend = matplotlib.rcParams['backend']
910 910 if backend.startswith('GTK'):
911 911 sh_class = IPShellMatplotlibGTK
912 912 elif backend.startswith('WX'):
913 913 sh_class = IPShellMatplotlibWX
914 914 elif backend.startswith('Qt'):
915 915 sh_class = IPShellMatplotlibQt
916 916 else:
917 917 sh_class = IPShellMatplotlib
918 918 #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg
919 919 return sh_class
920 920
921 921 # This is the one which should be called by external code.
922 def start():
922 def start(user_ns = None):
923 923 """Return a running shell instance, dealing with threading options.
924 924
925 925 This is a factory function which will instantiate the proper IPython shell
926 926 based on the user's threading choice. Such a selector is needed because
927 927 different GUI toolkits require different thread handling details."""
928 928
929 929 global USE_TK
930 930 # Crude sys.argv hack to extract the threading options.
931 931 argv = sys.argv
932 932 if len(argv) > 1:
933 933 if len(argv) > 2:
934 934 arg2 = argv[2]
935 935 if arg2.endswith('-tk'):
936 936 USE_TK = True
937 937 arg1 = argv[1]
938 938 if arg1.endswith('-gthread'):
939 939 shell = IPShellGTK
940 940 elif arg1.endswith( '-qthread' ):
941 941 shell = IPShellQt
942 942 elif arg1.endswith('-wthread'):
943 943 shell = IPShellWX
944 944 elif arg1.endswith('-pylab'):
945 945 shell = _matplotlib_shell_class()
946 946 else:
947 947 shell = IPShell
948 948 else:
949 949 shell = IPShell
950 return shell()
950 return shell(user_ns = user_ns)
951 951
952 952 # Some aliases for backwards compatibility
953 953 IPythonShell = IPShell
954 954 IPythonShellEmbed = IPShellEmbed
955 955 #************************ End of file <Shell.py> ***************************
@@ -1,50 +1,50 b''
1 1 """ User configuration file for IPython
2 2
3 3 This is a more flexible and safe way to configure ipython than *rc files
4 4 (ipythonrc, ipythonrc-pysh etc.)
5 5
6 6 This file is always imported on ipython startup. You should import all the
7 7 ipython extensions you need here (see IPython/Extensions directory).
8 8
9 9 Feel free to edit this file to customize your ipython experience. If
10 10 you wish to only use the old config system, it's perfectly ok to make this file
11 11 empty.
12 12
13 13 """
14 14
15 15 # Most of your config files and extensions will probably start with this import
16 16
17 import IPython.ipapi as ip
18
17 from IPython import ipapi
18 ip = ipapi.get()
19 19 import os
20 20
21 21 o = ip.options()
22 22 # autocall 1 ('smart') is default anyway, this is just an
23 23 # example on how to set an option
24 24 o.autocall = 1
25 25
26 26 if o.profile == 'pysh':
27 27 # Jason Orendorff's path class is handy to have in user namespace
28 28 # if you are doing shell-like stuff
29 29 ip.ex("from IPython.path import path" )
30 30
31 31 # Uncomment these lines to get pysh-like prompt for all profiles.
32 32
33 33 #o.prompt_in1= '\C_LightBlue[\C_LightCyan\Y1\C_LightBlue]\C_Green|\#> '
34 34 #o.prompt_in2= '\C_Green|\C_LightGreen\D\C_Green> '
35 35 #o.prompt_out= '<\#> '
36 36
37 37 # make 'd' an alias for ls -F
38 38
39 39 ip.magic('alias d ls -F --color=auto')
40 40
41 41 # Make available all system commands through "rehashing" immediately.
42 42 # You can comment these lines out to speed up startup on very slow
43 43 # machines, and to conserve a bit of memory. Note that pysh profile does this
44 44 # automatically
45 45
46 46 #if os.name=='posix':
47 47 # ip.magic('rehash')
48 48 #else:
49 49 # #slightly slower, but better results esp. with Windows
50 50 # ip.magic('rehashx')
@@ -1,174 +1,168 b''
1 1 ''' IPython customization API
2 2
3 3 Your one-stop module for configuring & extending ipython
4 4
5 5 The API will probably break when ipython 1.0 is released, but so
6 6 will the other configuration method (rc files).
7 7
8 8 All names prefixed by underscores are for internal use, not part
9 9 of the public api.
10 10
11 11 Below is an example that you can just put to a module and import from ipython.
12 12
13 13 A good practice is to install the config script below as e.g.
14 14
15 15 ~/.ipython/my_private_conf.py
16 16
17 17 And do
18 18
19 19 import_mod my_private_conf
20 20
21 21 in ~/.ipython/ipythonrc
22 22
23 23 That way the module is imported at startup and you can have all your
24 24 personal configuration (as opposed to boilerplate ipythonrc-PROFILENAME
25 25 stuff) in there.
26 26
27 27 -----------------------------------------------
28 28 import IPython.ipapi as ip
29 29
30 30 def ankka_f(self, arg):
31 31 print "Ankka",self,"says uppercase:",arg.upper()
32 32
33 33 ip.expose_magic("ankka",ankka_f)
34 34
35 35 ip.magic('alias sayhi echo "Testing, hi ok"')
36 36 ip.magic('alias helloworld echo "Hello world"')
37 37 ip.system('pwd')
38 38
39 39 ip.ex('import re')
40 40 ip.ex("""
41 41 def funcci(a,b):
42 42 print a+b
43 43 print funcci(3,4)
44 44 """)
45 45 ip.ex("funcci(348,9)")
46 46
47 47 def jed_editor(self,filename, linenum=None):
48 48 print "Calling my own editor, jed ... via hook!"
49 49 import os
50 50 if linenum is None: linenum = 0
51 51 os.system('jed +%d %s' % (linenum, filename))
52 52 print "exiting jed"
53 53
54 54 ip.set_hook('editor',jed_editor)
55 55
56 56 o = ip.options()
57 57 o.autocall = 2 # FULL autocall mode
58 58
59 59 print "done!"
60 60
61 61 '''
62 62
63 63
64 64 class TryNext(Exception):
65 65 """ Try next hook exception.
66 66
67 67 Raise this in your hook function to indicate that the next
68 68 hook handler should be used to handle the operation.
69 69 """
70 70
71 71
72 # contains the most recently instantiated IPApi
73 _recent = None
72 74
73 __IP = None
75 def get():
76 """ Get an IPApi object, or None if not running under ipython
74 77
75 def _init_with_shell(ip):
76 global magic
77 magic = ip.ipmagic
78 global system
79 system = ip.ipsystem
80 global set_hook
81 set_hook = ip.set_hook
78 Running this should be the first thing you do when writing
79 extensions that can be imported as normal modules. You can then
80 direct all the configuration operations against the returned
81 object.
82 82
83 global __IP
84 __IP = ip
83 """
85 84
86 def options():
87 """ All configurable variables """
88 return __IP.rc
85 return _recent
89 86
90 def user_ns():
91 return __IP.user_ns
92 87
93 def expose_magic(magicname, func):
94 ''' Expose own function as magic function for ipython
95 88
96 def foo_impl(self,parameter_s=''):
97 """My very own magic!. (Use docstrings, IPython reads them)."""
98 print 'Magic function. Passed parameter is between < >: <'+parameter_s+'>'
99 print 'The self object is:',self
89 class IPApi:
90 """ The actual API class for configuring IPython
100 91
101 ipapi.expose_magic("foo",foo_impl)
102 '''
92 You should do all of the IPython configuration by getting
93 an IPApi object with IPython.ipapi.get() and using the provided
94 methods.
103 95
104 from IPython import Magic
105 import new
106 im = new.instancemethod(func,__IP, __IP.__class__)
107 setattr(__IP, "magic_" + magicname, im)
96 """
97 def __init__(self,ip):
108 98
109 class asmagic:
110 """ Decorator for exposing magics in a friendly 2.4 decorator form
99 self.magic = ip.ipmagic
111 100
112 @ip.asmagic("foo")
113 def f(self,arg):
114 pring "arg given:",arg
101 self.system = ip.ipsystem
115 102
116 After this, %foo is a magic function.
117 """
103 self.set_hook = ip.set_hook
118 104
119 def __init__(self,magicname):
120 self.name = magicname
105 self.IP = ip
106 global _recent
107 _recent = self
121 108
122 def __call__(self,f):
123 expose_magic(self.name, f)
124 return f
125 109
126 class ashook:
127 """ Decorator for exposing magics in a friendly 2.4 decorator form
128 110
129 @ip.ashook("editor")
130 def jed_editor(self,filename, linenum=None):
131 import os
132 if linenum is None: linenum = 0
133 os.system('jed +%d %s' % (linenum, filename))
111 def options(self):
112 """ All configurable variables """
113 return self.IP.rc
134 114
135 """
115 def user_ns(self):
116 return self.IP.user_ns
136 117
137 def __init__(self,name,priority=50):
138 self.name = name
139 self.prio = priority
118 def expose_magic(self,magicname, func):
119 ''' Expose own function as magic function for ipython
140 120
141 def __call__(self,f):
142 set_hook(self.name, f, self.prio)
143 return f
121 def foo_impl(self,parameter_s=''):
122 """My very own magic!. (Use docstrings, IPython reads them)."""
123 print 'Magic function. Passed parameter is between < >: <'+parameter_s+'>'
124 print 'The self object is:',self
144 125
126 ipapi.expose_magic("foo",foo_impl)
127 '''
145 128
146 def ex(cmd):
129 import new
130 im = new.instancemethod(func,self.IP, self.IP.__class__)
131 setattr(self.IP, "magic_" + magicname, im)
132
133
134 def ex(self,cmd):
147 135 """ Execute a normal python statement in user namespace """
148 exec cmd in user_ns()
136 exec cmd in self.user_ns()
149 137
150 def ev(expr):
138 def ev(self,expr):
151 139 """ Evaluate python expression expr in user namespace
152 140
153 Returns the result """
154 return eval(expr,user_ns())
141 Returns the result of evaluation"""
142 return eval(expr,self.user_ns())
155 143
156 def launch_new_instance():
144 def launch_new_instance(user_ns = None):
157 145 """ Create and start a new ipython instance.
158 146
159 147 This can be called even without having an already initialized
160 148 ipython session running.
161 149
150 This is also used as the egg entry point for the 'ipython' script.
151
162 152 """
163 import IPython
153 ses = create_session(user_ns)
154 ses.mainloop()
164 155
165 IPython.Shell.start().mainloop()
166 156
167 def is_ipython_session():
168 """ Return a true value if running inside IPython.
157 def create_session(user_ns = None):
158 """ Creates, but does not launch an IPython session.
169 159
170 """
160 Later on you can call obj.mainloop() on the returned object.
161
162 This should *not* be run when a session exists already.
171 163
172 # Yes, this is the shell object or None - however, it's an implementation
173 # detail and should not be relied on, only truth value matters.
174 return __IP
164 """
165 if user_ns is not None:
166 user_ns["__name__"] = user_ns.get("__name__",'ipy_session')
167 import IPython
168 return IPython.Shell.start(user_ns = user_ns) No newline at end of file
@@ -1,2234 +1,2235 b''
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 IPython -- An enhanced Interactive Python
4 4
5 5 Requires Python 2.3 or newer.
6 6
7 7 This file contains all the classes and helper functions specific to IPython.
8 8
9 $Id: iplib.py 1077 2006-01-24 18:15:27Z vivainio $
9 $Id: iplib.py 1079 2006-01-24 21:52:31Z vivainio $
10 10 """
11 11
12 12 #*****************************************************************************
13 13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
15 15 #
16 16 # Distributed under the terms of the BSD License. The full license is in
17 17 # the file COPYING, distributed as part of this software.
18 18 #
19 19 # Note: this code originally subclassed code.InteractiveConsole from the
20 20 # Python standard library. Over time, all of that class has been copied
21 21 # verbatim here for modifications which could not be accomplished by
22 22 # subclassing. At this point, there are no dependencies at all on the code
23 23 # module anymore (it is not even imported). The Python License (sec. 2)
24 24 # allows for this, but it's always nice to acknowledge credit where credit is
25 25 # due.
26 26 #*****************************************************************************
27 27
28 28 #****************************************************************************
29 29 # Modules and globals
30 30
31 31 from __future__ import generators # for 2.2 backwards-compatibility
32 32
33 33 from IPython import Release
34 34 __author__ = '%s <%s>\n%s <%s>' % \
35 35 ( Release.authors['Janko'] + Release.authors['Fernando'] )
36 36 __license__ = Release.license
37 37 __version__ = Release.version
38 38
39 39 # Python standard modules
40 40 import __main__
41 41 import __builtin__
42 42 import StringIO
43 43 import bdb
44 44 import cPickle as pickle
45 45 import codeop
46 46 import exceptions
47 47 import glob
48 48 import inspect
49 49 import keyword
50 50 import new
51 51 import os
52 52 import pdb
53 53 import pydoc
54 54 import re
55 55 import shutil
56 56 import string
57 57 import sys
58 58 import tempfile
59 59 import traceback
60 60 import types
61 61
62 62 from pprint import pprint, pformat
63 63
64 64 # IPython's own modules
65 65 import IPython
66 66 from IPython import OInspect,PyColorize,ultraTB
67 67 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
68 68 from IPython.FakeModule import FakeModule
69 69 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
70 70 from IPython.Logger import Logger
71 71 from IPython.Magic import Magic
72 72 from IPython.Prompts import CachedOutput
73 73 from IPython.ipstruct import Struct
74 74 from IPython.background_jobs import BackgroundJobManager
75 75 from IPython.usage import cmd_line_usage,interactive_usage
76 76 from IPython.genutils import *
77 77 import IPython.ipapi
78 78
79 79 # Globals
80 80
81 81 # store the builtin raw_input globally, and use this always, in case user code
82 82 # overwrites it (like wx.py.PyShell does)
83 83 raw_input_original = raw_input
84 84
85 85 # compiled regexps for autoindent management
86 86 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
87 87
88 88
89 89 #****************************************************************************
90 90 # Some utility function definitions
91 91
92 92 ini_spaces_re = re.compile(r'^(\s+)')
93 93
94 94 def num_ini_spaces(strng):
95 95 """Return the number of initial spaces in a string"""
96 96
97 97 ini_spaces = ini_spaces_re.match(strng)
98 98 if ini_spaces:
99 99 return ini_spaces.end()
100 100 else:
101 101 return 0
102 102
103 103 def softspace(file, newvalue):
104 104 """Copied from code.py, to remove the dependency"""
105 105
106 106 oldvalue = 0
107 107 try:
108 108 oldvalue = file.softspace
109 109 except AttributeError:
110 110 pass
111 111 try:
112 112 file.softspace = newvalue
113 113 except (AttributeError, TypeError):
114 114 # "attribute-less object" or "read-only attributes"
115 115 pass
116 116 return oldvalue
117 117
118 118
119 119 #****************************************************************************
120 120 # Local use exceptions
121 121 class SpaceInInput(exceptions.Exception): pass
122 122
123 123
124 124 #****************************************************************************
125 125 # Local use classes
126 126 class Bunch: pass
127 127
128 128 class Undefined: pass
129 129
130 130 class InputList(list):
131 131 """Class to store user input.
132 132
133 133 It's basically a list, but slices return a string instead of a list, thus
134 134 allowing things like (assuming 'In' is an instance):
135 135
136 136 exec In[4:7]
137 137
138 138 or
139 139
140 140 exec In[5:9] + In[14] + In[21:25]"""
141 141
142 142 def __getslice__(self,i,j):
143 143 return ''.join(list.__getslice__(self,i,j))
144 144
145 145 class SyntaxTB(ultraTB.ListTB):
146 146 """Extension which holds some state: the last exception value"""
147 147
148 148 def __init__(self,color_scheme = 'NoColor'):
149 149 ultraTB.ListTB.__init__(self,color_scheme)
150 150 self.last_syntax_error = None
151 151
152 152 def __call__(self, etype, value, elist):
153 153 self.last_syntax_error = value
154 154 ultraTB.ListTB.__call__(self,etype,value,elist)
155 155
156 156 def clear_err_state(self):
157 157 """Return the current error state and clear it"""
158 158 e = self.last_syntax_error
159 159 self.last_syntax_error = None
160 160 return e
161 161
162 162 #****************************************************************************
163 163 # Main IPython class
164 164
165 165 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
166 166 # until a full rewrite is made. I've cleaned all cross-class uses of
167 167 # attributes and methods, but too much user code out there relies on the
168 168 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
169 169 #
170 170 # But at least now, all the pieces have been separated and we could, in
171 171 # principle, stop using the mixin. This will ease the transition to the
172 172 # chainsaw branch.
173 173
174 174 # For reference, the following is the list of 'self.foo' uses in the Magic
175 175 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
176 176 # class, to prevent clashes.
177 177
178 178 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
179 179 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
180 180 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
181 181 # 'self.value']
182 182
183 183 class InteractiveShell(object,Magic):
184 184 """An enhanced console for Python."""
185 185
186 186 # class attribute to indicate whether the class supports threads or not.
187 187 # Subclasses with thread support should override this as needed.
188 188 isthreaded = False
189 189
190 190 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
191 191 user_ns = None,user_global_ns=None,banner2='',
192 192 custom_exceptions=((),None),embedded=False):
193 193
194 194 # log system
195 195 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
196 196
197 # introduce ourselves to IPython.ipapi which is uncallable
198 # before it knows an InteractiveShell object.
199 IPython.ipapi._init_with_shell(self)
197 # Produce a public API instance
198
199 self.api = IPython.ipapi.IPApi(self)
200
200 201
201 202 # some minimal strict typechecks. For some core data structures, I
202 203 # want actual basic python types, not just anything that looks like
203 204 # one. This is especially true for namespaces.
204 205 for ns in (user_ns,user_global_ns):
205 206 if ns is not None and type(ns) != types.DictType:
206 207 raise TypeError,'namespace must be a dictionary'
207 208
208 209 # Job manager (for jobs run as background threads)
209 210 self.jobs = BackgroundJobManager()
210 211
211 212 # track which builtins we add, so we can clean up later
212 213 self.builtins_added = {}
213 214 # This method will add the necessary builtins for operation, but
214 215 # tracking what it did via the builtins_added dict.
215 216 self.add_builtins()
216 217
217 218 # Do the intuitively correct thing for quit/exit: we remove the
218 219 # builtins if they exist, and our own magics will deal with this
219 220 try:
220 221 del __builtin__.exit, __builtin__.quit
221 222 except AttributeError:
222 223 pass
223 224
224 225 # Store the actual shell's name
225 226 self.name = name
226 227
227 228 # We need to know whether the instance is meant for embedding, since
228 229 # global/local namespaces need to be handled differently in that case
229 230 self.embedded = embedded
230 231
231 232 # command compiler
232 233 self.compile = codeop.CommandCompiler()
233 234
234 235 # User input buffer
235 236 self.buffer = []
236 237
237 238 # Default name given in compilation of code
238 239 self.filename = '<ipython console>'
239 240
240 241 # Make an empty namespace, which extension writers can rely on both
241 242 # existing and NEVER being used by ipython itself. This gives them a
242 243 # convenient location for storing additional information and state
243 244 # their extensions may require, without fear of collisions with other
244 245 # ipython names that may develop later.
245 246 self.meta = Bunch()
246 247
247 248 # Create the namespace where the user will operate. user_ns is
248 249 # normally the only one used, and it is passed to the exec calls as
249 250 # the locals argument. But we do carry a user_global_ns namespace
250 251 # given as the exec 'globals' argument, This is useful in embedding
251 252 # situations where the ipython shell opens in a context where the
252 253 # distinction between locals and globals is meaningful.
253 254
254 255 # FIXME. For some strange reason, __builtins__ is showing up at user
255 256 # level as a dict instead of a module. This is a manual fix, but I
256 257 # should really track down where the problem is coming from. Alex
257 258 # Schmolck reported this problem first.
258 259
259 260 # A useful post by Alex Martelli on this topic:
260 261 # Re: inconsistent value from __builtins__
261 262 # Von: Alex Martelli <aleaxit@yahoo.com>
262 263 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
263 264 # Gruppen: comp.lang.python
264 265
265 266 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
266 267 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
267 268 # > <type 'dict'>
268 269 # > >>> print type(__builtins__)
269 270 # > <type 'module'>
270 271 # > Is this difference in return value intentional?
271 272
272 273 # Well, it's documented that '__builtins__' can be either a dictionary
273 274 # or a module, and it's been that way for a long time. Whether it's
274 275 # intentional (or sensible), I don't know. In any case, the idea is
275 276 # that if you need to access the built-in namespace directly, you
276 277 # should start with "import __builtin__" (note, no 's') which will
277 278 # definitely give you a module. Yeah, it's somewhat confusing:-(.
278 279
279 280 if user_ns is None:
280 281 # Set __name__ to __main__ to better match the behavior of the
281 282 # normal interpreter.
282 283 user_ns = {'__name__' :'__main__',
283 284 '__builtins__' : __builtin__,
284 285 }
285 286
286 287 if user_global_ns is None:
287 288 user_global_ns = {}
288 289
289 290 # Assign namespaces
290 291 # This is the namespace where all normal user variables live
291 292 self.user_ns = user_ns
292 293 # Embedded instances require a separate namespace for globals.
293 294 # Normally this one is unused by non-embedded instances.
294 295 self.user_global_ns = user_global_ns
295 296 # A namespace to keep track of internal data structures to prevent
296 297 # them from cluttering user-visible stuff. Will be updated later
297 298 self.internal_ns = {}
298 299
299 300 # Namespace of system aliases. Each entry in the alias
300 301 # table must be a 2-tuple of the form (N,name), where N is the number
301 302 # of positional arguments of the alias.
302 303 self.alias_table = {}
303 304
304 305 # A table holding all the namespaces IPython deals with, so that
305 306 # introspection facilities can search easily.
306 307 self.ns_table = {'user':user_ns,
307 308 'user_global':user_global_ns,
308 309 'alias':self.alias_table,
309 310 'internal':self.internal_ns,
310 311 'builtin':__builtin__.__dict__
311 312 }
312 313
313 314 # The user namespace MUST have a pointer to the shell itself.
314 315 self.user_ns[name] = self
315 316
316 317 # We need to insert into sys.modules something that looks like a
317 318 # module but which accesses the IPython namespace, for shelve and
318 319 # pickle to work interactively. Normally they rely on getting
319 320 # everything out of __main__, but for embedding purposes each IPython
320 321 # instance has its own private namespace, so we can't go shoving
321 322 # everything into __main__.
322 323
323 324 # note, however, that we should only do this for non-embedded
324 325 # ipythons, which really mimic the __main__.__dict__ with their own
325 326 # namespace. Embedded instances, on the other hand, should not do
326 327 # this because they need to manage the user local/global namespaces
327 328 # only, but they live within a 'normal' __main__ (meaning, they
328 329 # shouldn't overtake the execution environment of the script they're
329 330 # embedded in).
330 331
331 332 if not embedded:
332 333 try:
333 334 main_name = self.user_ns['__name__']
334 335 except KeyError:
335 336 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
336 337 else:
337 338 #print "pickle hack in place" # dbg
338 339 #print 'main_name:',main_name # dbg
339 340 sys.modules[main_name] = FakeModule(self.user_ns)
340 341
341 342 # List of input with multi-line handling.
342 343 # Fill its zero entry, user counter starts at 1
343 344 self.input_hist = InputList(['\n'])
344 345 # This one will hold the 'raw' input history, without any
345 346 # pre-processing. This will allow users to retrieve the input just as
346 347 # it was exactly typed in by the user, with %hist -r.
347 348 self.input_hist_raw = InputList(['\n'])
348 349
349 350 # list of visited directories
350 351 try:
351 352 self.dir_hist = [os.getcwd()]
352 353 except IOError, e:
353 354 self.dir_hist = []
354 355
355 356 # dict of output history
356 357 self.output_hist = {}
357 358
358 359 # dict of things NOT to alias (keywords, builtins and some magics)
359 360 no_alias = {}
360 361 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
361 362 for key in keyword.kwlist + no_alias_magics:
362 363 no_alias[key] = 1
363 364 no_alias.update(__builtin__.__dict__)
364 365 self.no_alias = no_alias
365 366
366 367 # make global variables for user access to these
367 368 self.user_ns['_ih'] = self.input_hist
368 369 self.user_ns['_oh'] = self.output_hist
369 370 self.user_ns['_dh'] = self.dir_hist
370 371
371 372 # user aliases to input and output histories
372 373 self.user_ns['In'] = self.input_hist
373 374 self.user_ns['Out'] = self.output_hist
374 375
375 376 # Object variable to store code object waiting execution. This is
376 377 # used mainly by the multithreaded shells, but it can come in handy in
377 378 # other situations. No need to use a Queue here, since it's a single
378 379 # item which gets cleared once run.
379 380 self.code_to_run = None
380 381
381 382 # escapes for automatic behavior on the command line
382 383 self.ESC_SHELL = '!'
383 384 self.ESC_HELP = '?'
384 385 self.ESC_MAGIC = '%'
385 386 self.ESC_QUOTE = ','
386 387 self.ESC_QUOTE2 = ';'
387 388 self.ESC_PAREN = '/'
388 389
389 390 # And their associated handlers
390 391 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
391 392 self.ESC_QUOTE : self.handle_auto,
392 393 self.ESC_QUOTE2 : self.handle_auto,
393 394 self.ESC_MAGIC : self.handle_magic,
394 395 self.ESC_HELP : self.handle_help,
395 396 self.ESC_SHELL : self.handle_shell_escape,
396 397 }
397 398
398 399 # class initializations
399 400 Magic.__init__(self,self)
400 401
401 402 # Python source parser/formatter for syntax highlighting
402 403 pyformat = PyColorize.Parser().format
403 404 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
404 405
405 406 # hooks holds pointers used for user-side customizations
406 407 self.hooks = Struct()
407 408
408 409 # Set all default hooks, defined in the IPython.hooks module.
409 410 hooks = IPython.hooks
410 411 for hook_name in hooks.__all__:
411 412 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
412 413 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
413 414
414 415 # Flag to mark unconditional exit
415 416 self.exit_now = False
416 417
417 418 self.usage_min = """\
418 419 An enhanced console for Python.
419 420 Some of its features are:
420 421 - Readline support if the readline library is present.
421 422 - Tab completion in the local namespace.
422 423 - Logging of input, see command-line options.
423 424 - System shell escape via ! , eg !ls.
424 425 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
425 426 - Keeps track of locally defined variables via %who, %whos.
426 427 - Show object information with a ? eg ?x or x? (use ?? for more info).
427 428 """
428 429 if usage: self.usage = usage
429 430 else: self.usage = self.usage_min
430 431
431 432 # Storage
432 433 self.rc = rc # This will hold all configuration information
433 434 self.pager = 'less'
434 435 # temporary files used for various purposes. Deleted at exit.
435 436 self.tempfiles = []
436 437
437 438 # Keep track of readline usage (later set by init_readline)
438 439 self.has_readline = False
439 440
440 441 # template for logfile headers. It gets resolved at runtime by the
441 442 # logstart method.
442 443 self.loghead_tpl = \
443 444 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
444 445 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
445 446 #log# opts = %s
446 447 #log# args = %s
447 448 #log# It is safe to make manual edits below here.
448 449 #log#-----------------------------------------------------------------------
449 450 """
450 451 # for pushd/popd management
451 452 try:
452 453 self.home_dir = get_home_dir()
453 454 except HomeDirError,msg:
454 455 fatal(msg)
455 456
456 457 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
457 458
458 459 # Functions to call the underlying shell.
459 460
460 461 # utility to expand user variables via Itpl
461 462 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
462 463 self.user_ns))
463 464 # The first is similar to os.system, but it doesn't return a value,
464 465 # and it allows interpolation of variables in the user's namespace.
465 466 self.system = lambda cmd: shell(self.var_expand(cmd),
466 467 header='IPython system call: ',
467 468 verbose=self.rc.system_verbose)
468 469 # These are for getoutput and getoutputerror:
469 470 self.getoutput = lambda cmd: \
470 471 getoutput(self.var_expand(cmd),
471 472 header='IPython system call: ',
472 473 verbose=self.rc.system_verbose)
473 474 self.getoutputerror = lambda cmd: \
474 475 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
475 476 self.user_ns)),
476 477 header='IPython system call: ',
477 478 verbose=self.rc.system_verbose)
478 479
479 480 # RegExp for splitting line contents into pre-char//first
480 481 # word-method//rest. For clarity, each group in on one line.
481 482
482 483 # WARNING: update the regexp if the above escapes are changed, as they
483 484 # are hardwired in.
484 485
485 486 # Don't get carried away with trying to make the autocalling catch too
486 487 # much: it's better to be conservative rather than to trigger hidden
487 488 # evals() somewhere and end up causing side effects.
488 489
489 490 self.line_split = re.compile(r'^([\s*,;/])'
490 491 r'([\?\w\.]+\w*\s*)'
491 492 r'(\(?.*$)')
492 493
493 494 # Original re, keep around for a while in case changes break something
494 495 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
495 496 # r'(\s*[\?\w\.]+\w*\s*)'
496 497 # r'(\(?.*$)')
497 498
498 499 # RegExp to identify potential function names
499 500 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
500 501
501 502 # RegExp to exclude strings with this start from autocalling. In
502 503 # particular, all binary operators should be excluded, so that if foo
503 504 # is callable, foo OP bar doesn't become foo(OP bar), which is
504 505 # invalid. The characters '!=()' don't need to be checked for, as the
505 506 # _prefilter routine explicitely does so, to catch direct calls and
506 507 # rebindings of existing names.
507 508
508 509 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
509 510 # it affects the rest of the group in square brackets.
510 511 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
511 512 '|^is |^not |^in |^and |^or ')
512 513
513 514 # try to catch also methods for stuff in lists/tuples/dicts: off
514 515 # (experimental). For this to work, the line_split regexp would need
515 516 # to be modified so it wouldn't break things at '['. That line is
516 517 # nasty enough that I shouldn't change it until I can test it _well_.
517 518 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
518 519
519 520 # keep track of where we started running (mainly for crash post-mortem)
520 521 self.starting_dir = os.getcwd()
521 522
522 523 # Various switches which can be set
523 524 self.CACHELENGTH = 5000 # this is cheap, it's just text
524 525 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
525 526 self.banner2 = banner2
526 527
527 528 # TraceBack handlers:
528 529
529 530 # Syntax error handler.
530 531 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
531 532
532 533 # The interactive one is initialized with an offset, meaning we always
533 534 # want to remove the topmost item in the traceback, which is our own
534 535 # internal code. Valid modes: ['Plain','Context','Verbose']
535 536 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
536 537 color_scheme='NoColor',
537 538 tb_offset = 1)
538 539
539 540 # IPython itself shouldn't crash. This will produce a detailed
540 541 # post-mortem if it does. But we only install the crash handler for
541 542 # non-threaded shells, the threaded ones use a normal verbose reporter
542 543 # and lose the crash handler. This is because exceptions in the main
543 544 # thread (such as in GUI code) propagate directly to sys.excepthook,
544 545 # and there's no point in printing crash dumps for every user exception.
545 546 if self.isthreaded:
546 547 sys.excepthook = ultraTB.FormattedTB()
547 548 else:
548 549 from IPython import CrashHandler
549 550 sys.excepthook = CrashHandler.CrashHandler(self)
550 551
551 552 # The instance will store a pointer to this, so that runtime code
552 553 # (such as magics) can access it. This is because during the
553 554 # read-eval loop, it gets temporarily overwritten (to deal with GUI
554 555 # frameworks).
555 556 self.sys_excepthook = sys.excepthook
556 557
557 558 # and add any custom exception handlers the user may have specified
558 559 self.set_custom_exc(*custom_exceptions)
559 560
560 561 # Object inspector
561 562 self.inspector = OInspect.Inspector(OInspect.InspectColors,
562 563 PyColorize.ANSICodeColors,
563 564 'NoColor')
564 565 # indentation management
565 566 self.autoindent = False
566 567 self.indent_current_nsp = 0
567 568
568 569 # Make some aliases automatically
569 570 # Prepare list of shell aliases to auto-define
570 571 if os.name == 'posix':
571 572 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
572 573 'mv mv -i','rm rm -i','cp cp -i',
573 574 'cat cat','less less','clear clear',
574 575 # a better ls
575 576 'ls ls -F',
576 577 # long ls
577 578 'll ls -lF',
578 579 # color ls
579 580 'lc ls -F -o --color',
580 581 # ls normal files only
581 582 'lf ls -F -o --color %l | grep ^-',
582 583 # ls symbolic links
583 584 'lk ls -F -o --color %l | grep ^l',
584 585 # directories or links to directories,
585 586 'ldir ls -F -o --color %l | grep /$',
586 587 # things which are executable
587 588 'lx ls -F -o --color %l | grep ^-..x',
588 589 )
589 590 elif os.name in ['nt','dos']:
590 591 auto_alias = ('dir dir /on', 'ls dir /on',
591 592 'ddir dir /ad /on', 'ldir dir /ad /on',
592 593 'mkdir mkdir','rmdir rmdir','echo echo',
593 594 'ren ren','cls cls','copy copy')
594 595 else:
595 596 auto_alias = ()
596 597 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
597 598 # Call the actual (public) initializer
598 599 self.init_auto_alias()
599 600 # end __init__
600 601
601 602 def post_config_initialization(self):
602 603 """Post configuration init method
603 604
604 605 This is called after the configuration files have been processed to
605 606 'finalize' the initialization."""
606 607
607 608 rc = self.rc
608 609
609 610 # Load readline proper
610 611 if rc.readline:
611 612 self.init_readline()
612 613
613 614 # local shortcut, this is used a LOT
614 615 self.log = self.logger.log
615 616
616 617 # Initialize cache, set in/out prompts and printing system
617 618 self.outputcache = CachedOutput(self,
618 619 rc.cache_size,
619 620 rc.pprint,
620 621 input_sep = rc.separate_in,
621 622 output_sep = rc.separate_out,
622 623 output_sep2 = rc.separate_out2,
623 624 ps1 = rc.prompt_in1,
624 625 ps2 = rc.prompt_in2,
625 626 ps_out = rc.prompt_out,
626 627 pad_left = rc.prompts_pad_left)
627 628
628 629 # user may have over-ridden the default print hook:
629 630 try:
630 631 self.outputcache.__class__.display = self.hooks.display
631 632 except AttributeError:
632 633 pass
633 634
634 635 # I don't like assigning globally to sys, because it means when embedding
635 636 # instances, each embedded instance overrides the previous choice. But
636 637 # sys.displayhook seems to be called internally by exec, so I don't see a
637 638 # way around it.
638 639 sys.displayhook = self.outputcache
639 640
640 641 # Set user colors (don't do it in the constructor above so that it
641 642 # doesn't crash if colors option is invalid)
642 643 self.magic_colors(rc.colors)
643 644
644 645 # Set calling of pdb on exceptions
645 646 self.call_pdb = rc.pdb
646 647
647 648 # Load user aliases
648 649 for alias in rc.alias:
649 650 self.magic_alias(alias)
650 651
651 652 # dynamic data that survives through sessions
652 653 # XXX make the filename a config option?
653 654 persist_base = 'persist'
654 655 if rc.profile:
655 656 persist_base += '_%s' % rc.profile
656 657 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
657 658
658 659 try:
659 660 self.persist = pickle.load(file(self.persist_fname))
660 661 except:
661 662 self.persist = {}
662 663
663 664
664 665 for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]:
665 666 try:
666 667 obj = pickle.loads(value)
667 668 except:
668 669
669 670 print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key
670 671 print "The error was:",sys.exc_info()[0]
671 672 continue
672 673
673 674
674 675 self.user_ns[key] = obj
675 676
676 677 def add_builtins(self):
677 678 """Store ipython references into the builtin namespace.
678 679
679 680 Some parts of ipython operate via builtins injected here, which hold a
680 681 reference to IPython itself."""
681 682
682 683 builtins_new = dict(__IPYTHON__ = self,
683 684 ip_set_hook = self.set_hook,
684 685 jobs = self.jobs,
685 686 ipmagic = self.ipmagic,
686 687 ipalias = self.ipalias,
687 688 ipsystem = self.ipsystem,
688 689 )
689 690 for biname,bival in builtins_new.items():
690 691 try:
691 692 # store the orignal value so we can restore it
692 693 self.builtins_added[biname] = __builtin__.__dict__[biname]
693 694 except KeyError:
694 695 # or mark that it wasn't defined, and we'll just delete it at
695 696 # cleanup
696 697 self.builtins_added[biname] = Undefined
697 698 __builtin__.__dict__[biname] = bival
698 699
699 700 # Keep in the builtins a flag for when IPython is active. We set it
700 701 # with setdefault so that multiple nested IPythons don't clobber one
701 702 # another. Each will increase its value by one upon being activated,
702 703 # which also gives us a way to determine the nesting level.
703 704 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
704 705
705 706 def clean_builtins(self):
706 707 """Remove any builtins which might have been added by add_builtins, or
707 708 restore overwritten ones to their previous values."""
708 709 for biname,bival in self.builtins_added.items():
709 710 if bival is Undefined:
710 711 del __builtin__.__dict__[biname]
711 712 else:
712 713 __builtin__.__dict__[biname] = bival
713 714 self.builtins_added.clear()
714 715
715 716 def set_hook(self,name,hook, priority = 50):
716 717 """set_hook(name,hook) -> sets an internal IPython hook.
717 718
718 719 IPython exposes some of its internal API as user-modifiable hooks. By
719 720 adding your function to one of these hooks, you can modify IPython's
720 721 behavior to call at runtime your own routines."""
721 722
722 723 # At some point in the future, this should validate the hook before it
723 724 # accepts it. Probably at least check that the hook takes the number
724 725 # of args it's supposed to.
725 726 dp = getattr(self.hooks, name, None)
726 727 if not dp:
727 728 dp = IPython.hooks.CommandChainDispatcher()
728 729
729 730 f = new.instancemethod(hook,self,self.__class__)
730 731 try:
731 732 dp.add(f,priority)
732 733 except AttributeError:
733 734 # it was not commandchain, plain old func - replace
734 735 dp = f
735 736
736 737 setattr(self.hooks,name, dp)
737 738
738 739
739 740 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
740 741
741 742 def set_custom_exc(self,exc_tuple,handler):
742 743 """set_custom_exc(exc_tuple,handler)
743 744
744 745 Set a custom exception handler, which will be called if any of the
745 746 exceptions in exc_tuple occur in the mainloop (specifically, in the
746 747 runcode() method.
747 748
748 749 Inputs:
749 750
750 751 - exc_tuple: a *tuple* of valid exceptions to call the defined
751 752 handler for. It is very important that you use a tuple, and NOT A
752 753 LIST here, because of the way Python's except statement works. If
753 754 you only want to trap a single exception, use a singleton tuple:
754 755
755 756 exc_tuple == (MyCustomException,)
756 757
757 758 - handler: this must be defined as a function with the following
758 759 basic interface: def my_handler(self,etype,value,tb).
759 760
760 761 This will be made into an instance method (via new.instancemethod)
761 762 of IPython itself, and it will be called if any of the exceptions
762 763 listed in the exc_tuple are caught. If the handler is None, an
763 764 internal basic one is used, which just prints basic info.
764 765
765 766 WARNING: by putting in your own exception handler into IPython's main
766 767 execution loop, you run a very good chance of nasty crashes. This
767 768 facility should only be used if you really know what you are doing."""
768 769
769 770 assert type(exc_tuple)==type(()) , \
770 771 "The custom exceptions must be given AS A TUPLE."
771 772
772 773 def dummy_handler(self,etype,value,tb):
773 774 print '*** Simple custom exception handler ***'
774 775 print 'Exception type :',etype
775 776 print 'Exception value:',value
776 777 print 'Traceback :',tb
777 778 print 'Source code :','\n'.join(self.buffer)
778 779
779 780 if handler is None: handler = dummy_handler
780 781
781 782 self.CustomTB = new.instancemethod(handler,self,self.__class__)
782 783 self.custom_exceptions = exc_tuple
783 784
784 785 def set_custom_completer(self,completer,pos=0):
785 786 """set_custom_completer(completer,pos=0)
786 787
787 788 Adds a new custom completer function.
788 789
789 790 The position argument (defaults to 0) is the index in the completers
790 791 list where you want the completer to be inserted."""
791 792
792 793 newcomp = new.instancemethod(completer,self.Completer,
793 794 self.Completer.__class__)
794 795 self.Completer.matchers.insert(pos,newcomp)
795 796
796 797 def _get_call_pdb(self):
797 798 return self._call_pdb
798 799
799 800 def _set_call_pdb(self,val):
800 801
801 802 if val not in (0,1,False,True):
802 803 raise ValueError,'new call_pdb value must be boolean'
803 804
804 805 # store value in instance
805 806 self._call_pdb = val
806 807
807 808 # notify the actual exception handlers
808 809 self.InteractiveTB.call_pdb = val
809 810 if self.isthreaded:
810 811 try:
811 812 self.sys_excepthook.call_pdb = val
812 813 except:
813 814 warn('Failed to activate pdb for threaded exception handler')
814 815
815 816 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
816 817 'Control auto-activation of pdb at exceptions')
817 818
818 819
819 820 # These special functions get installed in the builtin namespace, to
820 821 # provide programmatic (pure python) access to magics, aliases and system
821 822 # calls. This is important for logging, user scripting, and more.
822 823
823 824 # We are basically exposing, via normal python functions, the three
824 825 # mechanisms in which ipython offers special call modes (magics for
825 826 # internal control, aliases for direct system access via pre-selected
826 827 # names, and !cmd for calling arbitrary system commands).
827 828
828 829 def ipmagic(self,arg_s):
829 830 """Call a magic function by name.
830 831
831 832 Input: a string containing the name of the magic function to call and any
832 833 additional arguments to be passed to the magic.
833 834
834 835 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
835 836 prompt:
836 837
837 838 In[1]: %name -opt foo bar
838 839
839 840 To call a magic without arguments, simply use ipmagic('name').
840 841
841 842 This provides a proper Python function to call IPython's magics in any
842 843 valid Python code you can type at the interpreter, including loops and
843 844 compound statements. It is added by IPython to the Python builtin
844 845 namespace upon initialization."""
845 846
846 847 args = arg_s.split(' ',1)
847 848 magic_name = args[0]
848 849 magic_name = magic_name.lstrip(self.ESC_MAGIC)
849 850
850 851 try:
851 852 magic_args = args[1]
852 853 except IndexError:
853 854 magic_args = ''
854 855 fn = getattr(self,'magic_'+magic_name,None)
855 856 if fn is None:
856 857 error("Magic function `%s` not found." % magic_name)
857 858 else:
858 859 magic_args = self.var_expand(magic_args)
859 860 return fn(magic_args)
860 861
861 862 def ipalias(self,arg_s):
862 863 """Call an alias by name.
863 864
864 865 Input: a string containing the name of the alias to call and any
865 866 additional arguments to be passed to the magic.
866 867
867 868 ipalias('name -opt foo bar') is equivalent to typing at the ipython
868 869 prompt:
869 870
870 871 In[1]: name -opt foo bar
871 872
872 873 To call an alias without arguments, simply use ipalias('name').
873 874
874 875 This provides a proper Python function to call IPython's aliases in any
875 876 valid Python code you can type at the interpreter, including loops and
876 877 compound statements. It is added by IPython to the Python builtin
877 878 namespace upon initialization."""
878 879
879 880 args = arg_s.split(' ',1)
880 881 alias_name = args[0]
881 882 try:
882 883 alias_args = args[1]
883 884 except IndexError:
884 885 alias_args = ''
885 886 if alias_name in self.alias_table:
886 887 self.call_alias(alias_name,alias_args)
887 888 else:
888 889 error("Alias `%s` not found." % alias_name)
889 890
890 891 def ipsystem(self,arg_s):
891 892 """Make a system call, using IPython."""
892 893
893 894 self.system(arg_s)
894 895
895 896 def complete(self,text):
896 897 """Return a sorted list of all possible completions on text.
897 898
898 899 Inputs:
899 900
900 901 - text: a string of text to be completed on.
901 902
902 903 This is a wrapper around the completion mechanism, similar to what
903 904 readline does at the command line when the TAB key is hit. By
904 905 exposing it as a method, it can be used by other non-readline
905 906 environments (such as GUIs) for text completion.
906 907
907 908 Simple usage example:
908 909
909 910 In [1]: x = 'hello'
910 911
911 912 In [2]: __IP.complete('x.l')
912 913 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
913 914
914 915 complete = self.Completer.complete
915 916 state = 0
916 917 # use a dict so we get unique keys, since ipyhton's multiple
917 918 # completers can return duplicates.
918 919 comps = {}
919 920 while True:
920 921 newcomp = complete(text,state)
921 922 if newcomp is None:
922 923 break
923 924 comps[newcomp] = 1
924 925 state += 1
925 926 outcomps = comps.keys()
926 927 outcomps.sort()
927 928 return outcomps
928 929
929 930 def set_completer_frame(self, frame=None):
930 931 if frame:
931 932 self.Completer.namespace = frame.f_locals
932 933 self.Completer.global_namespace = frame.f_globals
933 934 else:
934 935 self.Completer.namespace = self.user_ns
935 936 self.Completer.global_namespace = self.user_global_ns
936 937
937 938 def init_auto_alias(self):
938 939 """Define some aliases automatically.
939 940
940 941 These are ALL parameter-less aliases"""
941 942
942 943 for alias,cmd in self.auto_alias:
943 944 self.alias_table[alias] = (0,cmd)
944 945
945 946 def alias_table_validate(self,verbose=0):
946 947 """Update information about the alias table.
947 948
948 949 In particular, make sure no Python keywords/builtins are in it."""
949 950
950 951 no_alias = self.no_alias
951 952 for k in self.alias_table.keys():
952 953 if k in no_alias:
953 954 del self.alias_table[k]
954 955 if verbose:
955 956 print ("Deleting alias <%s>, it's a Python "
956 957 "keyword or builtin." % k)
957 958
958 959 def set_autoindent(self,value=None):
959 960 """Set the autoindent flag, checking for readline support.
960 961
961 962 If called with no arguments, it acts as a toggle."""
962 963
963 964 if not self.has_readline:
964 965 if os.name == 'posix':
965 966 warn("The auto-indent feature requires the readline library")
966 967 self.autoindent = 0
967 968 return
968 969 if value is None:
969 970 self.autoindent = not self.autoindent
970 971 else:
971 972 self.autoindent = value
972 973
973 974 def rc_set_toggle(self,rc_field,value=None):
974 975 """Set or toggle a field in IPython's rc config. structure.
975 976
976 977 If called with no arguments, it acts as a toggle.
977 978
978 979 If called with a non-existent field, the resulting AttributeError
979 980 exception will propagate out."""
980 981
981 982 rc_val = getattr(self.rc,rc_field)
982 983 if value is None:
983 984 value = not rc_val
984 985 setattr(self.rc,rc_field,value)
985 986
986 987 def user_setup(self,ipythondir,rc_suffix,mode='install'):
987 988 """Install the user configuration directory.
988 989
989 990 Can be called when running for the first time or to upgrade the user's
990 991 .ipython/ directory with the mode parameter. Valid modes are 'install'
991 992 and 'upgrade'."""
992 993
993 994 def wait():
994 995 try:
995 996 raw_input("Please press <RETURN> to start IPython.")
996 997 except EOFError:
997 998 print >> Term.cout
998 999 print '*'*70
999 1000
1000 1001 cwd = os.getcwd() # remember where we started
1001 1002 glb = glob.glob
1002 1003 print '*'*70
1003 1004 if mode == 'install':
1004 1005 print \
1005 1006 """Welcome to IPython. I will try to create a personal configuration directory
1006 1007 where you can customize many aspects of IPython's functionality in:\n"""
1007 1008 else:
1008 1009 print 'I am going to upgrade your configuration in:'
1009 1010
1010 1011 print ipythondir
1011 1012
1012 1013 rcdirend = os.path.join('IPython','UserConfig')
1013 1014 cfg = lambda d: os.path.join(d,rcdirend)
1014 1015 try:
1015 1016 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1016 1017 except IOError:
1017 1018 warning = """
1018 1019 Installation error. IPython's directory was not found.
1019 1020
1020 1021 Check the following:
1021 1022
1022 1023 The ipython/IPython directory should be in a directory belonging to your
1023 1024 PYTHONPATH environment variable (that is, it should be in a directory
1024 1025 belonging to sys.path). You can copy it explicitly there or just link to it.
1025 1026
1026 1027 IPython will proceed with builtin defaults.
1027 1028 """
1028 1029 warn(warning)
1029 1030 wait()
1030 1031 return
1031 1032
1032 1033 if mode == 'install':
1033 1034 try:
1034 1035 shutil.copytree(rcdir,ipythondir)
1035 1036 os.chdir(ipythondir)
1036 1037 rc_files = glb("ipythonrc*")
1037 1038 for rc_file in rc_files:
1038 1039 os.rename(rc_file,rc_file+rc_suffix)
1039 1040 except:
1040 1041 warning = """
1041 1042
1042 1043 There was a problem with the installation:
1043 1044 %s
1044 1045 Try to correct it or contact the developers if you think it's a bug.
1045 1046 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1046 1047 warn(warning)
1047 1048 wait()
1048 1049 return
1049 1050
1050 1051 elif mode == 'upgrade':
1051 1052 try:
1052 1053 os.chdir(ipythondir)
1053 1054 except:
1054 1055 print """
1055 1056 Can not upgrade: changing to directory %s failed. Details:
1056 1057 %s
1057 1058 """ % (ipythondir,sys.exc_info()[1])
1058 1059 wait()
1059 1060 return
1060 1061 else:
1061 1062 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1062 1063 for new_full_path in sources:
1063 1064 new_filename = os.path.basename(new_full_path)
1064 1065 if new_filename.startswith('ipythonrc'):
1065 1066 new_filename = new_filename + rc_suffix
1066 1067 # The config directory should only contain files, skip any
1067 1068 # directories which may be there (like CVS)
1068 1069 if os.path.isdir(new_full_path):
1069 1070 continue
1070 1071 if os.path.exists(new_filename):
1071 1072 old_file = new_filename+'.old'
1072 1073 if os.path.exists(old_file):
1073 1074 os.remove(old_file)
1074 1075 os.rename(new_filename,old_file)
1075 1076 shutil.copy(new_full_path,new_filename)
1076 1077 else:
1077 1078 raise ValueError,'unrecognized mode for install:',`mode`
1078 1079
1079 1080 # Fix line-endings to those native to each platform in the config
1080 1081 # directory.
1081 1082 try:
1082 1083 os.chdir(ipythondir)
1083 1084 except:
1084 1085 print """
1085 1086 Problem: changing to directory %s failed.
1086 1087 Details:
1087 1088 %s
1088 1089
1089 1090 Some configuration files may have incorrect line endings. This should not
1090 1091 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1091 1092 wait()
1092 1093 else:
1093 1094 for fname in glb('ipythonrc*'):
1094 1095 try:
1095 1096 native_line_ends(fname,backup=0)
1096 1097 except IOError:
1097 1098 pass
1098 1099
1099 1100 if mode == 'install':
1100 1101 print """
1101 1102 Successful installation!
1102 1103
1103 1104 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1104 1105 IPython manual (there are both HTML and PDF versions supplied with the
1105 1106 distribution) to make sure that your system environment is properly configured
1106 1107 to take advantage of IPython's features.
1107 1108
1108 1109 Important note: the configuration system has changed! The old system is
1109 1110 still in place, but its setting may be partly overridden by the settings in
1110 1111 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1111 1112 if some of the new settings bother you.
1112 1113
1113 1114 """
1114 1115 else:
1115 1116 print """
1116 1117 Successful upgrade!
1117 1118
1118 1119 All files in your directory:
1119 1120 %(ipythondir)s
1120 1121 which would have been overwritten by the upgrade were backed up with a .old
1121 1122 extension. If you had made particular customizations in those files you may
1122 1123 want to merge them back into the new files.""" % locals()
1123 1124 wait()
1124 1125 os.chdir(cwd)
1125 1126 # end user_setup()
1126 1127
1127 1128 def atexit_operations(self):
1128 1129 """This will be executed at the time of exit.
1129 1130
1130 1131 Saving of persistent data should be performed here. """
1131 1132
1132 1133 #print '*** IPython exit cleanup ***' # dbg
1133 1134 # input history
1134 1135 self.savehist()
1135 1136
1136 1137 # Cleanup all tempfiles left around
1137 1138 for tfile in self.tempfiles:
1138 1139 try:
1139 1140 os.unlink(tfile)
1140 1141 except OSError:
1141 1142 pass
1142 1143
1143 1144 # save the "persistent data" catch-all dictionary
1144 1145 try:
1145 1146 pickle.dump(self.persist, open(self.persist_fname,"w"))
1146 1147 except:
1147 1148 print "*** ERROR *** persistent data saving failed."
1148 1149
1149 1150 def savehist(self):
1150 1151 """Save input history to a file (via readline library)."""
1151 1152 try:
1152 1153 self.readline.write_history_file(self.histfile)
1153 1154 except:
1154 1155 print 'Unable to save IPython command history to file: ' + \
1155 1156 `self.histfile`
1156 1157
1157 1158 def pre_readline(self):
1158 1159 """readline hook to be used at the start of each line.
1159 1160
1160 1161 Currently it handles auto-indent only."""
1161 1162
1162 1163 #debugx('self.indent_current_nsp','pre_readline:')
1163 1164 self.readline.insert_text(self.indent_current_str())
1164 1165
1165 1166 def init_readline(self):
1166 1167 """Command history completion/saving/reloading."""
1167 1168 try:
1168 1169 import readline
1169 1170 except ImportError:
1170 1171 self.has_readline = 0
1171 1172 self.readline = None
1172 1173 # no point in bugging windows users with this every time:
1173 1174 if os.name == 'posix':
1174 1175 warn('Readline services not available on this platform.')
1175 1176 else:
1176 1177 import atexit
1177 1178 from IPython.completer import IPCompleter
1178 1179 self.Completer = IPCompleter(self,
1179 1180 self.user_ns,
1180 1181 self.user_global_ns,
1181 1182 self.rc.readline_omit__names,
1182 1183 self.alias_table)
1183 1184
1184 1185 # Platform-specific configuration
1185 1186 if os.name == 'nt':
1186 1187 self.readline_startup_hook = readline.set_pre_input_hook
1187 1188 else:
1188 1189 self.readline_startup_hook = readline.set_startup_hook
1189 1190
1190 1191 # Load user's initrc file (readline config)
1191 1192 inputrc_name = os.environ.get('INPUTRC')
1192 1193 if inputrc_name is None:
1193 1194 home_dir = get_home_dir()
1194 1195 if home_dir is not None:
1195 1196 inputrc_name = os.path.join(home_dir,'.inputrc')
1196 1197 if os.path.isfile(inputrc_name):
1197 1198 try:
1198 1199 readline.read_init_file(inputrc_name)
1199 1200 except:
1200 1201 warn('Problems reading readline initialization file <%s>'
1201 1202 % inputrc_name)
1202 1203
1203 1204 self.has_readline = 1
1204 1205 self.readline = readline
1205 1206 # save this in sys so embedded copies can restore it properly
1206 1207 sys.ipcompleter = self.Completer.complete
1207 1208 readline.set_completer(self.Completer.complete)
1208 1209
1209 1210 # Configure readline according to user's prefs
1210 1211 for rlcommand in self.rc.readline_parse_and_bind:
1211 1212 readline.parse_and_bind(rlcommand)
1212 1213
1213 1214 # remove some chars from the delimiters list
1214 1215 delims = readline.get_completer_delims()
1215 1216 delims = delims.translate(string._idmap,
1216 1217 self.rc.readline_remove_delims)
1217 1218 readline.set_completer_delims(delims)
1218 1219 # otherwise we end up with a monster history after a while:
1219 1220 readline.set_history_length(1000)
1220 1221 try:
1221 1222 #print '*** Reading readline history' # dbg
1222 1223 readline.read_history_file(self.histfile)
1223 1224 except IOError:
1224 1225 pass # It doesn't exist yet.
1225 1226
1226 1227 atexit.register(self.atexit_operations)
1227 1228 del atexit
1228 1229
1229 1230 # Configure auto-indent for all platforms
1230 1231 self.set_autoindent(self.rc.autoindent)
1231 1232
1232 1233 def _should_recompile(self,e):
1233 1234 """Utility routine for edit_syntax_error"""
1234 1235
1235 1236 if e.filename in ('<ipython console>','<input>','<string>',
1236 1237 '<console>',None):
1237 1238
1238 1239 return False
1239 1240 try:
1240 1241 if not ask_yes_no('Return to editor to correct syntax error? '
1241 1242 '[Y/n] ','y'):
1242 1243 return False
1243 1244 except EOFError:
1244 1245 return False
1245 1246
1246 1247 def int0(x):
1247 1248 try:
1248 1249 return int(x)
1249 1250 except TypeError:
1250 1251 return 0
1251 1252 # always pass integer line and offset values to editor hook
1252 1253 self.hooks.fix_error_editor(e.filename,
1253 1254 int0(e.lineno),int0(e.offset),e.msg)
1254 1255 return True
1255 1256
1256 1257 def edit_syntax_error(self):
1257 1258 """The bottom half of the syntax error handler called in the main loop.
1258 1259
1259 1260 Loop until syntax error is fixed or user cancels.
1260 1261 """
1261 1262
1262 1263 while self.SyntaxTB.last_syntax_error:
1263 1264 # copy and clear last_syntax_error
1264 1265 err = self.SyntaxTB.clear_err_state()
1265 1266 if not self._should_recompile(err):
1266 1267 return
1267 1268 try:
1268 1269 # may set last_syntax_error again if a SyntaxError is raised
1269 1270 self.safe_execfile(err.filename,self.shell.user_ns)
1270 1271 except:
1271 1272 self.showtraceback()
1272 1273 else:
1273 1274 f = file(err.filename)
1274 1275 try:
1275 1276 sys.displayhook(f.read())
1276 1277 finally:
1277 1278 f.close()
1278 1279
1279 1280 def showsyntaxerror(self, filename=None):
1280 1281 """Display the syntax error that just occurred.
1281 1282
1282 1283 This doesn't display a stack trace because there isn't one.
1283 1284
1284 1285 If a filename is given, it is stuffed in the exception instead
1285 1286 of what was there before (because Python's parser always uses
1286 1287 "<string>" when reading from a string).
1287 1288 """
1288 1289 etype, value, last_traceback = sys.exc_info()
1289 1290 if filename and etype is SyntaxError:
1290 1291 # Work hard to stuff the correct filename in the exception
1291 1292 try:
1292 1293 msg, (dummy_filename, lineno, offset, line) = value
1293 1294 except:
1294 1295 # Not the format we expect; leave it alone
1295 1296 pass
1296 1297 else:
1297 1298 # Stuff in the right filename
1298 1299 try:
1299 1300 # Assume SyntaxError is a class exception
1300 1301 value = SyntaxError(msg, (filename, lineno, offset, line))
1301 1302 except:
1302 1303 # If that failed, assume SyntaxError is a string
1303 1304 value = msg, (filename, lineno, offset, line)
1304 1305 self.SyntaxTB(etype,value,[])
1305 1306
1306 1307 def debugger(self):
1307 1308 """Call the pdb debugger."""
1308 1309
1309 1310 if not self.rc.pdb:
1310 1311 return
1311 1312 pdb.pm()
1312 1313
1313 1314 def showtraceback(self,exc_tuple = None,filename=None):
1314 1315 """Display the exception that just occurred."""
1315 1316
1316 1317 # Though this won't be called by syntax errors in the input line,
1317 1318 # there may be SyntaxError cases whith imported code.
1318 1319 if exc_tuple is None:
1319 1320 type, value, tb = sys.exc_info()
1320 1321 else:
1321 1322 type, value, tb = exc_tuple
1322 1323 if type is SyntaxError:
1323 1324 self.showsyntaxerror(filename)
1324 1325 else:
1325 1326 self.InteractiveTB()
1326 1327 if self.InteractiveTB.call_pdb and self.has_readline:
1327 1328 # pdb mucks up readline, fix it back
1328 1329 self.readline.set_completer(self.Completer.complete)
1329 1330
1330 1331 def mainloop(self,banner=None):
1331 1332 """Creates the local namespace and starts the mainloop.
1332 1333
1333 1334 If an optional banner argument is given, it will override the
1334 1335 internally created default banner."""
1335 1336
1336 1337 if self.rc.c: # Emulate Python's -c option
1337 1338 self.exec_init_cmd()
1338 1339 if banner is None:
1339 1340 if self.rc.banner:
1340 1341 banner = self.BANNER+self.banner2
1341 1342 else:
1342 1343 banner = ''
1343 1344 self.interact(banner)
1344 1345
1345 1346 def exec_init_cmd(self):
1346 1347 """Execute a command given at the command line.
1347 1348
1348 1349 This emulates Python's -c option."""
1349 1350
1350 1351 sys.argv = ['-c']
1351 1352 self.push(self.rc.c)
1352 1353
1353 1354 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1354 1355 """Embeds IPython into a running python program.
1355 1356
1356 1357 Input:
1357 1358
1358 1359 - header: An optional header message can be specified.
1359 1360
1360 1361 - local_ns, global_ns: working namespaces. If given as None, the
1361 1362 IPython-initialized one is updated with __main__.__dict__, so that
1362 1363 program variables become visible but user-specific configuration
1363 1364 remains possible.
1364 1365
1365 1366 - stack_depth: specifies how many levels in the stack to go to
1366 1367 looking for namespaces (when local_ns and global_ns are None). This
1367 1368 allows an intermediate caller to make sure that this function gets
1368 1369 the namespace from the intended level in the stack. By default (0)
1369 1370 it will get its locals and globals from the immediate caller.
1370 1371
1371 1372 Warning: it's possible to use this in a program which is being run by
1372 1373 IPython itself (via %run), but some funny things will happen (a few
1373 1374 globals get overwritten). In the future this will be cleaned up, as
1374 1375 there is no fundamental reason why it can't work perfectly."""
1375 1376
1376 1377 # Get locals and globals from caller
1377 1378 if local_ns is None or global_ns is None:
1378 1379 call_frame = sys._getframe(stack_depth).f_back
1379 1380
1380 1381 if local_ns is None:
1381 1382 local_ns = call_frame.f_locals
1382 1383 if global_ns is None:
1383 1384 global_ns = call_frame.f_globals
1384 1385
1385 1386 # Update namespaces and fire up interpreter
1386 1387
1387 1388 # The global one is easy, we can just throw it in
1388 1389 self.user_global_ns = global_ns
1389 1390
1390 1391 # but the user/local one is tricky: ipython needs it to store internal
1391 1392 # data, but we also need the locals. We'll copy locals in the user
1392 1393 # one, but will track what got copied so we can delete them at exit.
1393 1394 # This is so that a later embedded call doesn't see locals from a
1394 1395 # previous call (which most likely existed in a separate scope).
1395 1396 local_varnames = local_ns.keys()
1396 1397 self.user_ns.update(local_ns)
1397 1398
1398 1399 # Patch for global embedding to make sure that things don't overwrite
1399 1400 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1400 1401 # FIXME. Test this a bit more carefully (the if.. is new)
1401 1402 if local_ns is None and global_ns is None:
1402 1403 self.user_global_ns.update(__main__.__dict__)
1403 1404
1404 1405 # make sure the tab-completer has the correct frame information, so it
1405 1406 # actually completes using the frame's locals/globals
1406 1407 self.set_completer_frame()
1407 1408
1408 1409 # before activating the interactive mode, we need to make sure that
1409 1410 # all names in the builtin namespace needed by ipython point to
1410 1411 # ourselves, and not to other instances.
1411 1412 self.add_builtins()
1412 1413
1413 1414 self.interact(header)
1414 1415
1415 1416 # now, purge out the user namespace from anything we might have added
1416 1417 # from the caller's local namespace
1417 1418 delvar = self.user_ns.pop
1418 1419 for var in local_varnames:
1419 1420 delvar(var,None)
1420 1421 # and clean builtins we may have overridden
1421 1422 self.clean_builtins()
1422 1423
1423 1424 def interact(self, banner=None):
1424 1425 """Closely emulate the interactive Python console.
1425 1426
1426 1427 The optional banner argument specify the banner to print
1427 1428 before the first interaction; by default it prints a banner
1428 1429 similar to the one printed by the real Python interpreter,
1429 1430 followed by the current class name in parentheses (so as not
1430 1431 to confuse this with the real interpreter -- since it's so
1431 1432 close!).
1432 1433
1433 1434 """
1434 1435 cprt = 'Type "copyright", "credits" or "license" for more information.'
1435 1436 if banner is None:
1436 1437 self.write("Python %s on %s\n%s\n(%s)\n" %
1437 1438 (sys.version, sys.platform, cprt,
1438 1439 self.__class__.__name__))
1439 1440 else:
1440 1441 self.write(banner)
1441 1442
1442 1443 more = 0
1443 1444
1444 1445 # Mark activity in the builtins
1445 1446 __builtin__.__dict__['__IPYTHON__active'] += 1
1446 1447
1447 1448 # exit_now is set by a call to %Exit or %Quit
1448 1449 self.exit_now = False
1449 1450 while not self.exit_now:
1450 1451
1451 1452 try:
1452 1453 if more:
1453 1454 prompt = self.outputcache.prompt2
1454 1455 if self.autoindent:
1455 1456 self.readline_startup_hook(self.pre_readline)
1456 1457 else:
1457 1458 prompt = self.outputcache.prompt1
1458 1459 try:
1459 1460 line = self.raw_input(prompt,more)
1460 1461 if self.autoindent:
1461 1462 self.readline_startup_hook(None)
1462 1463 except EOFError:
1463 1464 if self.autoindent:
1464 1465 self.readline_startup_hook(None)
1465 1466 self.write("\n")
1466 1467 self.exit()
1467 1468 except:
1468 1469 # exceptions here are VERY RARE, but they can be triggered
1469 1470 # asynchronously by signal handlers, for example.
1470 1471 self.showtraceback()
1471 1472 else:
1472 1473 more = self.push(line)
1473 1474
1474 1475 if (self.SyntaxTB.last_syntax_error and
1475 1476 self.rc.autoedit_syntax):
1476 1477 self.edit_syntax_error()
1477 1478
1478 1479 except KeyboardInterrupt:
1479 1480 self.write("\nKeyboardInterrupt\n")
1480 1481 self.resetbuffer()
1481 1482 more = 0
1482 1483 # keep cache in sync with the prompt counter:
1483 1484 self.outputcache.prompt_count -= 1
1484 1485
1485 1486 if self.autoindent:
1486 1487 self.indent_current_nsp = 0
1487 1488
1488 1489 except bdb.BdbQuit:
1489 1490 warn("The Python debugger has exited with a BdbQuit exception.\n"
1490 1491 "Because of how pdb handles the stack, it is impossible\n"
1491 1492 "for IPython to properly format this particular exception.\n"
1492 1493 "IPython will resume normal operation.")
1493 1494
1494 1495 # We are off again...
1495 1496 __builtin__.__dict__['__IPYTHON__active'] -= 1
1496 1497
1497 1498 def excepthook(self, type, value, tb):
1498 1499 """One more defense for GUI apps that call sys.excepthook.
1499 1500
1500 1501 GUI frameworks like wxPython trap exceptions and call
1501 1502 sys.excepthook themselves. I guess this is a feature that
1502 1503 enables them to keep running after exceptions that would
1503 1504 otherwise kill their mainloop. This is a bother for IPython
1504 1505 which excepts to catch all of the program exceptions with a try:
1505 1506 except: statement.
1506 1507
1507 1508 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1508 1509 any app directly invokes sys.excepthook, it will look to the user like
1509 1510 IPython crashed. In order to work around this, we can disable the
1510 1511 CrashHandler and replace it with this excepthook instead, which prints a
1511 1512 regular traceback using our InteractiveTB. In this fashion, apps which
1512 1513 call sys.excepthook will generate a regular-looking exception from
1513 1514 IPython, and the CrashHandler will only be triggered by real IPython
1514 1515 crashes.
1515 1516
1516 1517 This hook should be used sparingly, only in places which are not likely
1517 1518 to be true IPython errors.
1518 1519 """
1519 1520
1520 1521 self.InteractiveTB(type, value, tb, tb_offset=0)
1521 1522 if self.InteractiveTB.call_pdb and self.has_readline:
1522 1523 self.readline.set_completer(self.Completer.complete)
1523 1524
1524 1525 def call_alias(self,alias,rest=''):
1525 1526 """Call an alias given its name and the rest of the line.
1526 1527
1527 1528 This function MUST be given a proper alias, because it doesn't make
1528 1529 any checks when looking up into the alias table. The caller is
1529 1530 responsible for invoking it only with a valid alias."""
1530 1531
1531 1532 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1532 1533 nargs,cmd = self.alias_table[alias]
1533 1534 # Expand the %l special to be the user's input line
1534 1535 if cmd.find('%l') >= 0:
1535 1536 cmd = cmd.replace('%l',rest)
1536 1537 rest = ''
1537 1538 if nargs==0:
1538 1539 # Simple, argument-less aliases
1539 1540 cmd = '%s %s' % (cmd,rest)
1540 1541 else:
1541 1542 # Handle aliases with positional arguments
1542 1543 args = rest.split(None,nargs)
1543 1544 if len(args)< nargs:
1544 1545 error('Alias <%s> requires %s arguments, %s given.' %
1545 1546 (alias,nargs,len(args)))
1546 1547 return
1547 1548 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1548 1549 # Now call the macro, evaluating in the user's namespace
1549 1550 try:
1550 1551 self.system(cmd)
1551 1552 except:
1552 1553 self.showtraceback()
1553 1554
1554 1555 def indent_current_str(self):
1555 1556 """return the current level of indentation as a string"""
1556 1557 return self.indent_current_nsp * ' '
1557 1558
1558 1559 def autoindent_update(self,line):
1559 1560 """Keep track of the indent level."""
1560 1561
1561 1562 #debugx('line')
1562 1563 #debugx('self.indent_current_nsp')
1563 1564 if self.autoindent:
1564 1565 if line:
1565 1566 inisp = num_ini_spaces(line)
1566 1567 if inisp < self.indent_current_nsp:
1567 1568 self.indent_current_nsp = inisp
1568 1569
1569 1570 if line[-1] == ':':
1570 1571 self.indent_current_nsp += 4
1571 1572 elif dedent_re.match(line):
1572 1573 self.indent_current_nsp -= 4
1573 1574 else:
1574 1575 self.indent_current_nsp = 0
1575 1576
1576 1577 def runlines(self,lines):
1577 1578 """Run a string of one or more lines of source.
1578 1579
1579 1580 This method is capable of running a string containing multiple source
1580 1581 lines, as if they had been entered at the IPython prompt. Since it
1581 1582 exposes IPython's processing machinery, the given strings can contain
1582 1583 magic calls (%magic), special shell access (!cmd), etc."""
1583 1584
1584 1585 # We must start with a clean buffer, in case this is run from an
1585 1586 # interactive IPython session (via a magic, for example).
1586 1587 self.resetbuffer()
1587 1588 lines = lines.split('\n')
1588 1589 more = 0
1589 1590 for line in lines:
1590 1591 # skip blank lines so we don't mess up the prompt counter, but do
1591 1592 # NOT skip even a blank line if we are in a code block (more is
1592 1593 # true)
1593 1594 if line or more:
1594 1595 more = self.push(self.prefilter(line,more))
1595 1596 # IPython's runsource returns None if there was an error
1596 1597 # compiling the code. This allows us to stop processing right
1597 1598 # away, so the user gets the error message at the right place.
1598 1599 if more is None:
1599 1600 break
1600 1601 # final newline in case the input didn't have it, so that the code
1601 1602 # actually does get executed
1602 1603 if more:
1603 1604 self.push('\n')
1604 1605
1605 1606 def runsource(self, source, filename='<input>', symbol='single'):
1606 1607 """Compile and run some source in the interpreter.
1607 1608
1608 1609 Arguments are as for compile_command().
1609 1610
1610 1611 One several things can happen:
1611 1612
1612 1613 1) The input is incorrect; compile_command() raised an
1613 1614 exception (SyntaxError or OverflowError). A syntax traceback
1614 1615 will be printed by calling the showsyntaxerror() method.
1615 1616
1616 1617 2) The input is incomplete, and more input is required;
1617 1618 compile_command() returned None. Nothing happens.
1618 1619
1619 1620 3) The input is complete; compile_command() returned a code
1620 1621 object. The code is executed by calling self.runcode() (which
1621 1622 also handles run-time exceptions, except for SystemExit).
1622 1623
1623 1624 The return value is:
1624 1625
1625 1626 - True in case 2
1626 1627
1627 1628 - False in the other cases, unless an exception is raised, where
1628 1629 None is returned instead. This can be used by external callers to
1629 1630 know whether to continue feeding input or not.
1630 1631
1631 1632 The return value can be used to decide whether to use sys.ps1 or
1632 1633 sys.ps2 to prompt the next line."""
1633 1634
1634 1635 try:
1635 1636 code = self.compile(source,filename,symbol)
1636 1637 except (OverflowError, SyntaxError, ValueError):
1637 1638 # Case 1
1638 1639 self.showsyntaxerror(filename)
1639 1640 return None
1640 1641
1641 1642 if code is None:
1642 1643 # Case 2
1643 1644 return True
1644 1645
1645 1646 # Case 3
1646 1647 # We store the code object so that threaded shells and
1647 1648 # custom exception handlers can access all this info if needed.
1648 1649 # The source corresponding to this can be obtained from the
1649 1650 # buffer attribute as '\n'.join(self.buffer).
1650 1651 self.code_to_run = code
1651 1652 # now actually execute the code object
1652 1653 if self.runcode(code) == 0:
1653 1654 return False
1654 1655 else:
1655 1656 return None
1656 1657
1657 1658 def runcode(self,code_obj):
1658 1659 """Execute a code object.
1659 1660
1660 1661 When an exception occurs, self.showtraceback() is called to display a
1661 1662 traceback.
1662 1663
1663 1664 Return value: a flag indicating whether the code to be run completed
1664 1665 successfully:
1665 1666
1666 1667 - 0: successful execution.
1667 1668 - 1: an error occurred.
1668 1669 """
1669 1670
1670 1671 # Set our own excepthook in case the user code tries to call it
1671 1672 # directly, so that the IPython crash handler doesn't get triggered
1672 1673 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1673 1674
1674 1675 # we save the original sys.excepthook in the instance, in case config
1675 1676 # code (such as magics) needs access to it.
1676 1677 self.sys_excepthook = old_excepthook
1677 1678 outflag = 1 # happens in more places, so it's easier as default
1678 1679 try:
1679 1680 try:
1680 1681 # Embedded instances require separate global/local namespaces
1681 1682 # so they can see both the surrounding (local) namespace and
1682 1683 # the module-level globals when called inside another function.
1683 1684 if self.embedded:
1684 1685 exec code_obj in self.user_global_ns, self.user_ns
1685 1686 # Normal (non-embedded) instances should only have a single
1686 1687 # namespace for user code execution, otherwise functions won't
1687 1688 # see interactive top-level globals.
1688 1689 else:
1689 1690 exec code_obj in self.user_ns
1690 1691 finally:
1691 1692 # Reset our crash handler in place
1692 1693 sys.excepthook = old_excepthook
1693 1694 except SystemExit:
1694 1695 self.resetbuffer()
1695 1696 self.showtraceback()
1696 1697 warn("Type exit or quit to exit IPython "
1697 1698 "(%Exit or %Quit do so unconditionally).",level=1)
1698 1699 except self.custom_exceptions:
1699 1700 etype,value,tb = sys.exc_info()
1700 1701 self.CustomTB(etype,value,tb)
1701 1702 except:
1702 1703 self.showtraceback()
1703 1704 else:
1704 1705 outflag = 0
1705 1706 if softspace(sys.stdout, 0):
1706 1707 print
1707 1708 # Flush out code object which has been run (and source)
1708 1709 self.code_to_run = None
1709 1710 return outflag
1710 1711
1711 1712 def push(self, line):
1712 1713 """Push a line to the interpreter.
1713 1714
1714 1715 The line should not have a trailing newline; it may have
1715 1716 internal newlines. The line is appended to a buffer and the
1716 1717 interpreter's runsource() method is called with the
1717 1718 concatenated contents of the buffer as source. If this
1718 1719 indicates that the command was executed or invalid, the buffer
1719 1720 is reset; otherwise, the command is incomplete, and the buffer
1720 1721 is left as it was after the line was appended. The return
1721 1722 value is 1 if more input is required, 0 if the line was dealt
1722 1723 with in some way (this is the same as runsource()).
1723 1724 """
1724 1725
1725 1726 # autoindent management should be done here, and not in the
1726 1727 # interactive loop, since that one is only seen by keyboard input. We
1727 1728 # need this done correctly even for code run via runlines (which uses
1728 1729 # push).
1729 1730
1730 1731 #print 'push line: <%s>' % line # dbg
1731 1732 self.autoindent_update(line)
1732 1733
1733 1734 self.buffer.append(line)
1734 1735 more = self.runsource('\n'.join(self.buffer), self.filename)
1735 1736 if not more:
1736 1737 self.resetbuffer()
1737 1738 return more
1738 1739
1739 1740 def resetbuffer(self):
1740 1741 """Reset the input buffer."""
1741 1742 self.buffer[:] = []
1742 1743
1743 1744 def raw_input(self,prompt='',continue_prompt=False):
1744 1745 """Write a prompt and read a line.
1745 1746
1746 1747 The returned line does not include the trailing newline.
1747 1748 When the user enters the EOF key sequence, EOFError is raised.
1748 1749
1749 1750 Optional inputs:
1750 1751
1751 1752 - prompt(''): a string to be printed to prompt the user.
1752 1753
1753 1754 - continue_prompt(False): whether this line is the first one or a
1754 1755 continuation in a sequence of inputs.
1755 1756 """
1756 1757
1757 1758 line = raw_input_original(prompt)
1758 1759 # Try to be reasonably smart about not re-indenting pasted input more
1759 1760 # than necessary. We do this by trimming out the auto-indent initial
1760 1761 # spaces, if the user's actual input started itself with whitespace.
1761 1762 #debugx('self.buffer[-1]')
1762 1763
1763 1764 if self.autoindent:
1764 1765 if num_ini_spaces(line) > self.indent_current_nsp:
1765 1766 line = line[self.indent_current_nsp:]
1766 1767 self.indent_current_nsp = 0
1767 1768
1768 1769 # store the unfiltered input before the user has any chance to modify
1769 1770 # it.
1770 1771 if line.strip():
1771 1772 if continue_prompt:
1772 1773 self.input_hist_raw[-1] += '%s\n' % line
1773 1774 else:
1774 1775 self.input_hist_raw.append('%s\n' % line)
1775 1776
1776 1777 lineout = self.prefilter(line,continue_prompt)
1777 1778 return lineout
1778 1779
1779 1780 def split_user_input(self,line):
1780 1781 """Split user input into pre-char, function part and rest."""
1781 1782
1782 1783 lsplit = self.line_split.match(line)
1783 1784 if lsplit is None: # no regexp match returns None
1784 1785 try:
1785 1786 iFun,theRest = line.split(None,1)
1786 1787 except ValueError:
1787 1788 iFun,theRest = line,''
1788 1789 pre = re.match('^(\s*)(.*)',line).groups()[0]
1789 1790 else:
1790 1791 pre,iFun,theRest = lsplit.groups()
1791 1792
1792 1793 #print 'line:<%s>' % line # dbg
1793 1794 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1794 1795 return pre,iFun.strip(),theRest
1795 1796
1796 1797 def _prefilter(self, line, continue_prompt):
1797 1798 """Calls different preprocessors, depending on the form of line."""
1798 1799
1799 1800 # All handlers *must* return a value, even if it's blank ('').
1800 1801
1801 1802 # Lines are NOT logged here. Handlers should process the line as
1802 1803 # needed, update the cache AND log it (so that the input cache array
1803 1804 # stays synced).
1804 1805
1805 1806 # This function is _very_ delicate, and since it's also the one which
1806 1807 # determines IPython's response to user input, it must be as efficient
1807 1808 # as possible. For this reason it has _many_ returns in it, trying
1808 1809 # always to exit as quickly as it can figure out what it needs to do.
1809 1810
1810 1811 # This function is the main responsible for maintaining IPython's
1811 1812 # behavior respectful of Python's semantics. So be _very_ careful if
1812 1813 # making changes to anything here.
1813 1814
1814 1815 #.....................................................................
1815 1816 # Code begins
1816 1817
1817 1818 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1818 1819
1819 1820 # save the line away in case we crash, so the post-mortem handler can
1820 1821 # record it
1821 1822 self._last_input_line = line
1822 1823
1823 1824 #print '***line: <%s>' % line # dbg
1824 1825
1825 1826 # the input history needs to track even empty lines
1826 1827 if not line.strip():
1827 1828 if not continue_prompt:
1828 1829 self.outputcache.prompt_count -= 1
1829 1830 return self.handle_normal(line,continue_prompt)
1830 1831 #return self.handle_normal('',continue_prompt)
1831 1832
1832 1833 # print '***cont',continue_prompt # dbg
1833 1834 # special handlers are only allowed for single line statements
1834 1835 if continue_prompt and not self.rc.multi_line_specials:
1835 1836 return self.handle_normal(line,continue_prompt)
1836 1837
1837 1838 # For the rest, we need the structure of the input
1838 1839 pre,iFun,theRest = self.split_user_input(line)
1839 1840 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1840 1841
1841 1842 # First check for explicit escapes in the last/first character
1842 1843 handler = None
1843 1844 if line[-1] == self.ESC_HELP:
1844 1845 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1845 1846 if handler is None:
1846 1847 # look at the first character of iFun, NOT of line, so we skip
1847 1848 # leading whitespace in multiline input
1848 1849 handler = self.esc_handlers.get(iFun[0:1])
1849 1850 if handler is not None:
1850 1851 return handler(line,continue_prompt,pre,iFun,theRest)
1851 1852 # Emacs ipython-mode tags certain input lines
1852 1853 if line.endswith('# PYTHON-MODE'):
1853 1854 return self.handle_emacs(line,continue_prompt)
1854 1855
1855 1856 # Next, check if we can automatically execute this thing
1856 1857
1857 1858 # Allow ! in multi-line statements if multi_line_specials is on:
1858 1859 if continue_prompt and self.rc.multi_line_specials and \
1859 1860 iFun.startswith(self.ESC_SHELL):
1860 1861 return self.handle_shell_escape(line,continue_prompt,
1861 1862 pre=pre,iFun=iFun,
1862 1863 theRest=theRest)
1863 1864
1864 1865 # Let's try to find if the input line is a magic fn
1865 1866 oinfo = None
1866 1867 if hasattr(self,'magic_'+iFun):
1867 1868 # WARNING: _ofind uses getattr(), so it can consume generators and
1868 1869 # cause other side effects.
1869 1870 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1870 1871 if oinfo['ismagic']:
1871 1872 # Be careful not to call magics when a variable assignment is
1872 1873 # being made (ls='hi', for example)
1873 1874 if self.rc.automagic and \
1874 1875 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1875 1876 (self.rc.multi_line_specials or not continue_prompt):
1876 1877 return self.handle_magic(line,continue_prompt,
1877 1878 pre,iFun,theRest)
1878 1879 else:
1879 1880 return self.handle_normal(line,continue_prompt)
1880 1881
1881 1882 # If the rest of the line begins with an (in)equality, assginment or
1882 1883 # function call, we should not call _ofind but simply execute it.
1883 1884 # This avoids spurious geattr() accesses on objects upon assignment.
1884 1885 #
1885 1886 # It also allows users to assign to either alias or magic names true
1886 1887 # python variables (the magic/alias systems always take second seat to
1887 1888 # true python code).
1888 1889 if theRest and theRest[0] in '!=()':
1889 1890 return self.handle_normal(line,continue_prompt)
1890 1891
1891 1892 if oinfo is None:
1892 1893 # let's try to ensure that _oinfo is ONLY called when autocall is
1893 1894 # on. Since it has inevitable potential side effects, at least
1894 1895 # having autocall off should be a guarantee to the user that no
1895 1896 # weird things will happen.
1896 1897
1897 1898 if self.rc.autocall:
1898 1899 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1899 1900 else:
1900 1901 # in this case, all that's left is either an alias or
1901 1902 # processing the line normally.
1902 1903 if iFun in self.alias_table:
1903 1904 return self.handle_alias(line,continue_prompt,
1904 1905 pre,iFun,theRest)
1905 1906
1906 1907 else:
1907 1908 return self.handle_normal(line,continue_prompt)
1908 1909
1909 1910 if not oinfo['found']:
1910 1911 return self.handle_normal(line,continue_prompt)
1911 1912 else:
1912 1913 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1913 1914 if oinfo['isalias']:
1914 1915 return self.handle_alias(line,continue_prompt,
1915 1916 pre,iFun,theRest)
1916 1917
1917 1918 if (self.rc.autocall
1918 1919 and
1919 1920 (
1920 1921 #only consider exclusion re if not "," or ";" autoquoting
1921 1922 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2) or
1922 1923 (not self.re_exclude_auto.match(theRest)))
1923 1924 and
1924 1925 self.re_fun_name.match(iFun) and
1925 1926 callable(oinfo['obj'])) :
1926 1927 #print 'going auto' # dbg
1927 1928 return self.handle_auto(line,continue_prompt,
1928 1929 pre,iFun,theRest,oinfo['obj'])
1929 1930 else:
1930 1931 #print 'was callable?', callable(oinfo['obj']) # dbg
1931 1932 return self.handle_normal(line,continue_prompt)
1932 1933
1933 1934 # If we get here, we have a normal Python line. Log and return.
1934 1935 return self.handle_normal(line,continue_prompt)
1935 1936
1936 1937 def _prefilter_dumb(self, line, continue_prompt):
1937 1938 """simple prefilter function, for debugging"""
1938 1939 return self.handle_normal(line,continue_prompt)
1939 1940
1940 1941 # Set the default prefilter() function (this can be user-overridden)
1941 1942 prefilter = _prefilter
1942 1943
1943 1944 def handle_normal(self,line,continue_prompt=None,
1944 1945 pre=None,iFun=None,theRest=None):
1945 1946 """Handle normal input lines. Use as a template for handlers."""
1946 1947
1947 1948 # With autoindent on, we need some way to exit the input loop, and I
1948 1949 # don't want to force the user to have to backspace all the way to
1949 1950 # clear the line. The rule will be in this case, that either two
1950 1951 # lines of pure whitespace in a row, or a line of pure whitespace but
1951 1952 # of a size different to the indent level, will exit the input loop.
1952 1953
1953 1954 if (continue_prompt and self.autoindent and line.isspace() and
1954 1955 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
1955 1956 (self.buffer[-1]).isspace() )):
1956 1957 line = ''
1957 1958
1958 1959 self.log(line,continue_prompt)
1959 1960 return line
1960 1961
1961 1962 def handle_alias(self,line,continue_prompt=None,
1962 1963 pre=None,iFun=None,theRest=None):
1963 1964 """Handle alias input lines. """
1964 1965
1965 1966 # pre is needed, because it carries the leading whitespace. Otherwise
1966 1967 # aliases won't work in indented sections.
1967 1968 line_out = '%sipalias(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1968 1969 self.log(line_out,continue_prompt)
1969 1970 return line_out
1970 1971
1971 1972 def handle_shell_escape(self, line, continue_prompt=None,
1972 1973 pre=None,iFun=None,theRest=None):
1973 1974 """Execute the line in a shell, empty return value"""
1974 1975
1975 1976 #print 'line in :', `line` # dbg
1976 1977 # Example of a special handler. Others follow a similar pattern.
1977 1978 if line.lstrip().startswith('!!'):
1978 1979 # rewrite iFun/theRest to properly hold the call to %sx and
1979 1980 # the actual command to be executed, so handle_magic can work
1980 1981 # correctly
1981 1982 theRest = '%s %s' % (iFun[2:],theRest)
1982 1983 iFun = 'sx'
1983 1984 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
1984 1985 line.lstrip()[2:]),
1985 1986 continue_prompt,pre,iFun,theRest)
1986 1987 else:
1987 1988 cmd=line.lstrip().lstrip('!')
1988 1989 line_out = '%sipsystem(%s)' % (pre,make_quoted_expr(cmd))
1989 1990 # update cache/log and return
1990 1991 self.log(line_out,continue_prompt)
1991 1992 return line_out
1992 1993
1993 1994 def handle_magic(self, line, continue_prompt=None,
1994 1995 pre=None,iFun=None,theRest=None):
1995 1996 """Execute magic functions."""
1996 1997
1997 1998
1998 1999 cmd = '%sipmagic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1999 2000 self.log(cmd,continue_prompt)
2000 2001 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2001 2002 return cmd
2002 2003
2003 2004 def handle_auto(self, line, continue_prompt=None,
2004 2005 pre=None,iFun=None,theRest=None,obj=None):
2005 2006 """Hande lines which can be auto-executed, quoting if requested."""
2006 2007
2007 2008 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2008 2009
2009 2010 # This should only be active for single-line input!
2010 2011 if continue_prompt:
2011 2012 self.log(line,continue_prompt)
2012 2013 return line
2013 2014
2014 2015 auto_rewrite = True
2015 2016 if pre == self.ESC_QUOTE:
2016 2017 # Auto-quote splitting on whitespace
2017 2018 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2018 2019 elif pre == self.ESC_QUOTE2:
2019 2020 # Auto-quote whole string
2020 2021 newcmd = '%s("%s")' % (iFun,theRest)
2021 2022 else:
2022 2023 # Auto-paren.
2023 2024 # We only apply it to argument-less calls if the autocall
2024 2025 # parameter is set to 2. We only need to check that autocall is <
2025 2026 # 2, since this function isn't called unless it's at least 1.
2026 2027 if not theRest and (self.rc.autocall < 2):
2027 2028 newcmd = '%s %s' % (iFun,theRest)
2028 2029 auto_rewrite = False
2029 2030 else:
2030 2031 if theRest.startswith('['):
2031 2032 if hasattr(obj,'__getitem__'):
2032 2033 # Don't autocall in this case: item access for an object
2033 2034 # which is BOTH callable and implements __getitem__.
2034 2035 newcmd = '%s %s' % (iFun,theRest)
2035 2036 auto_rewrite = False
2036 2037 else:
2037 2038 # if the object doesn't support [] access, go ahead and
2038 2039 # autocall
2039 2040 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2040 2041 elif theRest.endswith(';'):
2041 2042 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2042 2043 else:
2043 2044 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2044 2045
2045 2046 if auto_rewrite:
2046 2047 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2047 2048 # log what is now valid Python, not the actual user input (without the
2048 2049 # final newline)
2049 2050 self.log(newcmd,continue_prompt)
2050 2051 return newcmd
2051 2052
2052 2053 def handle_help(self, line, continue_prompt=None,
2053 2054 pre=None,iFun=None,theRest=None):
2054 2055 """Try to get some help for the object.
2055 2056
2056 2057 obj? or ?obj -> basic information.
2057 2058 obj?? or ??obj -> more details.
2058 2059 """
2059 2060
2060 2061 # We need to make sure that we don't process lines which would be
2061 2062 # otherwise valid python, such as "x=1 # what?"
2062 2063 try:
2063 2064 codeop.compile_command(line)
2064 2065 except SyntaxError:
2065 2066 # We should only handle as help stuff which is NOT valid syntax
2066 2067 if line[0]==self.ESC_HELP:
2067 2068 line = line[1:]
2068 2069 elif line[-1]==self.ESC_HELP:
2069 2070 line = line[:-1]
2070 2071 self.log('#?'+line)
2071 2072 if line:
2072 2073 self.magic_pinfo(line)
2073 2074 else:
2074 2075 page(self.usage,screen_lines=self.rc.screen_length)
2075 2076 return '' # Empty string is needed here!
2076 2077 except:
2077 2078 # Pass any other exceptions through to the normal handler
2078 2079 return self.handle_normal(line,continue_prompt)
2079 2080 else:
2080 2081 # If the code compiles ok, we should handle it normally
2081 2082 return self.handle_normal(line,continue_prompt)
2082 2083
2083 2084 def handle_emacs(self,line,continue_prompt=None,
2084 2085 pre=None,iFun=None,theRest=None):
2085 2086 """Handle input lines marked by python-mode."""
2086 2087
2087 2088 # Currently, nothing is done. Later more functionality can be added
2088 2089 # here if needed.
2089 2090
2090 2091 # The input cache shouldn't be updated
2091 2092
2092 2093 return line
2093 2094
2094 2095 def mktempfile(self,data=None):
2095 2096 """Make a new tempfile and return its filename.
2096 2097
2097 2098 This makes a call to tempfile.mktemp, but it registers the created
2098 2099 filename internally so ipython cleans it up at exit time.
2099 2100
2100 2101 Optional inputs:
2101 2102
2102 2103 - data(None): if data is given, it gets written out to the temp file
2103 2104 immediately, and the file is closed again."""
2104 2105
2105 2106 filename = tempfile.mktemp('.py','ipython_edit_')
2106 2107 self.tempfiles.append(filename)
2107 2108
2108 2109 if data:
2109 2110 tmp_file = open(filename,'w')
2110 2111 tmp_file.write(data)
2111 2112 tmp_file.close()
2112 2113 return filename
2113 2114
2114 2115 def write(self,data):
2115 2116 """Write a string to the default output"""
2116 2117 Term.cout.write(data)
2117 2118
2118 2119 def write_err(self,data):
2119 2120 """Write a string to the default error output"""
2120 2121 Term.cerr.write(data)
2121 2122
2122 2123 def exit(self):
2123 2124 """Handle interactive exit.
2124 2125
2125 2126 This method sets the exit_now attribute."""
2126 2127
2127 2128 if self.rc.confirm_exit:
2128 2129 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2129 2130 self.exit_now = True
2130 2131 else:
2131 2132 self.exit_now = True
2132 2133 return self.exit_now
2133 2134
2134 2135 def safe_execfile(self,fname,*where,**kw):
2135 2136 fname = os.path.expanduser(fname)
2136 2137
2137 2138 # find things also in current directory
2138 2139 dname = os.path.dirname(fname)
2139 2140 if not sys.path.count(dname):
2140 2141 sys.path.append(dname)
2141 2142
2142 2143 try:
2143 2144 xfile = open(fname)
2144 2145 except:
2145 2146 print >> Term.cerr, \
2146 2147 'Could not open file <%s> for safe execution.' % fname
2147 2148 return None
2148 2149
2149 2150 kw.setdefault('islog',0)
2150 2151 kw.setdefault('quiet',1)
2151 2152 kw.setdefault('exit_ignore',0)
2152 2153 first = xfile.readline()
2153 2154 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2154 2155 xfile.close()
2155 2156 # line by line execution
2156 2157 if first.startswith(loghead) or kw['islog']:
2157 2158 print 'Loading log file <%s> one line at a time...' % fname
2158 2159 if kw['quiet']:
2159 2160 stdout_save = sys.stdout
2160 2161 sys.stdout = StringIO.StringIO()
2161 2162 try:
2162 2163 globs,locs = where[0:2]
2163 2164 except:
2164 2165 try:
2165 2166 globs = locs = where[0]
2166 2167 except:
2167 2168 globs = locs = globals()
2168 2169 badblocks = []
2169 2170
2170 2171 # we also need to identify indented blocks of code when replaying
2171 2172 # logs and put them together before passing them to an exec
2172 2173 # statement. This takes a bit of regexp and look-ahead work in the
2173 2174 # file. It's easiest if we swallow the whole thing in memory
2174 2175 # first, and manually walk through the lines list moving the
2175 2176 # counter ourselves.
2176 2177 indent_re = re.compile('\s+\S')
2177 2178 xfile = open(fname)
2178 2179 filelines = xfile.readlines()
2179 2180 xfile.close()
2180 2181 nlines = len(filelines)
2181 2182 lnum = 0
2182 2183 while lnum < nlines:
2183 2184 line = filelines[lnum]
2184 2185 lnum += 1
2185 2186 # don't re-insert logger status info into cache
2186 2187 if line.startswith('#log#'):
2187 2188 continue
2188 2189 else:
2189 2190 # build a block of code (maybe a single line) for execution
2190 2191 block = line
2191 2192 try:
2192 2193 next = filelines[lnum] # lnum has already incremented
2193 2194 except:
2194 2195 next = None
2195 2196 while next and indent_re.match(next):
2196 2197 block += next
2197 2198 lnum += 1
2198 2199 try:
2199 2200 next = filelines[lnum]
2200 2201 except:
2201 2202 next = None
2202 2203 # now execute the block of one or more lines
2203 2204 try:
2204 2205 exec block in globs,locs
2205 2206 except SystemExit:
2206 2207 pass
2207 2208 except:
2208 2209 badblocks.append(block.rstrip())
2209 2210 if kw['quiet']: # restore stdout
2210 2211 sys.stdout.close()
2211 2212 sys.stdout = stdout_save
2212 2213 print 'Finished replaying log file <%s>' % fname
2213 2214 if badblocks:
2214 2215 print >> sys.stderr, ('\nThe following lines/blocks in file '
2215 2216 '<%s> reported errors:' % fname)
2216 2217
2217 2218 for badline in badblocks:
2218 2219 print >> sys.stderr, badline
2219 2220 else: # regular file execution
2220 2221 try:
2221 2222 execfile(fname,*where)
2222 2223 except SyntaxError:
2223 2224 etype,evalue = sys.exc_info()[:2]
2224 2225 self.SyntaxTB(etype,evalue,[])
2225 2226 warn('Failure executing file: <%s>' % fname)
2226 2227 except SystemExit,status:
2227 2228 if not kw['exit_ignore']:
2228 2229 self.InteractiveTB()
2229 2230 warn('Failure executing file: <%s>' % fname)
2230 2231 except:
2231 2232 self.InteractiveTB()
2232 2233 warn('Failure executing file: <%s>' % fname)
2233 2234
2234 2235 #************************* end of file <iplib.py> *****************************
@@ -1,5066 +1,5067 b''
1 1 2006-01-24 Ville Vainio <vivainio@gmail.com>
2 2
3 3 * iplib.py, hooks.py: 'result_display' hook can return a non-None
4 4 value to manipulate resulting history entry.
5 5
6 * ipapi.py: Moved TryNext here from hooks.py, added
7 is_ipython_session() to determine whether we are running
8 inside an ipython session.
6 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
7 to instance methods of IPApi class, to make extending an embedded
8 IPython feasible. See ext_rehashdir.py for example usage.
9 9
10 10 * Merged 1071-1076 from banches/0.7.1
11 11
12
12 13 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
13 14
14 15 * tools/release (daystamp): Fix build tools to use the new
15 16 eggsetup.py script to build lightweight eggs.
16 17
17 18 * Applied changesets 1062 and 1064 before 0.7.1 release.
18 19
19 20 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
20 21 see the raw input history (without conversions like %ls ->
21 22 ipmagic("ls")). After a request from W. Stein, SAGE
22 23 (http://modular.ucsd.edu/sage) developer. This information is
23 24 stored in the input_hist_raw attribute of the IPython instance, so
24 25 developers can access it if needed (it's an InputList instance).
25 26
26 27 * Versionstring = 0.7.2.svn
27 28
28 29 * eggsetup.py: A separate script for constructing eggs, creates
29 30 proper launch scripts even on Windows (an .exe file in
30 31 \python24\scripts).
31 32
32 33 * ipapi.py: launch_new_instance, launch entry point needed for the
33 34 egg.
34 35
35 36 2006-01-23 Ville Vainio <vivainio@gmail.com>
36 37
37 38 * Added %cpaste magic for pasting python code
38 39
39 40 2006-01-22 Ville Vainio <vivainio@gmail.com>
40 41
41 42 * Merge from branches/0.7.1 into trunk, revs 1052-1057
42 43
43 44 * Versionstring = 0.7.2.svn
44 45
45 46 * eggsetup.py: A separate script for constructing eggs, creates
46 47 proper launch scripts even on Windows (an .exe file in
47 48 \python24\scripts).
48 49
49 50 * ipapi.py: launch_new_instance, launch entry point needed for the
50 51 egg.
51 52
52 53 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
53 54
54 55 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
55 56 %pfile foo would print the file for foo even if it was a binary.
56 57 Now, extensions '.so' and '.dll' are skipped.
57 58
58 59 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
59 60 bug, where macros would fail in all threaded modes. I'm not 100%
60 61 sure, so I'm going to put out an rc instead of making a release
61 62 today, and wait for feedback for at least a few days.
62 63
63 64 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
64 65 it...) the handling of pasting external code with autoindent on.
65 66 To get out of a multiline input, the rule will appear for most
66 67 users unchanged: two blank lines or change the indent level
67 68 proposed by IPython. But there is a twist now: you can
68 69 add/subtract only *one or two spaces*. If you add/subtract three
69 70 or more (unless you completely delete the line), IPython will
70 71 accept that line, and you'll need to enter a second one of pure
71 72 whitespace. I know it sounds complicated, but I can't find a
72 73 different solution that covers all the cases, with the right
73 74 heuristics. Hopefully in actual use, nobody will really notice
74 75 all these strange rules and things will 'just work'.
75 76
76 77 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
77 78
78 79 * IPython/iplib.py (interact): catch exceptions which can be
79 80 triggered asynchronously by signal handlers. Thanks to an
80 81 automatic crash report, submitted by Colin Kingsley
81 82 <tercel-AT-gentoo.org>.
82 83
83 84 2006-01-20 Ville Vainio <vivainio@gmail.com>
84 85
85 86 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
86 87 (%rehashdir, very useful, try it out) of how to extend ipython
87 88 with new magics. Also added Extensions dir to pythonpath to make
88 89 importing extensions easy.
89 90
90 91 * %store now complains when trying to store interactively declared
91 92 classes / instances of those classes.
92 93
93 94 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
94 95 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
95 96 if they exist, and ipy_user_conf.py with some defaults is created for
96 97 the user.
97 98
98 99 * Startup rehashing done by the config file, not InterpreterExec.
99 100 This means system commands are available even without selecting the
100 101 pysh profile. It's the sensible default after all.
101 102
102 103 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
103 104
104 105 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
105 106 multiline code with autoindent on working. But I am really not
106 107 sure, so this needs more testing. Will commit a debug-enabled
107 108 version for now, while I test it some more, so that Ville and
108 109 others may also catch any problems. Also made
109 110 self.indent_current_str() a method, to ensure that there's no
110 111 chance of the indent space count and the corresponding string
111 112 falling out of sync. All code needing the string should just call
112 113 the method.
113 114
114 115 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
115 116
116 117 * IPython/Magic.py (magic_edit): fix check for when users don't
117 118 save their output files, the try/except was in the wrong section.
118 119
119 120 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
120 121
121 122 * IPython/Magic.py (magic_run): fix __file__ global missing from
122 123 script's namespace when executed via %run. After a report by
123 124 Vivian.
124 125
125 126 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
126 127 when using python 2.4. The parent constructor changed in 2.4, and
127 128 we need to track it directly (we can't call it, as it messes up
128 129 readline and tab-completion inside our pdb would stop working).
129 130 After a bug report by R. Bernstein <rocky-AT-panix.com>.
130 131
131 132 2006-01-16 Ville Vainio <vivainio@gmail.com>
132 133
133 134 * Ipython/magic.py:Reverted back to old %edit functionality
134 135 that returns file contents on exit.
135 136
136 137 * IPython/path.py: Added Jason Orendorff's "path" module to
137 138 IPython tree, http://www.jorendorff.com/articles/python/path/.
138 139 You can get path objects conveniently through %sc, and !!, e.g.:
139 140 sc files=ls
140 141 for p in files.paths: # or files.p
141 142 print p,p.mtime
142 143
143 144 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
144 145 now work again without considering the exclusion regexp -
145 146 hence, things like ',foo my/path' turn to 'foo("my/path")'
146 147 instead of syntax error.
147 148
148 149
149 150 2006-01-14 Ville Vainio <vivainio@gmail.com>
150 151
151 152 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
152 153 ipapi decorators for python 2.4 users, options() provides access to rc
153 154 data.
154 155
155 156 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
156 157 as path separators (even on Linux ;-). Space character after
157 158 backslash (as yielded by tab completer) is still space;
158 159 "%cd long\ name" works as expected.
159 160
160 161 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
161 162 as "chain of command", with priority. API stays the same,
162 163 TryNext exception raised by a hook function signals that
163 164 current hook failed and next hook should try handling it, as
164 165 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
165 166 requested configurable display hook, which is now implemented.
166 167
167 168 2006-01-13 Ville Vainio <vivainio@gmail.com>
168 169
169 170 * IPython/platutils*.py: platform specific utility functions,
170 171 so far only set_term_title is implemented (change terminal
171 172 label in windowing systems). %cd now changes the title to
172 173 current dir.
173 174
174 175 * IPython/Release.py: Added myself to "authors" list,
175 176 had to create new files.
176 177
177 178 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
178 179 shell escape; not a known bug but had potential to be one in the
179 180 future.
180 181
181 182 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
182 183 extension API for IPython! See the module for usage example. Fix
183 184 OInspect for docstring-less magic functions.
184 185
185 186
186 187 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
187 188
188 189 * IPython/iplib.py (raw_input): temporarily deactivate all
189 190 attempts at allowing pasting of code with autoindent on. It
190 191 introduced bugs (reported by Prabhu) and I can't seem to find a
191 192 robust combination which works in all cases. Will have to revisit
192 193 later.
193 194
194 195 * IPython/genutils.py: remove isspace() function. We've dropped
195 196 2.2 compatibility, so it's OK to use the string method.
196 197
197 198 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
198 199
199 200 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
200 201 matching what NOT to autocall on, to include all python binary
201 202 operators (including things like 'and', 'or', 'is' and 'in').
202 203 Prompted by a bug report on 'foo & bar', but I realized we had
203 204 many more potential bug cases with other operators. The regexp is
204 205 self.re_exclude_auto, it's fairly commented.
205 206
206 207 2006-01-12 Ville Vainio <vivainio@gmail.com>
207 208
208 209 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
209 210 Prettified and hardened string/backslash quoting with ipsystem(),
210 211 ipalias() and ipmagic(). Now even \ characters are passed to
211 212 %magics, !shell escapes and aliases exactly as they are in the
212 213 ipython command line. Should improve backslash experience,
213 214 particularly in Windows (path delimiter for some commands that
214 215 won't understand '/'), but Unix benefits as well (regexps). %cd
215 216 magic still doesn't support backslash path delimiters, though. Also
216 217 deleted all pretense of supporting multiline command strings in
217 218 !system or %magic commands. Thanks to Jerry McRae for suggestions.
218 219
219 220 * doc/build_doc_instructions.txt added. Documentation on how to
220 221 use doc/update_manual.py, added yesterday. Both files contributed
221 222 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
222 223 doc/*.sh for deprecation at a later date.
223 224
224 225 * /ipython.py Added ipython.py to root directory for
225 226 zero-installation (tar xzvf ipython.tgz; cd ipython; python
226 227 ipython.py) and development convenience (no need to kee doing
227 228 "setup.py install" between changes).
228 229
229 230 * Made ! and !! shell escapes work (again) in multiline expressions:
230 231 if 1:
231 232 !ls
232 233 !!ls
233 234
234 235 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
235 236
236 237 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
237 238 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
238 239 module in case-insensitive installation. Was causing crashes
239 240 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
240 241
241 242 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
242 243 <marienz-AT-gentoo.org>, closes
243 244 http://www.scipy.net/roundup/ipython/issue51.
244 245
245 246 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
246 247
247 248 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the
248 249 problem of excessive CPU usage under *nix and keyboard lag under
249 250 win32.
250 251
251 252 2006-01-10 *** Released version 0.7.0
252 253
253 254 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
254 255
255 256 * IPython/Release.py (revision): tag version number to 0.7.0,
256 257 ready for release.
257 258
258 259 * IPython/Magic.py (magic_edit): Add print statement to %edit so
259 260 it informs the user of the name of the temp. file used. This can
260 261 help if you decide later to reuse that same file, so you know
261 262 where to copy the info from.
262 263
263 264 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
264 265
265 266 * setup_bdist_egg.py: little script to build an egg. Added
266 267 support in the release tools as well.
267 268
268 269 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
269 270
270 271 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
271 272 version selection (new -wxversion command line and ipythonrc
272 273 parameter). Patch contributed by Arnd Baecker
273 274 <arnd.baecker-AT-web.de>.
274 275
275 276 * IPython/iplib.py (embed_mainloop): fix tab-completion in
276 277 embedded instances, for variables defined at the interactive
277 278 prompt of the embedded ipython. Reported by Arnd.
278 279
279 280 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
280 281 it can be used as a (stateful) toggle, or with a direct parameter.
281 282
282 283 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
283 284 could be triggered in certain cases and cause the traceback
284 285 printer not to work.
285 286
286 287 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
287 288
288 289 * IPython/iplib.py (_should_recompile): Small fix, closes
289 290 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
290 291
291 292 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
292 293
293 294 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
294 295 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
295 296 Moad for help with tracking it down.
296 297
297 298 * IPython/iplib.py (handle_auto): fix autocall handling for
298 299 objects which support BOTH __getitem__ and __call__ (so that f [x]
299 300 is left alone, instead of becoming f([x]) automatically).
300 301
301 302 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
302 303 Ville's patch.
303 304
304 305 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
305 306
306 307 * IPython/iplib.py (handle_auto): changed autocall semantics to
307 308 include 'smart' mode, where the autocall transformation is NOT
308 309 applied if there are no arguments on the line. This allows you to
309 310 just type 'foo' if foo is a callable to see its internal form,
310 311 instead of having it called with no arguments (typically a
311 312 mistake). The old 'full' autocall still exists: for that, you
312 313 need to set the 'autocall' parameter to 2 in your ipythonrc file.
313 314
314 315 * IPython/completer.py (Completer.attr_matches): add
315 316 tab-completion support for Enthoughts' traits. After a report by
316 317 Arnd and a patch by Prabhu.
317 318
318 319 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
319 320
320 321 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
321 322 Schmolck's patch to fix inspect.getinnerframes().
322 323
323 324 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
324 325 for embedded instances, regarding handling of namespaces and items
325 326 added to the __builtin__ one. Multiple embedded instances and
326 327 recursive embeddings should work better now (though I'm not sure
327 328 I've got all the corner cases fixed, that code is a bit of a brain
328 329 twister).
329 330
330 331 * IPython/Magic.py (magic_edit): added support to edit in-memory
331 332 macros (automatically creates the necessary temp files). %edit
332 333 also doesn't return the file contents anymore, it's just noise.
333 334
334 335 * IPython/completer.py (Completer.attr_matches): revert change to
335 336 complete only on attributes listed in __all__. I realized it
336 337 cripples the tab-completion system as a tool for exploring the
337 338 internals of unknown libraries (it renders any non-__all__
338 339 attribute off-limits). I got bit by this when trying to see
339 340 something inside the dis module.
340 341
341 342 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
342 343
343 344 * IPython/iplib.py (InteractiveShell.__init__): add .meta
344 345 namespace for users and extension writers to hold data in. This
345 346 follows the discussion in
346 347 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
347 348
348 349 * IPython/completer.py (IPCompleter.complete): small patch to help
349 350 tab-completion under Emacs, after a suggestion by John Barnard
350 351 <barnarj-AT-ccf.org>.
351 352
352 353 * IPython/Magic.py (Magic.extract_input_slices): added support for
353 354 the slice notation in magics to use N-M to represent numbers N...M
354 355 (closed endpoints). This is used by %macro and %save.
355 356
356 357 * IPython/completer.py (Completer.attr_matches): for modules which
357 358 define __all__, complete only on those. After a patch by Jeffrey
358 359 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
359 360 speed up this routine.
360 361
361 362 * IPython/Logger.py (Logger.log): fix a history handling bug. I
362 363 don't know if this is the end of it, but the behavior now is
363 364 certainly much more correct. Note that coupled with macros,
364 365 slightly surprising (at first) behavior may occur: a macro will in
365 366 general expand to multiple lines of input, so upon exiting, the
366 367 in/out counters will both be bumped by the corresponding amount
367 368 (as if the macro's contents had been typed interactively). Typing
368 369 %hist will reveal the intermediate (silently processed) lines.
369 370
370 371 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
371 372 pickle to fail (%run was overwriting __main__ and not restoring
372 373 it, but pickle relies on __main__ to operate).
373 374
374 375 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
375 376 using properties, but forgot to make the main InteractiveShell
376 377 class a new-style class. Properties fail silently, and
377 378 misteriously, with old-style class (getters work, but
378 379 setters don't do anything).
379 380
380 381 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
381 382
382 383 * IPython/Magic.py (magic_history): fix history reporting bug (I
383 384 know some nasties are still there, I just can't seem to find a
384 385 reproducible test case to track them down; the input history is
385 386 falling out of sync...)
386 387
387 388 * IPython/iplib.py (handle_shell_escape): fix bug where both
388 389 aliases and system accesses where broken for indented code (such
389 390 as loops).
390 391
391 392 * IPython/genutils.py (shell): fix small but critical bug for
392 393 win32 system access.
393 394
394 395 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
395 396
396 397 * IPython/iplib.py (showtraceback): remove use of the
397 398 sys.last_{type/value/traceback} structures, which are non
398 399 thread-safe.
399 400 (_prefilter): change control flow to ensure that we NEVER
400 401 introspect objects when autocall is off. This will guarantee that
401 402 having an input line of the form 'x.y', where access to attribute
402 403 'y' has side effects, doesn't trigger the side effect TWICE. It
403 404 is important to note that, with autocall on, these side effects
404 405 can still happen.
405 406 (ipsystem): new builtin, to complete the ip{magic/alias/system}
406 407 trio. IPython offers these three kinds of special calls which are
407 408 not python code, and it's a good thing to have their call method
408 409 be accessible as pure python functions (not just special syntax at
409 410 the command line). It gives us a better internal implementation
410 411 structure, as well as exposing these for user scripting more
411 412 cleanly.
412 413
413 414 * IPython/macro.py (Macro.__init__): moved macros to a standalone
414 415 file. Now that they'll be more likely to be used with the
415 416 persistance system (%store), I want to make sure their module path
416 417 doesn't change in the future, so that we don't break things for
417 418 users' persisted data.
418 419
419 420 * IPython/iplib.py (autoindent_update): move indentation
420 421 management into the _text_ processing loop, not the keyboard
421 422 interactive one. This is necessary to correctly process non-typed
422 423 multiline input (such as macros).
423 424
424 425 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
425 426 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
426 427 which was producing problems in the resulting manual.
427 428 (magic_whos): improve reporting of instances (show their class,
428 429 instead of simply printing 'instance' which isn't terribly
429 430 informative).
430 431
431 432 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
432 433 (minor mods) to support network shares under win32.
433 434
434 435 * IPython/winconsole.py (get_console_size): add new winconsole
435 436 module and fixes to page_dumb() to improve its behavior under
436 437 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
437 438
438 439 * IPython/Magic.py (Macro): simplified Macro class to just
439 440 subclass list. We've had only 2.2 compatibility for a very long
440 441 time, yet I was still avoiding subclassing the builtin types. No
441 442 more (I'm also starting to use properties, though I won't shift to
442 443 2.3-specific features quite yet).
443 444 (magic_store): added Ville's patch for lightweight variable
444 445 persistence, after a request on the user list by Matt Wilkie
445 446 <maphew-AT-gmail.com>. The new %store magic's docstring has full
446 447 details.
447 448
448 449 * IPython/iplib.py (InteractiveShell.post_config_initialization):
449 450 changed the default logfile name from 'ipython.log' to
450 451 'ipython_log.py'. These logs are real python files, and now that
451 452 we have much better multiline support, people are more likely to
452 453 want to use them as such. Might as well name them correctly.
453 454
454 455 * IPython/Magic.py: substantial cleanup. While we can't stop
455 456 using magics as mixins, due to the existing customizations 'out
456 457 there' which rely on the mixin naming conventions, at least I
457 458 cleaned out all cross-class name usage. So once we are OK with
458 459 breaking compatibility, the two systems can be separated.
459 460
460 461 * IPython/Logger.py: major cleanup. This one is NOT a mixin
461 462 anymore, and the class is a fair bit less hideous as well. New
462 463 features were also introduced: timestamping of input, and logging
463 464 of output results. These are user-visible with the -t and -o
464 465 options to %logstart. Closes
465 466 http://www.scipy.net/roundup/ipython/issue11 and a request by
466 467 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
467 468
468 469 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
469 470
470 471 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
471 472 better hadnle backslashes in paths. See the thread 'More Windows
472 473 questions part 2 - \/ characters revisited' on the iypthon user
473 474 list:
474 475 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
475 476
476 477 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
477 478
478 479 (InteractiveShell.__init__): change threaded shells to not use the
479 480 ipython crash handler. This was causing more problems than not,
480 481 as exceptions in the main thread (GUI code, typically) would
481 482 always show up as a 'crash', when they really weren't.
482 483
483 484 The colors and exception mode commands (%colors/%xmode) have been
484 485 synchronized to also take this into account, so users can get
485 486 verbose exceptions for their threaded code as well. I also added
486 487 support for activating pdb inside this exception handler as well,
487 488 so now GUI authors can use IPython's enhanced pdb at runtime.
488 489
489 490 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
490 491 true by default, and add it to the shipped ipythonrc file. Since
491 492 this asks the user before proceeding, I think it's OK to make it
492 493 true by default.
493 494
494 495 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
495 496 of the previous special-casing of input in the eval loop. I think
496 497 this is cleaner, as they really are commands and shouldn't have
497 498 a special role in the middle of the core code.
498 499
499 500 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
500 501
501 502 * IPython/iplib.py (edit_syntax_error): added support for
502 503 automatically reopening the editor if the file had a syntax error
503 504 in it. Thanks to scottt who provided the patch at:
504 505 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
505 506 version committed).
506 507
507 508 * IPython/iplib.py (handle_normal): add suport for multi-line
508 509 input with emtpy lines. This fixes
509 510 http://www.scipy.net/roundup/ipython/issue43 and a similar
510 511 discussion on the user list.
511 512
512 513 WARNING: a behavior change is necessarily introduced to support
513 514 blank lines: now a single blank line with whitespace does NOT
514 515 break the input loop, which means that when autoindent is on, by
515 516 default hitting return on the next (indented) line does NOT exit.
516 517
517 518 Instead, to exit a multiline input you can either have:
518 519
519 520 - TWO whitespace lines (just hit return again), or
520 521 - a single whitespace line of a different length than provided
521 522 by the autoindent (add or remove a space).
522 523
523 524 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
524 525 module to better organize all readline-related functionality.
525 526 I've deleted FlexCompleter and put all completion clases here.
526 527
527 528 * IPython/iplib.py (raw_input): improve indentation management.
528 529 It is now possible to paste indented code with autoindent on, and
529 530 the code is interpreted correctly (though it still looks bad on
530 531 screen, due to the line-oriented nature of ipython).
531 532 (MagicCompleter.complete): change behavior so that a TAB key on an
532 533 otherwise empty line actually inserts a tab, instead of completing
533 534 on the entire global namespace. This makes it easier to use the
534 535 TAB key for indentation. After a request by Hans Meine
535 536 <hans_meine-AT-gmx.net>
536 537 (_prefilter): add support so that typing plain 'exit' or 'quit'
537 538 does a sensible thing. Originally I tried to deviate as little as
538 539 possible from the default python behavior, but even that one may
539 540 change in this direction (thread on python-dev to that effect).
540 541 Regardless, ipython should do the right thing even if CPython's
541 542 '>>>' prompt doesn't.
542 543 (InteractiveShell): removed subclassing code.InteractiveConsole
543 544 class. By now we'd overridden just about all of its methods: I've
544 545 copied the remaining two over, and now ipython is a standalone
545 546 class. This will provide a clearer picture for the chainsaw
546 547 branch refactoring.
547 548
548 549 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
549 550
550 551 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
551 552 failures for objects which break when dir() is called on them.
552 553
553 554 * IPython/FlexCompleter.py (Completer.__init__): Added support for
554 555 distinct local and global namespaces in the completer API. This
555 556 change allows us top properly handle completion with distinct
556 557 scopes, including in embedded instances (this had never really
557 558 worked correctly).
558 559
559 560 Note: this introduces a change in the constructor for
560 561 MagicCompleter, as a new global_namespace parameter is now the
561 562 second argument (the others were bumped one position).
562 563
563 564 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
564 565
565 566 * IPython/iplib.py (embed_mainloop): fix tab-completion in
566 567 embedded instances (which can be done now thanks to Vivian's
567 568 frame-handling fixes for pdb).
568 569 (InteractiveShell.__init__): Fix namespace handling problem in
569 570 embedded instances. We were overwriting __main__ unconditionally,
570 571 and this should only be done for 'full' (non-embedded) IPython;
571 572 embedded instances must respect the caller's __main__. Thanks to
572 573 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
573 574
574 575 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
575 576
576 577 * setup.py: added download_url to setup(). This registers the
577 578 download address at PyPI, which is not only useful to humans
578 579 browsing the site, but is also picked up by setuptools (the Eggs
579 580 machinery). Thanks to Ville and R. Kern for the info/discussion
580 581 on this.
581 582
582 583 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
583 584
584 585 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
585 586 This brings a lot of nice functionality to the pdb mode, which now
586 587 has tab-completion, syntax highlighting, and better stack handling
587 588 than before. Many thanks to Vivian De Smedt
588 589 <vivian-AT-vdesmedt.com> for the original patches.
589 590
590 591 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
591 592
592 593 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
593 594 sequence to consistently accept the banner argument. The
594 595 inconsistency was tripping SAGE, thanks to Gary Zablackis
595 596 <gzabl-AT-yahoo.com> for the report.
596 597
597 598 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
598 599
599 600 * IPython/iplib.py (InteractiveShell.post_config_initialization):
600 601 Fix bug where a naked 'alias' call in the ipythonrc file would
601 602 cause a crash. Bug reported by Jorgen Stenarson.
602 603
603 604 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
604 605
605 606 * IPython/ipmaker.py (make_IPython): cleanups which should improve
606 607 startup time.
607 608
608 609 * IPython/iplib.py (runcode): my globals 'fix' for embedded
609 610 instances had introduced a bug with globals in normal code. Now
610 611 it's working in all cases.
611 612
612 613 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
613 614 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
614 615 has been introduced to set the default case sensitivity of the
615 616 searches. Users can still select either mode at runtime on a
616 617 per-search basis.
617 618
618 619 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
619 620
620 621 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
621 622 attributes in wildcard searches for subclasses. Modified version
622 623 of a patch by Jorgen.
623 624
624 625 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
625 626
626 627 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
627 628 embedded instances. I added a user_global_ns attribute to the
628 629 InteractiveShell class to handle this.
629 630
630 631 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
631 632
632 633 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
633 634 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
634 635 (reported under win32, but may happen also in other platforms).
635 636 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
636 637
637 638 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
638 639
639 640 * IPython/Magic.py (magic_psearch): new support for wildcard
640 641 patterns. Now, typing ?a*b will list all names which begin with a
641 642 and end in b, for example. The %psearch magic has full
642 643 docstrings. Many thanks to JΓΆrgen Stenarson
643 644 <jorgen.stenarson-AT-bostream.nu>, author of the patches
644 645 implementing this functionality.
645 646
646 647 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
647 648
648 649 * Manual: fixed long-standing annoyance of double-dashes (as in
649 650 --prefix=~, for example) being stripped in the HTML version. This
650 651 is a latex2html bug, but a workaround was provided. Many thanks
651 652 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
652 653 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
653 654 rolling. This seemingly small issue had tripped a number of users
654 655 when first installing, so I'm glad to see it gone.
655 656
656 657 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
657 658
658 659 * IPython/Extensions/numeric_formats.py: fix missing import,
659 660 reported by Stephen Walton.
660 661
661 662 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
662 663
663 664 * IPython/demo.py: finish demo module, fully documented now.
664 665
665 666 * IPython/genutils.py (file_read): simple little utility to read a
666 667 file and ensure it's closed afterwards.
667 668
668 669 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
669 670
670 671 * IPython/demo.py (Demo.__init__): added support for individually
671 672 tagging blocks for automatic execution.
672 673
673 674 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
674 675 syntax-highlighted python sources, requested by John.
675 676
676 677 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
677 678
678 679 * IPython/demo.py (Demo.again): fix bug where again() blocks after
679 680 finishing.
680 681
681 682 * IPython/genutils.py (shlex_split): moved from Magic to here,
682 683 where all 2.2 compatibility stuff lives. I needed it for demo.py.
683 684
684 685 * IPython/demo.py (Demo.__init__): added support for silent
685 686 blocks, improved marks as regexps, docstrings written.
686 687 (Demo.__init__): better docstring, added support for sys.argv.
687 688
688 689 * IPython/genutils.py (marquee): little utility used by the demo
689 690 code, handy in general.
690 691
691 692 * IPython/demo.py (Demo.__init__): new class for interactive
692 693 demos. Not documented yet, I just wrote it in a hurry for
693 694 scipy'05. Will docstring later.
694 695
695 696 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
696 697
697 698 * IPython/Shell.py (sigint_handler): Drastic simplification which
698 699 also seems to make Ctrl-C work correctly across threads! This is
699 700 so simple, that I can't beleive I'd missed it before. Needs more
700 701 testing, though.
701 702 (KBINT): Never mind, revert changes. I'm sure I'd tried something
702 703 like this before...
703 704
704 705 * IPython/genutils.py (get_home_dir): add protection against
705 706 non-dirs in win32 registry.
706 707
707 708 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
708 709 bug where dict was mutated while iterating (pysh crash).
709 710
710 711 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
711 712
712 713 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
713 714 spurious newlines added by this routine. After a report by
714 715 F. Mantegazza.
715 716
716 717 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
717 718
718 719 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
719 720 calls. These were a leftover from the GTK 1.x days, and can cause
720 721 problems in certain cases (after a report by John Hunter).
721 722
722 723 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
723 724 os.getcwd() fails at init time. Thanks to patch from David Remahl
724 725 <chmod007-AT-mac.com>.
725 726 (InteractiveShell.__init__): prevent certain special magics from
726 727 being shadowed by aliases. Closes
727 728 http://www.scipy.net/roundup/ipython/issue41.
728 729
729 730 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
730 731
731 732 * IPython/iplib.py (InteractiveShell.complete): Added new
732 733 top-level completion method to expose the completion mechanism
733 734 beyond readline-based environments.
734 735
735 736 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
736 737
737 738 * tools/ipsvnc (svnversion): fix svnversion capture.
738 739
739 740 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
740 741 attribute to self, which was missing. Before, it was set by a
741 742 routine which in certain cases wasn't being called, so the
742 743 instance could end up missing the attribute. This caused a crash.
743 744 Closes http://www.scipy.net/roundup/ipython/issue40.
744 745
745 746 2005-08-16 Fernando Perez <fperez@colorado.edu>
746 747
747 748 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
748 749 contains non-string attribute. Closes
749 750 http://www.scipy.net/roundup/ipython/issue38.
750 751
751 752 2005-08-14 Fernando Perez <fperez@colorado.edu>
752 753
753 754 * tools/ipsvnc: Minor improvements, to add changeset info.
754 755
755 756 2005-08-12 Fernando Perez <fperez@colorado.edu>
756 757
757 758 * IPython/iplib.py (runsource): remove self.code_to_run_src
758 759 attribute. I realized this is nothing more than
759 760 '\n'.join(self.buffer), and having the same data in two different
760 761 places is just asking for synchronization bugs. This may impact
761 762 people who have custom exception handlers, so I need to warn
762 763 ipython-dev about it (F. Mantegazza may use them).
763 764
764 765 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
765 766
766 767 * IPython/genutils.py: fix 2.2 compatibility (generators)
767 768
768 769 2005-07-18 Fernando Perez <fperez@colorado.edu>
769 770
770 771 * IPython/genutils.py (get_home_dir): fix to help users with
771 772 invalid $HOME under win32.
772 773
773 774 2005-07-17 Fernando Perez <fperez@colorado.edu>
774 775
775 776 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
776 777 some old hacks and clean up a bit other routines; code should be
777 778 simpler and a bit faster.
778 779
779 780 * IPython/iplib.py (interact): removed some last-resort attempts
780 781 to survive broken stdout/stderr. That code was only making it
781 782 harder to abstract out the i/o (necessary for gui integration),
782 783 and the crashes it could prevent were extremely rare in practice
783 784 (besides being fully user-induced in a pretty violent manner).
784 785
785 786 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
786 787 Nothing major yet, but the code is simpler to read; this should
787 788 make it easier to do more serious modifications in the future.
788 789
789 790 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
790 791 which broke in .15 (thanks to a report by Ville).
791 792
792 793 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
793 794 be quite correct, I know next to nothing about unicode). This
794 795 will allow unicode strings to be used in prompts, amongst other
795 796 cases. It also will prevent ipython from crashing when unicode
796 797 shows up unexpectedly in many places. If ascii encoding fails, we
797 798 assume utf_8. Currently the encoding is not a user-visible
798 799 setting, though it could be made so if there is demand for it.
799 800
800 801 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
801 802
802 803 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
803 804
804 805 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
805 806
806 807 * IPython/genutils.py: Add 2.2 compatibility here, so all other
807 808 code can work transparently for 2.2/2.3.
808 809
809 810 2005-07-16 Fernando Perez <fperez@colorado.edu>
810 811
811 812 * IPython/ultraTB.py (ExceptionColors): Make a global variable
812 813 out of the color scheme table used for coloring exception
813 814 tracebacks. This allows user code to add new schemes at runtime.
814 815 This is a minimally modified version of the patch at
815 816 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
816 817 for the contribution.
817 818
818 819 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
819 820 slightly modified version of the patch in
820 821 http://www.scipy.net/roundup/ipython/issue34, which also allows me
821 822 to remove the previous try/except solution (which was costlier).
822 823 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
823 824
824 825 2005-06-08 Fernando Perez <fperez@colorado.edu>
825 826
826 827 * IPython/iplib.py (write/write_err): Add methods to abstract all
827 828 I/O a bit more.
828 829
829 830 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
830 831 warning, reported by Aric Hagberg, fix by JD Hunter.
831 832
832 833 2005-06-02 *** Released version 0.6.15
833 834
834 835 2005-06-01 Fernando Perez <fperez@colorado.edu>
835 836
836 837 * IPython/iplib.py (MagicCompleter.file_matches): Fix
837 838 tab-completion of filenames within open-quoted strings. Note that
838 839 this requires that in ~/.ipython/ipythonrc, users change the
839 840 readline delimiters configuration to read:
840 841
841 842 readline_remove_delims -/~
842 843
843 844
844 845 2005-05-31 *** Released version 0.6.14
845 846
846 847 2005-05-29 Fernando Perez <fperez@colorado.edu>
847 848
848 849 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
849 850 with files not on the filesystem. Reported by Eliyahu Sandler
850 851 <eli@gondolin.net>
851 852
852 853 2005-05-22 Fernando Perez <fperez@colorado.edu>
853 854
854 855 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
855 856 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
856 857
857 858 2005-05-19 Fernando Perez <fperez@colorado.edu>
858 859
859 860 * IPython/iplib.py (safe_execfile): close a file which could be
860 861 left open (causing problems in win32, which locks open files).
861 862 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
862 863
863 864 2005-05-18 Fernando Perez <fperez@colorado.edu>
864 865
865 866 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
866 867 keyword arguments correctly to safe_execfile().
867 868
868 869 2005-05-13 Fernando Perez <fperez@colorado.edu>
869 870
870 871 * ipython.1: Added info about Qt to manpage, and threads warning
871 872 to usage page (invoked with --help).
872 873
873 874 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
874 875 new matcher (it goes at the end of the priority list) to do
875 876 tab-completion on named function arguments. Submitted by George
876 877 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
877 878 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
878 879 for more details.
879 880
880 881 * IPython/Magic.py (magic_run): Added new -e flag to ignore
881 882 SystemExit exceptions in the script being run. Thanks to a report
882 883 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
883 884 producing very annoying behavior when running unit tests.
884 885
885 886 2005-05-12 Fernando Perez <fperez@colorado.edu>
886 887
887 888 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
888 889 which I'd broken (again) due to a changed regexp. In the process,
889 890 added ';' as an escape to auto-quote the whole line without
890 891 splitting its arguments. Thanks to a report by Jerry McRae
891 892 <qrs0xyc02-AT-sneakemail.com>.
892 893
893 894 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
894 895 possible crashes caused by a TokenError. Reported by Ed Schofield
895 896 <schofield-AT-ftw.at>.
896 897
897 898 2005-05-06 Fernando Perez <fperez@colorado.edu>
898 899
899 900 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
900 901
901 902 2005-04-29 Fernando Perez <fperez@colorado.edu>
902 903
903 904 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
904 905 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
905 906 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
906 907 which provides support for Qt interactive usage (similar to the
907 908 existing one for WX and GTK). This had been often requested.
908 909
909 910 2005-04-14 *** Released version 0.6.13
910 911
911 912 2005-04-08 Fernando Perez <fperez@colorado.edu>
912 913
913 914 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
914 915 from _ofind, which gets called on almost every input line. Now,
915 916 we only try to get docstrings if they are actually going to be
916 917 used (the overhead of fetching unnecessary docstrings can be
917 918 noticeable for certain objects, such as Pyro proxies).
918 919
919 920 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
920 921 for completers. For some reason I had been passing them the state
921 922 variable, which completers never actually need, and was in
922 923 conflict with the rlcompleter API. Custom completers ONLY need to
923 924 take the text parameter.
924 925
925 926 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
926 927 work correctly in pysh. I've also moved all the logic which used
927 928 to be in pysh.py here, which will prevent problems with future
928 929 upgrades. However, this time I must warn users to update their
929 930 pysh profile to include the line
930 931
931 932 import_all IPython.Extensions.InterpreterExec
932 933
933 934 because otherwise things won't work for them. They MUST also
934 935 delete pysh.py and the line
935 936
936 937 execfile pysh.py
937 938
938 939 from their ipythonrc-pysh.
939 940
940 941 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
941 942 robust in the face of objects whose dir() returns non-strings
942 943 (which it shouldn't, but some broken libs like ITK do). Thanks to
943 944 a patch by John Hunter (implemented differently, though). Also
944 945 minor improvements by using .extend instead of + on lists.
945 946
946 947 * pysh.py:
947 948
948 949 2005-04-06 Fernando Perez <fperez@colorado.edu>
949 950
950 951 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
951 952 by default, so that all users benefit from it. Those who don't
952 953 want it can still turn it off.
953 954
954 955 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
955 956 config file, I'd forgotten about this, so users were getting it
956 957 off by default.
957 958
958 959 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
959 960 consistency. Now magics can be called in multiline statements,
960 961 and python variables can be expanded in magic calls via $var.
961 962 This makes the magic system behave just like aliases or !system
962 963 calls.
963 964
964 965 2005-03-28 Fernando Perez <fperez@colorado.edu>
965 966
966 967 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
967 968 expensive string additions for building command. Add support for
968 969 trailing ';' when autocall is used.
969 970
970 971 2005-03-26 Fernando Perez <fperez@colorado.edu>
971 972
972 973 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
973 974 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
974 975 ipython.el robust against prompts with any number of spaces
975 976 (including 0) after the ':' character.
976 977
977 978 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
978 979 continuation prompt, which misled users to think the line was
979 980 already indented. Closes debian Bug#300847, reported to me by
980 981 Norbert Tretkowski <tretkowski-AT-inittab.de>.
981 982
982 983 2005-03-23 Fernando Perez <fperez@colorado.edu>
983 984
984 985 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
985 986 properly aligned if they have embedded newlines.
986 987
987 988 * IPython/iplib.py (runlines): Add a public method to expose
988 989 IPython's code execution machinery, so that users can run strings
989 990 as if they had been typed at the prompt interactively.
990 991 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
991 992 methods which can call the system shell, but with python variable
992 993 expansion. The three such methods are: __IPYTHON__.system,
993 994 .getoutput and .getoutputerror. These need to be documented in a
994 995 'public API' section (to be written) of the manual.
995 996
996 997 2005-03-20 Fernando Perez <fperez@colorado.edu>
997 998
998 999 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
999 1000 for custom exception handling. This is quite powerful, and it
1000 1001 allows for user-installable exception handlers which can trap
1001 1002 custom exceptions at runtime and treat them separately from
1002 1003 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
1003 1004 Mantegazza <mantegazza-AT-ill.fr>.
1004 1005 (InteractiveShell.set_custom_completer): public API function to
1005 1006 add new completers at runtime.
1006 1007
1007 1008 2005-03-19 Fernando Perez <fperez@colorado.edu>
1008 1009
1009 1010 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
1010 1011 allow objects which provide their docstrings via non-standard
1011 1012 mechanisms (like Pyro proxies) to still be inspected by ipython's
1012 1013 ? system.
1013 1014
1014 1015 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
1015 1016 automatic capture system. I tried quite hard to make it work
1016 1017 reliably, and simply failed. I tried many combinations with the
1017 1018 subprocess module, but eventually nothing worked in all needed
1018 1019 cases (not blocking stdin for the child, duplicating stdout
1019 1020 without blocking, etc). The new %sc/%sx still do capture to these
1020 1021 magical list/string objects which make shell use much more
1021 1022 conveninent, so not all is lost.
1022 1023
1023 1024 XXX - FIX MANUAL for the change above!
1024 1025
1025 1026 (runsource): I copied code.py's runsource() into ipython to modify
1026 1027 it a bit. Now the code object and source to be executed are
1027 1028 stored in ipython. This makes this info accessible to third-party
1028 1029 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
1029 1030 Mantegazza <mantegazza-AT-ill.fr>.
1030 1031
1031 1032 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
1032 1033 history-search via readline (like C-p/C-n). I'd wanted this for a
1033 1034 long time, but only recently found out how to do it. For users
1034 1035 who already have their ipythonrc files made and want this, just
1035 1036 add:
1036 1037
1037 1038 readline_parse_and_bind "\e[A": history-search-backward
1038 1039 readline_parse_and_bind "\e[B": history-search-forward
1039 1040
1040 1041 2005-03-18 Fernando Perez <fperez@colorado.edu>
1041 1042
1042 1043 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
1043 1044 LSString and SList classes which allow transparent conversions
1044 1045 between list mode and whitespace-separated string.
1045 1046 (magic_r): Fix recursion problem in %r.
1046 1047
1047 1048 * IPython/genutils.py (LSString): New class to be used for
1048 1049 automatic storage of the results of all alias/system calls in _o
1049 1050 and _e (stdout/err). These provide a .l/.list attribute which
1050 1051 does automatic splitting on newlines. This means that for most
1051 1052 uses, you'll never need to do capturing of output with %sc/%sx
1052 1053 anymore, since ipython keeps this always done for you. Note that
1053 1054 only the LAST results are stored, the _o/e variables are
1054 1055 overwritten on each call. If you need to save their contents
1055 1056 further, simply bind them to any other name.
1056 1057
1057 1058 2005-03-17 Fernando Perez <fperez@colorado.edu>
1058 1059
1059 1060 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
1060 1061 prompt namespace handling.
1061 1062
1062 1063 2005-03-16 Fernando Perez <fperez@colorado.edu>
1063 1064
1064 1065 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
1065 1066 classic prompts to be '>>> ' (final space was missing, and it
1066 1067 trips the emacs python mode).
1067 1068 (BasePrompt.__str__): Added safe support for dynamic prompt
1068 1069 strings. Now you can set your prompt string to be '$x', and the
1069 1070 value of x will be printed from your interactive namespace. The
1070 1071 interpolation syntax includes the full Itpl support, so
1071 1072 ${foo()+x+bar()} is a valid prompt string now, and the function
1072 1073 calls will be made at runtime.
1073 1074
1074 1075 2005-03-15 Fernando Perez <fperez@colorado.edu>
1075 1076
1076 1077 * IPython/Magic.py (magic_history): renamed %hist to %history, to
1077 1078 avoid name clashes in pylab. %hist still works, it just forwards
1078 1079 the call to %history.
1079 1080
1080 1081 2005-03-02 *** Released version 0.6.12
1081 1082
1082 1083 2005-03-02 Fernando Perez <fperez@colorado.edu>
1083 1084
1084 1085 * IPython/iplib.py (handle_magic): log magic calls properly as
1085 1086 ipmagic() function calls.
1086 1087
1087 1088 * IPython/Magic.py (magic_time): Improved %time to support
1088 1089 statements and provide wall-clock as well as CPU time.
1089 1090
1090 1091 2005-02-27 Fernando Perez <fperez@colorado.edu>
1091 1092
1092 1093 * IPython/hooks.py: New hooks module, to expose user-modifiable
1093 1094 IPython functionality in a clean manner. For now only the editor
1094 1095 hook is actually written, and other thigns which I intend to turn
1095 1096 into proper hooks aren't yet there. The display and prefilter
1096 1097 stuff, for example, should be hooks. But at least now the
1097 1098 framework is in place, and the rest can be moved here with more
1098 1099 time later. IPython had had a .hooks variable for a long time for
1099 1100 this purpose, but I'd never actually used it for anything.
1100 1101
1101 1102 2005-02-26 Fernando Perez <fperez@colorado.edu>
1102 1103
1103 1104 * IPython/ipmaker.py (make_IPython): make the default ipython
1104 1105 directory be called _ipython under win32, to follow more the
1105 1106 naming peculiarities of that platform (where buggy software like
1106 1107 Visual Sourcesafe breaks with .named directories). Reported by
1107 1108 Ville Vainio.
1108 1109
1109 1110 2005-02-23 Fernando Perez <fperez@colorado.edu>
1110 1111
1111 1112 * IPython/iplib.py (InteractiveShell.__init__): removed a few
1112 1113 auto_aliases for win32 which were causing problems. Users can
1113 1114 define the ones they personally like.
1114 1115
1115 1116 2005-02-21 Fernando Perez <fperez@colorado.edu>
1116 1117
1117 1118 * IPython/Magic.py (magic_time): new magic to time execution of
1118 1119 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
1119 1120
1120 1121 2005-02-19 Fernando Perez <fperez@colorado.edu>
1121 1122
1122 1123 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
1123 1124 into keys (for prompts, for example).
1124 1125
1125 1126 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
1126 1127 prompts in case users want them. This introduces a small behavior
1127 1128 change: ipython does not automatically add a space to all prompts
1128 1129 anymore. To get the old prompts with a space, users should add it
1129 1130 manually to their ipythonrc file, so for example prompt_in1 should
1130 1131 now read 'In [\#]: ' instead of 'In [\#]:'.
1131 1132 (BasePrompt.__init__): New option prompts_pad_left (only in rc
1132 1133 file) to control left-padding of secondary prompts.
1133 1134
1134 1135 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
1135 1136 the profiler can't be imported. Fix for Debian, which removed
1136 1137 profile.py because of License issues. I applied a slightly
1137 1138 modified version of the original Debian patch at
1138 1139 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
1139 1140
1140 1141 2005-02-17 Fernando Perez <fperez@colorado.edu>
1141 1142
1142 1143 * IPython/genutils.py (native_line_ends): Fix bug which would
1143 1144 cause improper line-ends under win32 b/c I was not opening files
1144 1145 in binary mode. Bug report and fix thanks to Ville.
1145 1146
1146 1147 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
1147 1148 trying to catch spurious foo[1] autocalls. My fix actually broke
1148 1149 ',/' autoquote/call with explicit escape (bad regexp).
1149 1150
1150 1151 2005-02-15 *** Released version 0.6.11
1151 1152
1152 1153 2005-02-14 Fernando Perez <fperez@colorado.edu>
1153 1154
1154 1155 * IPython/background_jobs.py: New background job management
1155 1156 subsystem. This is implemented via a new set of classes, and
1156 1157 IPython now provides a builtin 'jobs' object for background job
1157 1158 execution. A convenience %bg magic serves as a lightweight
1158 1159 frontend for starting the more common type of calls. This was
1159 1160 inspired by discussions with B. Granger and the BackgroundCommand
1160 1161 class described in the book Python Scripting for Computational
1161 1162 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
1162 1163 (although ultimately no code from this text was used, as IPython's
1163 1164 system is a separate implementation).
1164 1165
1165 1166 * IPython/iplib.py (MagicCompleter.python_matches): add new option
1166 1167 to control the completion of single/double underscore names
1167 1168 separately. As documented in the example ipytonrc file, the
1168 1169 readline_omit__names variable can now be set to 2, to omit even
1169 1170 single underscore names. Thanks to a patch by Brian Wong
1170 1171 <BrianWong-AT-AirgoNetworks.Com>.
1171 1172 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
1172 1173 be autocalled as foo([1]) if foo were callable. A problem for
1173 1174 things which are both callable and implement __getitem__.
1174 1175 (init_readline): Fix autoindentation for win32. Thanks to a patch
1175 1176 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
1176 1177
1177 1178 2005-02-12 Fernando Perez <fperez@colorado.edu>
1178 1179
1179 1180 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
1180 1181 which I had written long ago to sort out user error messages which
1181 1182 may occur during startup. This seemed like a good idea initially,
1182 1183 but it has proven a disaster in retrospect. I don't want to
1183 1184 change much code for now, so my fix is to set the internal 'debug'
1184 1185 flag to true everywhere, whose only job was precisely to control
1185 1186 this subsystem. This closes issue 28 (as well as avoiding all
1186 1187 sorts of strange hangups which occur from time to time).
1187 1188
1188 1189 2005-02-07 Fernando Perez <fperez@colorado.edu>
1189 1190
1190 1191 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
1191 1192 previous call produced a syntax error.
1192 1193
1193 1194 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1194 1195 classes without constructor.
1195 1196
1196 1197 2005-02-06 Fernando Perez <fperez@colorado.edu>
1197 1198
1198 1199 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
1199 1200 completions with the results of each matcher, so we return results
1200 1201 to the user from all namespaces. This breaks with ipython
1201 1202 tradition, but I think it's a nicer behavior. Now you get all
1202 1203 possible completions listed, from all possible namespaces (python,
1203 1204 filesystem, magics...) After a request by John Hunter
1204 1205 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1205 1206
1206 1207 2005-02-05 Fernando Perez <fperez@colorado.edu>
1207 1208
1208 1209 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
1209 1210 the call had quote characters in it (the quotes were stripped).
1210 1211
1211 1212 2005-01-31 Fernando Perez <fperez@colorado.edu>
1212 1213
1213 1214 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
1214 1215 Itpl.itpl() to make the code more robust against psyco
1215 1216 optimizations.
1216 1217
1217 1218 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
1218 1219 of causing an exception. Quicker, cleaner.
1219 1220
1220 1221 2005-01-28 Fernando Perez <fperez@colorado.edu>
1221 1222
1222 1223 * scripts/ipython_win_post_install.py (install): hardcode
1223 1224 sys.prefix+'python.exe' as the executable path. It turns out that
1224 1225 during the post-installation run, sys.executable resolves to the
1225 1226 name of the binary installer! I should report this as a distutils
1226 1227 bug, I think. I updated the .10 release with this tiny fix, to
1227 1228 avoid annoying the lists further.
1228 1229
1229 1230 2005-01-27 *** Released version 0.6.10
1230 1231
1231 1232 2005-01-27 Fernando Perez <fperez@colorado.edu>
1232 1233
1233 1234 * IPython/numutils.py (norm): Added 'inf' as optional name for
1234 1235 L-infinity norm, included references to mathworld.com for vector
1235 1236 norm definitions.
1236 1237 (amin/amax): added amin/amax for array min/max. Similar to what
1237 1238 pylab ships with after the recent reorganization of names.
1238 1239 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1239 1240
1240 1241 * ipython.el: committed Alex's recent fixes and improvements.
1241 1242 Tested with python-mode from CVS, and it looks excellent. Since
1242 1243 python-mode hasn't released anything in a while, I'm temporarily
1243 1244 putting a copy of today's CVS (v 4.70) of python-mode in:
1244 1245 http://ipython.scipy.org/tmp/python-mode.el
1245 1246
1246 1247 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1247 1248 sys.executable for the executable name, instead of assuming it's
1248 1249 called 'python.exe' (the post-installer would have produced broken
1249 1250 setups on systems with a differently named python binary).
1250 1251
1251 1252 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1252 1253 references to os.linesep, to make the code more
1253 1254 platform-independent. This is also part of the win32 coloring
1254 1255 fixes.
1255 1256
1256 1257 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1257 1258 lines, which actually cause coloring bugs because the length of
1258 1259 the line is very difficult to correctly compute with embedded
1259 1260 escapes. This was the source of all the coloring problems under
1260 1261 Win32. I think that _finally_, Win32 users have a properly
1261 1262 working ipython in all respects. This would never have happened
1262 1263 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1263 1264
1264 1265 2005-01-26 *** Released version 0.6.9
1265 1266
1266 1267 2005-01-25 Fernando Perez <fperez@colorado.edu>
1267 1268
1268 1269 * setup.py: finally, we have a true Windows installer, thanks to
1269 1270 the excellent work of Viktor Ransmayr
1270 1271 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1271 1272 Windows users. The setup routine is quite a bit cleaner thanks to
1272 1273 this, and the post-install script uses the proper functions to
1273 1274 allow a clean de-installation using the standard Windows Control
1274 1275 Panel.
1275 1276
1276 1277 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1277 1278 environment variable under all OSes (including win32) if
1278 1279 available. This will give consistency to win32 users who have set
1279 1280 this variable for any reason. If os.environ['HOME'] fails, the
1280 1281 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1281 1282
1282 1283 2005-01-24 Fernando Perez <fperez@colorado.edu>
1283 1284
1284 1285 * IPython/numutils.py (empty_like): add empty_like(), similar to
1285 1286 zeros_like() but taking advantage of the new empty() Numeric routine.
1286 1287
1287 1288 2005-01-23 *** Released version 0.6.8
1288 1289
1289 1290 2005-01-22 Fernando Perez <fperez@colorado.edu>
1290 1291
1291 1292 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1292 1293 automatic show() calls. After discussing things with JDH, it
1293 1294 turns out there are too many corner cases where this can go wrong.
1294 1295 It's best not to try to be 'too smart', and simply have ipython
1295 1296 reproduce as much as possible the default behavior of a normal
1296 1297 python shell.
1297 1298
1298 1299 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1299 1300 line-splitting regexp and _prefilter() to avoid calling getattr()
1300 1301 on assignments. This closes
1301 1302 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1302 1303 readline uses getattr(), so a simple <TAB> keypress is still
1303 1304 enough to trigger getattr() calls on an object.
1304 1305
1305 1306 2005-01-21 Fernando Perez <fperez@colorado.edu>
1306 1307
1307 1308 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1308 1309 docstring under pylab so it doesn't mask the original.
1309 1310
1310 1311 2005-01-21 *** Released version 0.6.7
1311 1312
1312 1313 2005-01-21 Fernando Perez <fperez@colorado.edu>
1313 1314
1314 1315 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1315 1316 signal handling for win32 users in multithreaded mode.
1316 1317
1317 1318 2005-01-17 Fernando Perez <fperez@colorado.edu>
1318 1319
1319 1320 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1320 1321 instances with no __init__. After a crash report by Norbert Nemec
1321 1322 <Norbert-AT-nemec-online.de>.
1322 1323
1323 1324 2005-01-14 Fernando Perez <fperez@colorado.edu>
1324 1325
1325 1326 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1326 1327 names for verbose exceptions, when multiple dotted names and the
1327 1328 'parent' object were present on the same line.
1328 1329
1329 1330 2005-01-11 Fernando Perez <fperez@colorado.edu>
1330 1331
1331 1332 * IPython/genutils.py (flag_calls): new utility to trap and flag
1332 1333 calls in functions. I need it to clean up matplotlib support.
1333 1334 Also removed some deprecated code in genutils.
1334 1335
1335 1336 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1336 1337 that matplotlib scripts called with %run, which don't call show()
1337 1338 themselves, still have their plotting windows open.
1338 1339
1339 1340 2005-01-05 Fernando Perez <fperez@colorado.edu>
1340 1341
1341 1342 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1342 1343 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1343 1344
1344 1345 2004-12-19 Fernando Perez <fperez@colorado.edu>
1345 1346
1346 1347 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1347 1348 parent_runcode, which was an eyesore. The same result can be
1348 1349 obtained with Python's regular superclass mechanisms.
1349 1350
1350 1351 2004-12-17 Fernando Perez <fperez@colorado.edu>
1351 1352
1352 1353 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1353 1354 reported by Prabhu.
1354 1355 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1355 1356 sys.stderr) instead of explicitly calling sys.stderr. This helps
1356 1357 maintain our I/O abstractions clean, for future GUI embeddings.
1357 1358
1358 1359 * IPython/genutils.py (info): added new utility for sys.stderr
1359 1360 unified info message handling (thin wrapper around warn()).
1360 1361
1361 1362 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1362 1363 composite (dotted) names on verbose exceptions.
1363 1364 (VerboseTB.nullrepr): harden against another kind of errors which
1364 1365 Python's inspect module can trigger, and which were crashing
1365 1366 IPython. Thanks to a report by Marco Lombardi
1366 1367 <mlombard-AT-ma010192.hq.eso.org>.
1367 1368
1368 1369 2004-12-13 *** Released version 0.6.6
1369 1370
1370 1371 2004-12-12 Fernando Perez <fperez@colorado.edu>
1371 1372
1372 1373 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1373 1374 generated by pygtk upon initialization if it was built without
1374 1375 threads (for matplotlib users). After a crash reported by
1375 1376 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1376 1377
1377 1378 * IPython/ipmaker.py (make_IPython): fix small bug in the
1378 1379 import_some parameter for multiple imports.
1379 1380
1380 1381 * IPython/iplib.py (ipmagic): simplified the interface of
1381 1382 ipmagic() to take a single string argument, just as it would be
1382 1383 typed at the IPython cmd line.
1383 1384 (ipalias): Added new ipalias() with an interface identical to
1384 1385 ipmagic(). This completes exposing a pure python interface to the
1385 1386 alias and magic system, which can be used in loops or more complex
1386 1387 code where IPython's automatic line mangling is not active.
1387 1388
1388 1389 * IPython/genutils.py (timing): changed interface of timing to
1389 1390 simply run code once, which is the most common case. timings()
1390 1391 remains unchanged, for the cases where you want multiple runs.
1391 1392
1392 1393 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1393 1394 bug where Python2.2 crashes with exec'ing code which does not end
1394 1395 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1395 1396 before.
1396 1397
1397 1398 2004-12-10 Fernando Perez <fperez@colorado.edu>
1398 1399
1399 1400 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1400 1401 -t to -T, to accomodate the new -t flag in %run (the %run and
1401 1402 %prun options are kind of intermixed, and it's not easy to change
1402 1403 this with the limitations of python's getopt).
1403 1404
1404 1405 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1405 1406 the execution of scripts. It's not as fine-tuned as timeit.py,
1406 1407 but it works from inside ipython (and under 2.2, which lacks
1407 1408 timeit.py). Optionally a number of runs > 1 can be given for
1408 1409 timing very short-running code.
1409 1410
1410 1411 * IPython/genutils.py (uniq_stable): new routine which returns a
1411 1412 list of unique elements in any iterable, but in stable order of
1412 1413 appearance. I needed this for the ultraTB fixes, and it's a handy
1413 1414 utility.
1414 1415
1415 1416 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1416 1417 dotted names in Verbose exceptions. This had been broken since
1417 1418 the very start, now x.y will properly be printed in a Verbose
1418 1419 traceback, instead of x being shown and y appearing always as an
1419 1420 'undefined global'. Getting this to work was a bit tricky,
1420 1421 because by default python tokenizers are stateless. Saved by
1421 1422 python's ability to easily add a bit of state to an arbitrary
1422 1423 function (without needing to build a full-blown callable object).
1423 1424
1424 1425 Also big cleanup of this code, which had horrendous runtime
1425 1426 lookups of zillions of attributes for colorization. Moved all
1426 1427 this code into a few templates, which make it cleaner and quicker.
1427 1428
1428 1429 Printout quality was also improved for Verbose exceptions: one
1429 1430 variable per line, and memory addresses are printed (this can be
1430 1431 quite handy in nasty debugging situations, which is what Verbose
1431 1432 is for).
1432 1433
1433 1434 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1434 1435 the command line as scripts to be loaded by embedded instances.
1435 1436 Doing so has the potential for an infinite recursion if there are
1436 1437 exceptions thrown in the process. This fixes a strange crash
1437 1438 reported by Philippe MULLER <muller-AT-irit.fr>.
1438 1439
1439 1440 2004-12-09 Fernando Perez <fperez@colorado.edu>
1440 1441
1441 1442 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1442 1443 to reflect new names in matplotlib, which now expose the
1443 1444 matlab-compatible interface via a pylab module instead of the
1444 1445 'matlab' name. The new code is backwards compatible, so users of
1445 1446 all matplotlib versions are OK. Patch by J. Hunter.
1446 1447
1447 1448 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1448 1449 of __init__ docstrings for instances (class docstrings are already
1449 1450 automatically printed). Instances with customized docstrings
1450 1451 (indep. of the class) are also recognized and all 3 separate
1451 1452 docstrings are printed (instance, class, constructor). After some
1452 1453 comments/suggestions by J. Hunter.
1453 1454
1454 1455 2004-12-05 Fernando Perez <fperez@colorado.edu>
1455 1456
1456 1457 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1457 1458 warnings when tab-completion fails and triggers an exception.
1458 1459
1459 1460 2004-12-03 Fernando Perez <fperez@colorado.edu>
1460 1461
1461 1462 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1462 1463 be triggered when using 'run -p'. An incorrect option flag was
1463 1464 being set ('d' instead of 'D').
1464 1465 (manpage): fix missing escaped \- sign.
1465 1466
1466 1467 2004-11-30 *** Released version 0.6.5
1467 1468
1468 1469 2004-11-30 Fernando Perez <fperez@colorado.edu>
1469 1470
1470 1471 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1471 1472 setting with -d option.
1472 1473
1473 1474 * setup.py (docfiles): Fix problem where the doc glob I was using
1474 1475 was COMPLETELY BROKEN. It was giving the right files by pure
1475 1476 accident, but failed once I tried to include ipython.el. Note:
1476 1477 glob() does NOT allow you to do exclusion on multiple endings!
1477 1478
1478 1479 2004-11-29 Fernando Perez <fperez@colorado.edu>
1479 1480
1480 1481 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1481 1482 the manpage as the source. Better formatting & consistency.
1482 1483
1483 1484 * IPython/Magic.py (magic_run): Added new -d option, to run
1484 1485 scripts under the control of the python pdb debugger. Note that
1485 1486 this required changing the %prun option -d to -D, to avoid a clash
1486 1487 (since %run must pass options to %prun, and getopt is too dumb to
1487 1488 handle options with string values with embedded spaces). Thanks
1488 1489 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1489 1490 (magic_who_ls): added type matching to %who and %whos, so that one
1490 1491 can filter their output to only include variables of certain
1491 1492 types. Another suggestion by Matthew.
1492 1493 (magic_whos): Added memory summaries in kb and Mb for arrays.
1493 1494 (magic_who): Improve formatting (break lines every 9 vars).
1494 1495
1495 1496 2004-11-28 Fernando Perez <fperez@colorado.edu>
1496 1497
1497 1498 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1498 1499 cache when empty lines were present.
1499 1500
1500 1501 2004-11-24 Fernando Perez <fperez@colorado.edu>
1501 1502
1502 1503 * IPython/usage.py (__doc__): document the re-activated threading
1503 1504 options for WX and GTK.
1504 1505
1505 1506 2004-11-23 Fernando Perez <fperez@colorado.edu>
1506 1507
1507 1508 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1508 1509 the -wthread and -gthread options, along with a new -tk one to try
1509 1510 and coordinate Tk threading with wx/gtk. The tk support is very
1510 1511 platform dependent, since it seems to require Tcl and Tk to be
1511 1512 built with threads (Fedora1/2 appears NOT to have it, but in
1512 1513 Prabhu's Debian boxes it works OK). But even with some Tk
1513 1514 limitations, this is a great improvement.
1514 1515
1515 1516 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1516 1517 info in user prompts. Patch by Prabhu.
1517 1518
1518 1519 2004-11-18 Fernando Perez <fperez@colorado.edu>
1519 1520
1520 1521 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1521 1522 EOFErrors and bail, to avoid infinite loops if a non-terminating
1522 1523 file is fed into ipython. Patch submitted in issue 19 by user,
1523 1524 many thanks.
1524 1525
1525 1526 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1526 1527 autoquote/parens in continuation prompts, which can cause lots of
1527 1528 problems. Closes roundup issue 20.
1528 1529
1529 1530 2004-11-17 Fernando Perez <fperez@colorado.edu>
1530 1531
1531 1532 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1532 1533 reported as debian bug #280505. I'm not sure my local changelog
1533 1534 entry has the proper debian format (Jack?).
1534 1535
1535 1536 2004-11-08 *** Released version 0.6.4
1536 1537
1537 1538 2004-11-08 Fernando Perez <fperez@colorado.edu>
1538 1539
1539 1540 * IPython/iplib.py (init_readline): Fix exit message for Windows
1540 1541 when readline is active. Thanks to a report by Eric Jones
1541 1542 <eric-AT-enthought.com>.
1542 1543
1543 1544 2004-11-07 Fernando Perez <fperez@colorado.edu>
1544 1545
1545 1546 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1546 1547 sometimes seen by win2k/cygwin users.
1547 1548
1548 1549 2004-11-06 Fernando Perez <fperez@colorado.edu>
1549 1550
1550 1551 * IPython/iplib.py (interact): Change the handling of %Exit from
1551 1552 trying to propagate a SystemExit to an internal ipython flag.
1552 1553 This is less elegant than using Python's exception mechanism, but
1553 1554 I can't get that to work reliably with threads, so under -pylab
1554 1555 %Exit was hanging IPython. Cross-thread exception handling is
1555 1556 really a bitch. Thaks to a bug report by Stephen Walton
1556 1557 <stephen.walton-AT-csun.edu>.
1557 1558
1558 1559 2004-11-04 Fernando Perez <fperez@colorado.edu>
1559 1560
1560 1561 * IPython/iplib.py (raw_input_original): store a pointer to the
1561 1562 true raw_input to harden against code which can modify it
1562 1563 (wx.py.PyShell does this and would otherwise crash ipython).
1563 1564 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1564 1565
1565 1566 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1566 1567 Ctrl-C problem, which does not mess up the input line.
1567 1568
1568 1569 2004-11-03 Fernando Perez <fperez@colorado.edu>
1569 1570
1570 1571 * IPython/Release.py: Changed licensing to BSD, in all files.
1571 1572 (name): lowercase name for tarball/RPM release.
1572 1573
1573 1574 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1574 1575 use throughout ipython.
1575 1576
1576 1577 * IPython/Magic.py (Magic._ofind): Switch to using the new
1577 1578 OInspect.getdoc() function.
1578 1579
1579 1580 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1580 1581 of the line currently being canceled via Ctrl-C. It's extremely
1581 1582 ugly, but I don't know how to do it better (the problem is one of
1582 1583 handling cross-thread exceptions).
1583 1584
1584 1585 2004-10-28 Fernando Perez <fperez@colorado.edu>
1585 1586
1586 1587 * IPython/Shell.py (signal_handler): add signal handlers to trap
1587 1588 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1588 1589 report by Francesc Alted.
1589 1590
1590 1591 2004-10-21 Fernando Perez <fperez@colorado.edu>
1591 1592
1592 1593 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1593 1594 to % for pysh syntax extensions.
1594 1595
1595 1596 2004-10-09 Fernando Perez <fperez@colorado.edu>
1596 1597
1597 1598 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1598 1599 arrays to print a more useful summary, without calling str(arr).
1599 1600 This avoids the problem of extremely lengthy computations which
1600 1601 occur if arr is large, and appear to the user as a system lockup
1601 1602 with 100% cpu activity. After a suggestion by Kristian Sandberg
1602 1603 <Kristian.Sandberg@colorado.edu>.
1603 1604 (Magic.__init__): fix bug in global magic escapes not being
1604 1605 correctly set.
1605 1606
1606 1607 2004-10-08 Fernando Perez <fperez@colorado.edu>
1607 1608
1608 1609 * IPython/Magic.py (__license__): change to absolute imports of
1609 1610 ipython's own internal packages, to start adapting to the absolute
1610 1611 import requirement of PEP-328.
1611 1612
1612 1613 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1613 1614 files, and standardize author/license marks through the Release
1614 1615 module instead of having per/file stuff (except for files with
1615 1616 particular licenses, like the MIT/PSF-licensed codes).
1616 1617
1617 1618 * IPython/Debugger.py: remove dead code for python 2.1
1618 1619
1619 1620 2004-10-04 Fernando Perez <fperez@colorado.edu>
1620 1621
1621 1622 * IPython/iplib.py (ipmagic): New function for accessing magics
1622 1623 via a normal python function call.
1623 1624
1624 1625 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1625 1626 from '@' to '%', to accomodate the new @decorator syntax of python
1626 1627 2.4.
1627 1628
1628 1629 2004-09-29 Fernando Perez <fperez@colorado.edu>
1629 1630
1630 1631 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1631 1632 matplotlib.use to prevent running scripts which try to switch
1632 1633 interactive backends from within ipython. This will just crash
1633 1634 the python interpreter, so we can't allow it (but a detailed error
1634 1635 is given to the user).
1635 1636
1636 1637 2004-09-28 Fernando Perez <fperez@colorado.edu>
1637 1638
1638 1639 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1639 1640 matplotlib-related fixes so that using @run with non-matplotlib
1640 1641 scripts doesn't pop up spurious plot windows. This requires
1641 1642 matplotlib >= 0.63, where I had to make some changes as well.
1642 1643
1643 1644 * IPython/ipmaker.py (make_IPython): update version requirement to
1644 1645 python 2.2.
1645 1646
1646 1647 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1647 1648 banner arg for embedded customization.
1648 1649
1649 1650 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1650 1651 explicit uses of __IP as the IPython's instance name. Now things
1651 1652 are properly handled via the shell.name value. The actual code
1652 1653 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1653 1654 is much better than before. I'll clean things completely when the
1654 1655 magic stuff gets a real overhaul.
1655 1656
1656 1657 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1657 1658 minor changes to debian dir.
1658 1659
1659 1660 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1660 1661 pointer to the shell itself in the interactive namespace even when
1661 1662 a user-supplied dict is provided. This is needed for embedding
1662 1663 purposes (found by tests with Michel Sanner).
1663 1664
1664 1665 2004-09-27 Fernando Perez <fperez@colorado.edu>
1665 1666
1666 1667 * IPython/UserConfig/ipythonrc: remove []{} from
1667 1668 readline_remove_delims, so that things like [modname.<TAB> do
1668 1669 proper completion. This disables [].TAB, but that's a less common
1669 1670 case than module names in list comprehensions, for example.
1670 1671 Thanks to a report by Andrea Riciputi.
1671 1672
1672 1673 2004-09-09 Fernando Perez <fperez@colorado.edu>
1673 1674
1674 1675 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1675 1676 blocking problems in win32 and osx. Fix by John.
1676 1677
1677 1678 2004-09-08 Fernando Perez <fperez@colorado.edu>
1678 1679
1679 1680 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1680 1681 for Win32 and OSX. Fix by John Hunter.
1681 1682
1682 1683 2004-08-30 *** Released version 0.6.3
1683 1684
1684 1685 2004-08-30 Fernando Perez <fperez@colorado.edu>
1685 1686
1686 1687 * setup.py (isfile): Add manpages to list of dependent files to be
1687 1688 updated.
1688 1689
1689 1690 2004-08-27 Fernando Perez <fperez@colorado.edu>
1690 1691
1691 1692 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1692 1693 for now. They don't really work with standalone WX/GTK code
1693 1694 (though matplotlib IS working fine with both of those backends).
1694 1695 This will neeed much more testing. I disabled most things with
1695 1696 comments, so turning it back on later should be pretty easy.
1696 1697
1697 1698 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1698 1699 autocalling of expressions like r'foo', by modifying the line
1699 1700 split regexp. Closes
1700 1701 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1701 1702 Riley <ipythonbugs-AT-sabi.net>.
1702 1703 (InteractiveShell.mainloop): honor --nobanner with banner
1703 1704 extensions.
1704 1705
1705 1706 * IPython/Shell.py: Significant refactoring of all classes, so
1706 1707 that we can really support ALL matplotlib backends and threading
1707 1708 models (John spotted a bug with Tk which required this). Now we
1708 1709 should support single-threaded, WX-threads and GTK-threads, both
1709 1710 for generic code and for matplotlib.
1710 1711
1711 1712 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1712 1713 -pylab, to simplify things for users. Will also remove the pylab
1713 1714 profile, since now all of matplotlib configuration is directly
1714 1715 handled here. This also reduces startup time.
1715 1716
1716 1717 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1717 1718 shell wasn't being correctly called. Also in IPShellWX.
1718 1719
1719 1720 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1720 1721 fine-tune banner.
1721 1722
1722 1723 * IPython/numutils.py (spike): Deprecate these spike functions,
1723 1724 delete (long deprecated) gnuplot_exec handler.
1724 1725
1725 1726 2004-08-26 Fernando Perez <fperez@colorado.edu>
1726 1727
1727 1728 * ipython.1: Update for threading options, plus some others which
1728 1729 were missing.
1729 1730
1730 1731 * IPython/ipmaker.py (__call__): Added -wthread option for
1731 1732 wxpython thread handling. Make sure threading options are only
1732 1733 valid at the command line.
1733 1734
1734 1735 * scripts/ipython: moved shell selection into a factory function
1735 1736 in Shell.py, to keep the starter script to a minimum.
1736 1737
1737 1738 2004-08-25 Fernando Perez <fperez@colorado.edu>
1738 1739
1739 1740 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1740 1741 John. Along with some recent changes he made to matplotlib, the
1741 1742 next versions of both systems should work very well together.
1742 1743
1743 1744 2004-08-24 Fernando Perez <fperez@colorado.edu>
1744 1745
1745 1746 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1746 1747 tried to switch the profiling to using hotshot, but I'm getting
1747 1748 strange errors from prof.runctx() there. I may be misreading the
1748 1749 docs, but it looks weird. For now the profiling code will
1749 1750 continue to use the standard profiler.
1750 1751
1751 1752 2004-08-23 Fernando Perez <fperez@colorado.edu>
1752 1753
1753 1754 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1754 1755 threaded shell, by John Hunter. It's not quite ready yet, but
1755 1756 close.
1756 1757
1757 1758 2004-08-22 Fernando Perez <fperez@colorado.edu>
1758 1759
1759 1760 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1760 1761 in Magic and ultraTB.
1761 1762
1762 1763 * ipython.1: document threading options in manpage.
1763 1764
1764 1765 * scripts/ipython: Changed name of -thread option to -gthread,
1765 1766 since this is GTK specific. I want to leave the door open for a
1766 1767 -wthread option for WX, which will most likely be necessary. This
1767 1768 change affects usage and ipmaker as well.
1768 1769
1769 1770 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1770 1771 handle the matplotlib shell issues. Code by John Hunter
1771 1772 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1772 1773 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1773 1774 broken (and disabled for end users) for now, but it puts the
1774 1775 infrastructure in place.
1775 1776
1776 1777 2004-08-21 Fernando Perez <fperez@colorado.edu>
1777 1778
1778 1779 * ipythonrc-pylab: Add matplotlib support.
1779 1780
1780 1781 * matplotlib_config.py: new files for matplotlib support, part of
1781 1782 the pylab profile.
1782 1783
1783 1784 * IPython/usage.py (__doc__): documented the threading options.
1784 1785
1785 1786 2004-08-20 Fernando Perez <fperez@colorado.edu>
1786 1787
1787 1788 * ipython: Modified the main calling routine to handle the -thread
1788 1789 and -mpthread options. This needs to be done as a top-level hack,
1789 1790 because it determines which class to instantiate for IPython
1790 1791 itself.
1791 1792
1792 1793 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1793 1794 classes to support multithreaded GTK operation without blocking,
1794 1795 and matplotlib with all backends. This is a lot of still very
1795 1796 experimental code, and threads are tricky. So it may still have a
1796 1797 few rough edges... This code owes a lot to
1797 1798 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1798 1799 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1799 1800 to John Hunter for all the matplotlib work.
1800 1801
1801 1802 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1802 1803 options for gtk thread and matplotlib support.
1803 1804
1804 1805 2004-08-16 Fernando Perez <fperez@colorado.edu>
1805 1806
1806 1807 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1807 1808 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1808 1809 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1809 1810
1810 1811 2004-08-11 Fernando Perez <fperez@colorado.edu>
1811 1812
1812 1813 * setup.py (isfile): Fix build so documentation gets updated for
1813 1814 rpms (it was only done for .tgz builds).
1814 1815
1815 1816 2004-08-10 Fernando Perez <fperez@colorado.edu>
1816 1817
1817 1818 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1818 1819
1819 1820 * iplib.py : Silence syntax error exceptions in tab-completion.
1820 1821
1821 1822 2004-08-05 Fernando Perez <fperez@colorado.edu>
1822 1823
1823 1824 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1824 1825 'color off' mark for continuation prompts. This was causing long
1825 1826 continuation lines to mis-wrap.
1826 1827
1827 1828 2004-08-01 Fernando Perez <fperez@colorado.edu>
1828 1829
1829 1830 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1830 1831 for building ipython to be a parameter. All this is necessary
1831 1832 right now to have a multithreaded version, but this insane
1832 1833 non-design will be cleaned up soon. For now, it's a hack that
1833 1834 works.
1834 1835
1835 1836 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1836 1837 args in various places. No bugs so far, but it's a dangerous
1837 1838 practice.
1838 1839
1839 1840 2004-07-31 Fernando Perez <fperez@colorado.edu>
1840 1841
1841 1842 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1842 1843 fix completion of files with dots in their names under most
1843 1844 profiles (pysh was OK because the completion order is different).
1844 1845
1845 1846 2004-07-27 Fernando Perez <fperez@colorado.edu>
1846 1847
1847 1848 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1848 1849 keywords manually, b/c the one in keyword.py was removed in python
1849 1850 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1850 1851 This is NOT a bug under python 2.3 and earlier.
1851 1852
1852 1853 2004-07-26 Fernando Perez <fperez@colorado.edu>
1853 1854
1854 1855 * IPython/ultraTB.py (VerboseTB.text): Add another
1855 1856 linecache.checkcache() call to try to prevent inspect.py from
1856 1857 crashing under python 2.3. I think this fixes
1857 1858 http://www.scipy.net/roundup/ipython/issue17.
1858 1859
1859 1860 2004-07-26 *** Released version 0.6.2
1860 1861
1861 1862 2004-07-26 Fernando Perez <fperez@colorado.edu>
1862 1863
1863 1864 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1864 1865 fail for any number.
1865 1866 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1866 1867 empty bookmarks.
1867 1868
1868 1869 2004-07-26 *** Released version 0.6.1
1869 1870
1870 1871 2004-07-26 Fernando Perez <fperez@colorado.edu>
1871 1872
1872 1873 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1873 1874
1874 1875 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1875 1876 escaping '()[]{}' in filenames.
1876 1877
1877 1878 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1878 1879 Python 2.2 users who lack a proper shlex.split.
1879 1880
1880 1881 2004-07-19 Fernando Perez <fperez@colorado.edu>
1881 1882
1882 1883 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1883 1884 for reading readline's init file. I follow the normal chain:
1884 1885 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1885 1886 report by Mike Heeter. This closes
1886 1887 http://www.scipy.net/roundup/ipython/issue16.
1887 1888
1888 1889 2004-07-18 Fernando Perez <fperez@colorado.edu>
1889 1890
1890 1891 * IPython/iplib.py (__init__): Add better handling of '\' under
1891 1892 Win32 for filenames. After a patch by Ville.
1892 1893
1893 1894 2004-07-17 Fernando Perez <fperez@colorado.edu>
1894 1895
1895 1896 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1896 1897 autocalling would be triggered for 'foo is bar' if foo is
1897 1898 callable. I also cleaned up the autocall detection code to use a
1898 1899 regexp, which is faster. Bug reported by Alexander Schmolck.
1899 1900
1900 1901 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1901 1902 '?' in them would confuse the help system. Reported by Alex
1902 1903 Schmolck.
1903 1904
1904 1905 2004-07-16 Fernando Perez <fperez@colorado.edu>
1905 1906
1906 1907 * IPython/GnuplotInteractive.py (__all__): added plot2.
1907 1908
1908 1909 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1909 1910 plotting dictionaries, lists or tuples of 1d arrays.
1910 1911
1911 1912 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1912 1913 optimizations.
1913 1914
1914 1915 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1915 1916 the information which was there from Janko's original IPP code:
1916 1917
1917 1918 03.05.99 20:53 porto.ifm.uni-kiel.de
1918 1919 --Started changelog.
1919 1920 --make clear do what it say it does
1920 1921 --added pretty output of lines from inputcache
1921 1922 --Made Logger a mixin class, simplifies handling of switches
1922 1923 --Added own completer class. .string<TAB> expands to last history
1923 1924 line which starts with string. The new expansion is also present
1924 1925 with Ctrl-r from the readline library. But this shows, who this
1925 1926 can be done for other cases.
1926 1927 --Added convention that all shell functions should accept a
1927 1928 parameter_string This opens the door for different behaviour for
1928 1929 each function. @cd is a good example of this.
1929 1930
1930 1931 04.05.99 12:12 porto.ifm.uni-kiel.de
1931 1932 --added logfile rotation
1932 1933 --added new mainloop method which freezes first the namespace
1933 1934
1934 1935 07.05.99 21:24 porto.ifm.uni-kiel.de
1935 1936 --added the docreader classes. Now there is a help system.
1936 1937 -This is only a first try. Currently it's not easy to put new
1937 1938 stuff in the indices. But this is the way to go. Info would be
1938 1939 better, but HTML is every where and not everybody has an info
1939 1940 system installed and it's not so easy to change html-docs to info.
1940 1941 --added global logfile option
1941 1942 --there is now a hook for object inspection method pinfo needs to
1942 1943 be provided for this. Can be reached by two '??'.
1943 1944
1944 1945 08.05.99 20:51 porto.ifm.uni-kiel.de
1945 1946 --added a README
1946 1947 --bug in rc file. Something has changed so functions in the rc
1947 1948 file need to reference the shell and not self. Not clear if it's a
1948 1949 bug or feature.
1949 1950 --changed rc file for new behavior
1950 1951
1951 1952 2004-07-15 Fernando Perez <fperez@colorado.edu>
1952 1953
1953 1954 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1954 1955 cache was falling out of sync in bizarre manners when multi-line
1955 1956 input was present. Minor optimizations and cleanup.
1956 1957
1957 1958 (Logger): Remove old Changelog info for cleanup. This is the
1958 1959 information which was there from Janko's original code:
1959 1960
1960 1961 Changes to Logger: - made the default log filename a parameter
1961 1962
1962 1963 - put a check for lines beginning with !@? in log(). Needed
1963 1964 (even if the handlers properly log their lines) for mid-session
1964 1965 logging activation to work properly. Without this, lines logged
1965 1966 in mid session, which get read from the cache, would end up
1966 1967 'bare' (with !@? in the open) in the log. Now they are caught
1967 1968 and prepended with a #.
1968 1969
1969 1970 * IPython/iplib.py (InteractiveShell.init_readline): added check
1970 1971 in case MagicCompleter fails to be defined, so we don't crash.
1971 1972
1972 1973 2004-07-13 Fernando Perez <fperez@colorado.edu>
1973 1974
1974 1975 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1975 1976 of EPS if the requested filename ends in '.eps'.
1976 1977
1977 1978 2004-07-04 Fernando Perez <fperez@colorado.edu>
1978 1979
1979 1980 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1980 1981 escaping of quotes when calling the shell.
1981 1982
1982 1983 2004-07-02 Fernando Perez <fperez@colorado.edu>
1983 1984
1984 1985 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1985 1986 gettext not working because we were clobbering '_'. Fixes
1986 1987 http://www.scipy.net/roundup/ipython/issue6.
1987 1988
1988 1989 2004-07-01 Fernando Perez <fperez@colorado.edu>
1989 1990
1990 1991 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1991 1992 into @cd. Patch by Ville.
1992 1993
1993 1994 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1994 1995 new function to store things after ipmaker runs. Patch by Ville.
1995 1996 Eventually this will go away once ipmaker is removed and the class
1996 1997 gets cleaned up, but for now it's ok. Key functionality here is
1997 1998 the addition of the persistent storage mechanism, a dict for
1998 1999 keeping data across sessions (for now just bookmarks, but more can
1999 2000 be implemented later).
2000 2001
2001 2002 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
2002 2003 persistent across sections. Patch by Ville, I modified it
2003 2004 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
2004 2005 added a '-l' option to list all bookmarks.
2005 2006
2006 2007 * IPython/iplib.py (InteractiveShell.atexit_operations): new
2007 2008 center for cleanup. Registered with atexit.register(). I moved
2008 2009 here the old exit_cleanup(). After a patch by Ville.
2009 2010
2010 2011 * IPython/Magic.py (get_py_filename): added '~' to the accepted
2011 2012 characters in the hacked shlex_split for python 2.2.
2012 2013
2013 2014 * IPython/iplib.py (file_matches): more fixes to filenames with
2014 2015 whitespace in them. It's not perfect, but limitations in python's
2015 2016 readline make it impossible to go further.
2016 2017
2017 2018 2004-06-29 Fernando Perez <fperez@colorado.edu>
2018 2019
2019 2020 * IPython/iplib.py (file_matches): escape whitespace correctly in
2020 2021 filename completions. Bug reported by Ville.
2021 2022
2022 2023 2004-06-28 Fernando Perez <fperez@colorado.edu>
2023 2024
2024 2025 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
2025 2026 the history file will be called 'history-PROFNAME' (or just
2026 2027 'history' if no profile is loaded). I was getting annoyed at
2027 2028 getting my Numerical work history clobbered by pysh sessions.
2028 2029
2029 2030 * IPython/iplib.py (InteractiveShell.__init__): Internal
2030 2031 getoutputerror() function so that we can honor the system_verbose
2031 2032 flag for _all_ system calls. I also added escaping of #
2032 2033 characters here to avoid confusing Itpl.
2033 2034
2034 2035 * IPython/Magic.py (shlex_split): removed call to shell in
2035 2036 parse_options and replaced it with shlex.split(). The annoying
2036 2037 part was that in Python 2.2, shlex.split() doesn't exist, so I had
2037 2038 to backport it from 2.3, with several frail hacks (the shlex
2038 2039 module is rather limited in 2.2). Thanks to a suggestion by Ville
2039 2040 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
2040 2041 problem.
2041 2042
2042 2043 (Magic.magic_system_verbose): new toggle to print the actual
2043 2044 system calls made by ipython. Mainly for debugging purposes.
2044 2045
2045 2046 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
2046 2047 doesn't support persistence. Reported (and fix suggested) by
2047 2048 Travis Caldwell <travis_caldwell2000@yahoo.com>.
2048 2049
2049 2050 2004-06-26 Fernando Perez <fperez@colorado.edu>
2050 2051
2051 2052 * IPython/Logger.py (Logger.log): fix to handle correctly empty
2052 2053 continue prompts.
2053 2054
2054 2055 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
2055 2056 function (basically a big docstring) and a few more things here to
2056 2057 speedup startup. pysh.py is now very lightweight. We want because
2057 2058 it gets execfile'd, while InterpreterExec gets imported, so
2058 2059 byte-compilation saves time.
2059 2060
2060 2061 2004-06-25 Fernando Perez <fperez@colorado.edu>
2061 2062
2062 2063 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
2063 2064 -NUM', which was recently broken.
2064 2065
2065 2066 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
2066 2067 in multi-line input (but not !!, which doesn't make sense there).
2067 2068
2068 2069 * IPython/UserConfig/ipythonrc: made autoindent on by default.
2069 2070 It's just too useful, and people can turn it off in the less
2070 2071 common cases where it's a problem.
2071 2072
2072 2073 2004-06-24 Fernando Perez <fperez@colorado.edu>
2073 2074
2074 2075 * IPython/iplib.py (InteractiveShell._prefilter): big change -
2075 2076 special syntaxes (like alias calling) is now allied in multi-line
2076 2077 input. This is still _very_ experimental, but it's necessary for
2077 2078 efficient shell usage combining python looping syntax with system
2078 2079 calls. For now it's restricted to aliases, I don't think it
2079 2080 really even makes sense to have this for magics.
2080 2081
2081 2082 2004-06-23 Fernando Perez <fperez@colorado.edu>
2082 2083
2083 2084 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
2084 2085 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
2085 2086
2086 2087 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
2087 2088 extensions under Windows (after code sent by Gary Bishop). The
2088 2089 extensions considered 'executable' are stored in IPython's rc
2089 2090 structure as win_exec_ext.
2090 2091
2091 2092 * IPython/genutils.py (shell): new function, like system() but
2092 2093 without return value. Very useful for interactive shell work.
2093 2094
2094 2095 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
2095 2096 delete aliases.
2096 2097
2097 2098 * IPython/iplib.py (InteractiveShell.alias_table_update): make
2098 2099 sure that the alias table doesn't contain python keywords.
2099 2100
2100 2101 2004-06-21 Fernando Perez <fperez@colorado.edu>
2101 2102
2102 2103 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
2103 2104 non-existent items are found in $PATH. Reported by Thorsten.
2104 2105
2105 2106 2004-06-20 Fernando Perez <fperez@colorado.edu>
2106 2107
2107 2108 * IPython/iplib.py (complete): modified the completer so that the
2108 2109 order of priorities can be easily changed at runtime.
2109 2110
2110 2111 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
2111 2112 Modified to auto-execute all lines beginning with '~', '/' or '.'.
2112 2113
2113 2114 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
2114 2115 expand Python variables prepended with $ in all system calls. The
2115 2116 same was done to InteractiveShell.handle_shell_escape. Now all
2116 2117 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
2117 2118 expansion of python variables and expressions according to the
2118 2119 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
2119 2120
2120 2121 Though PEP-215 has been rejected, a similar (but simpler) one
2121 2122 seems like it will go into Python 2.4, PEP-292 -
2122 2123 http://www.python.org/peps/pep-0292.html.
2123 2124
2124 2125 I'll keep the full syntax of PEP-215, since IPython has since the
2125 2126 start used Ka-Ping Yee's reference implementation discussed there
2126 2127 (Itpl), and I actually like the powerful semantics it offers.
2127 2128
2128 2129 In order to access normal shell variables, the $ has to be escaped
2129 2130 via an extra $. For example:
2130 2131
2131 2132 In [7]: PATH='a python variable'
2132 2133
2133 2134 In [8]: !echo $PATH
2134 2135 a python variable
2135 2136
2136 2137 In [9]: !echo $$PATH
2137 2138 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2138 2139
2139 2140 (Magic.parse_options): escape $ so the shell doesn't evaluate
2140 2141 things prematurely.
2141 2142
2142 2143 * IPython/iplib.py (InteractiveShell.call_alias): added the
2143 2144 ability for aliases to expand python variables via $.
2144 2145
2145 2146 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
2146 2147 system, now there's a @rehash/@rehashx pair of magics. These work
2147 2148 like the csh rehash command, and can be invoked at any time. They
2148 2149 build a table of aliases to everything in the user's $PATH
2149 2150 (@rehash uses everything, @rehashx is slower but only adds
2150 2151 executable files). With this, the pysh.py-based shell profile can
2151 2152 now simply call rehash upon startup, and full access to all
2152 2153 programs in the user's path is obtained.
2153 2154
2154 2155 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
2155 2156 functionality is now fully in place. I removed the old dynamic
2156 2157 code generation based approach, in favor of a much lighter one
2157 2158 based on a simple dict. The advantage is that this allows me to
2158 2159 now have thousands of aliases with negligible cost (unthinkable
2159 2160 with the old system).
2160 2161
2161 2162 2004-06-19 Fernando Perez <fperez@colorado.edu>
2162 2163
2163 2164 * IPython/iplib.py (__init__): extended MagicCompleter class to
2164 2165 also complete (last in priority) on user aliases.
2165 2166
2166 2167 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
2167 2168 call to eval.
2168 2169 (ItplNS.__init__): Added a new class which functions like Itpl,
2169 2170 but allows configuring the namespace for the evaluation to occur
2170 2171 in.
2171 2172
2172 2173 2004-06-18 Fernando Perez <fperez@colorado.edu>
2173 2174
2174 2175 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
2175 2176 better message when 'exit' or 'quit' are typed (a common newbie
2176 2177 confusion).
2177 2178
2178 2179 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
2179 2180 check for Windows users.
2180 2181
2181 2182 * IPython/iplib.py (InteractiveShell.user_setup): removed
2182 2183 disabling of colors for Windows. I'll test at runtime and issue a
2183 2184 warning if Gary's readline isn't found, as to nudge users to
2184 2185 download it.
2185 2186
2186 2187 2004-06-16 Fernando Perez <fperez@colorado.edu>
2187 2188
2188 2189 * IPython/genutils.py (Stream.__init__): changed to print errors
2189 2190 to sys.stderr. I had a circular dependency here. Now it's
2190 2191 possible to run ipython as IDLE's shell (consider this pre-alpha,
2191 2192 since true stdout things end up in the starting terminal instead
2192 2193 of IDLE's out).
2193 2194
2194 2195 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
2195 2196 users who haven't # updated their prompt_in2 definitions. Remove
2196 2197 eventually.
2197 2198 (multiple_replace): added credit to original ASPN recipe.
2198 2199
2199 2200 2004-06-15 Fernando Perez <fperez@colorado.edu>
2200 2201
2201 2202 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
2202 2203 list of auto-defined aliases.
2203 2204
2204 2205 2004-06-13 Fernando Perez <fperez@colorado.edu>
2205 2206
2206 2207 * setup.py (scriptfiles): Don't trigger win_post_install unless an
2207 2208 install was really requested (so setup.py can be used for other
2208 2209 things under Windows).
2209 2210
2210 2211 2004-06-10 Fernando Perez <fperez@colorado.edu>
2211 2212
2212 2213 * IPython/Logger.py (Logger.create_log): Manually remove any old
2213 2214 backup, since os.remove may fail under Windows. Fixes bug
2214 2215 reported by Thorsten.
2215 2216
2216 2217 2004-06-09 Fernando Perez <fperez@colorado.edu>
2217 2218
2218 2219 * examples/example-embed.py: fixed all references to %n (replaced
2219 2220 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
2220 2221 for all examples and the manual as well.
2221 2222
2222 2223 2004-06-08 Fernando Perez <fperez@colorado.edu>
2223 2224
2224 2225 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2225 2226 alignment and color management. All 3 prompt subsystems now
2226 2227 inherit from BasePrompt.
2227 2228
2228 2229 * tools/release: updates for windows installer build and tag rpms
2229 2230 with python version (since paths are fixed).
2230 2231
2231 2232 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2232 2233 which will become eventually obsolete. Also fixed the default
2233 2234 prompt_in2 to use \D, so at least new users start with the correct
2234 2235 defaults.
2235 2236 WARNING: Users with existing ipythonrc files will need to apply
2236 2237 this fix manually!
2237 2238
2238 2239 * setup.py: make windows installer (.exe). This is finally the
2239 2240 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2240 2241 which I hadn't included because it required Python 2.3 (or recent
2241 2242 distutils).
2242 2243
2243 2244 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2244 2245 usage of new '\D' escape.
2245 2246
2246 2247 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2247 2248 lacks os.getuid())
2248 2249 (CachedOutput.set_colors): Added the ability to turn coloring
2249 2250 on/off with @colors even for manually defined prompt colors. It
2250 2251 uses a nasty global, but it works safely and via the generic color
2251 2252 handling mechanism.
2252 2253 (Prompt2.__init__): Introduced new escape '\D' for continuation
2253 2254 prompts. It represents the counter ('\#') as dots.
2254 2255 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2255 2256 need to update their ipythonrc files and replace '%n' with '\D' in
2256 2257 their prompt_in2 settings everywhere. Sorry, but there's
2257 2258 otherwise no clean way to get all prompts to properly align. The
2258 2259 ipythonrc shipped with IPython has been updated.
2259 2260
2260 2261 2004-06-07 Fernando Perez <fperez@colorado.edu>
2261 2262
2262 2263 * setup.py (isfile): Pass local_icons option to latex2html, so the
2263 2264 resulting HTML file is self-contained. Thanks to
2264 2265 dryice-AT-liu.com.cn for the tip.
2265 2266
2266 2267 * pysh.py: I created a new profile 'shell', which implements a
2267 2268 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2268 2269 system shell, nor will it become one anytime soon. It's mainly
2269 2270 meant to illustrate the use of the new flexible bash-like prompts.
2270 2271 I guess it could be used by hardy souls for true shell management,
2271 2272 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2272 2273 profile. This uses the InterpreterExec extension provided by
2273 2274 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2274 2275
2275 2276 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2276 2277 auto-align itself with the length of the previous input prompt
2277 2278 (taking into account the invisible color escapes).
2278 2279 (CachedOutput.__init__): Large restructuring of this class. Now
2279 2280 all three prompts (primary1, primary2, output) are proper objects,
2280 2281 managed by the 'parent' CachedOutput class. The code is still a
2281 2282 bit hackish (all prompts share state via a pointer to the cache),
2282 2283 but it's overall far cleaner than before.
2283 2284
2284 2285 * IPython/genutils.py (getoutputerror): modified to add verbose,
2285 2286 debug and header options. This makes the interface of all getout*
2286 2287 functions uniform.
2287 2288 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2288 2289
2289 2290 * IPython/Magic.py (Magic.default_option): added a function to
2290 2291 allow registering default options for any magic command. This
2291 2292 makes it easy to have profiles which customize the magics globally
2292 2293 for a certain use. The values set through this function are
2293 2294 picked up by the parse_options() method, which all magics should
2294 2295 use to parse their options.
2295 2296
2296 2297 * IPython/genutils.py (warn): modified the warnings framework to
2297 2298 use the Term I/O class. I'm trying to slowly unify all of
2298 2299 IPython's I/O operations to pass through Term.
2299 2300
2300 2301 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2301 2302 the secondary prompt to correctly match the length of the primary
2302 2303 one for any prompt. Now multi-line code will properly line up
2303 2304 even for path dependent prompts, such as the new ones available
2304 2305 via the prompt_specials.
2305 2306
2306 2307 2004-06-06 Fernando Perez <fperez@colorado.edu>
2307 2308
2308 2309 * IPython/Prompts.py (prompt_specials): Added the ability to have
2309 2310 bash-like special sequences in the prompts, which get
2310 2311 automatically expanded. Things like hostname, current working
2311 2312 directory and username are implemented already, but it's easy to
2312 2313 add more in the future. Thanks to a patch by W.J. van der Laan
2313 2314 <gnufnork-AT-hetdigitalegat.nl>
2314 2315 (prompt_specials): Added color support for prompt strings, so
2315 2316 users can define arbitrary color setups for their prompts.
2316 2317
2317 2318 2004-06-05 Fernando Perez <fperez@colorado.edu>
2318 2319
2319 2320 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2320 2321 code to load Gary Bishop's readline and configure it
2321 2322 automatically. Thanks to Gary for help on this.
2322 2323
2323 2324 2004-06-01 Fernando Perez <fperez@colorado.edu>
2324 2325
2325 2326 * IPython/Logger.py (Logger.create_log): fix bug for logging
2326 2327 with no filename (previous fix was incomplete).
2327 2328
2328 2329 2004-05-25 Fernando Perez <fperez@colorado.edu>
2329 2330
2330 2331 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2331 2332 parens would get passed to the shell.
2332 2333
2333 2334 2004-05-20 Fernando Perez <fperez@colorado.edu>
2334 2335
2335 2336 * IPython/Magic.py (Magic.magic_prun): changed default profile
2336 2337 sort order to 'time' (the more common profiling need).
2337 2338
2338 2339 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2339 2340 so that source code shown is guaranteed in sync with the file on
2340 2341 disk (also changed in psource). Similar fix to the one for
2341 2342 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2342 2343 <yann.ledu-AT-noos.fr>.
2343 2344
2344 2345 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2345 2346 with a single option would not be correctly parsed. Closes
2346 2347 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2347 2348 introduced in 0.6.0 (on 2004-05-06).
2348 2349
2349 2350 2004-05-13 *** Released version 0.6.0
2350 2351
2351 2352 2004-05-13 Fernando Perez <fperez@colorado.edu>
2352 2353
2353 2354 * debian/: Added debian/ directory to CVS, so that debian support
2354 2355 is publicly accessible. The debian package is maintained by Jack
2355 2356 Moffit <jack-AT-xiph.org>.
2356 2357
2357 2358 * Documentation: included the notes about an ipython-based system
2358 2359 shell (the hypothetical 'pysh') into the new_design.pdf document,
2359 2360 so that these ideas get distributed to users along with the
2360 2361 official documentation.
2361 2362
2362 2363 2004-05-10 Fernando Perez <fperez@colorado.edu>
2363 2364
2364 2365 * IPython/Logger.py (Logger.create_log): fix recently introduced
2365 2366 bug (misindented line) where logstart would fail when not given an
2366 2367 explicit filename.
2367 2368
2368 2369 2004-05-09 Fernando Perez <fperez@colorado.edu>
2369 2370
2370 2371 * IPython/Magic.py (Magic.parse_options): skip system call when
2371 2372 there are no options to look for. Faster, cleaner for the common
2372 2373 case.
2373 2374
2374 2375 * Documentation: many updates to the manual: describing Windows
2375 2376 support better, Gnuplot updates, credits, misc small stuff. Also
2376 2377 updated the new_design doc a bit.
2377 2378
2378 2379 2004-05-06 *** Released version 0.6.0.rc1
2379 2380
2380 2381 2004-05-06 Fernando Perez <fperez@colorado.edu>
2381 2382
2382 2383 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2383 2384 operations to use the vastly more efficient list/''.join() method.
2384 2385 (FormattedTB.text): Fix
2385 2386 http://www.scipy.net/roundup/ipython/issue12 - exception source
2386 2387 extract not updated after reload. Thanks to Mike Salib
2387 2388 <msalib-AT-mit.edu> for pinning the source of the problem.
2388 2389 Fortunately, the solution works inside ipython and doesn't require
2389 2390 any changes to python proper.
2390 2391
2391 2392 * IPython/Magic.py (Magic.parse_options): Improved to process the
2392 2393 argument list as a true shell would (by actually using the
2393 2394 underlying system shell). This way, all @magics automatically get
2394 2395 shell expansion for variables. Thanks to a comment by Alex
2395 2396 Schmolck.
2396 2397
2397 2398 2004-04-04 Fernando Perez <fperez@colorado.edu>
2398 2399
2399 2400 * IPython/iplib.py (InteractiveShell.interact): Added a special
2400 2401 trap for a debugger quit exception, which is basically impossible
2401 2402 to handle by normal mechanisms, given what pdb does to the stack.
2402 2403 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2403 2404
2404 2405 2004-04-03 Fernando Perez <fperez@colorado.edu>
2405 2406
2406 2407 * IPython/genutils.py (Term): Standardized the names of the Term
2407 2408 class streams to cin/cout/cerr, following C++ naming conventions
2408 2409 (I can't use in/out/err because 'in' is not a valid attribute
2409 2410 name).
2410 2411
2411 2412 * IPython/iplib.py (InteractiveShell.interact): don't increment
2412 2413 the prompt if there's no user input. By Daniel 'Dang' Griffith
2413 2414 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2414 2415 Francois Pinard.
2415 2416
2416 2417 2004-04-02 Fernando Perez <fperez@colorado.edu>
2417 2418
2418 2419 * IPython/genutils.py (Stream.__init__): Modified to survive at
2419 2420 least importing in contexts where stdin/out/err aren't true file
2420 2421 objects, such as PyCrust (they lack fileno() and mode). However,
2421 2422 the recovery facilities which rely on these things existing will
2422 2423 not work.
2423 2424
2424 2425 2004-04-01 Fernando Perez <fperez@colorado.edu>
2425 2426
2426 2427 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2427 2428 use the new getoutputerror() function, so it properly
2428 2429 distinguishes stdout/err.
2429 2430
2430 2431 * IPython/genutils.py (getoutputerror): added a function to
2431 2432 capture separately the standard output and error of a command.
2432 2433 After a comment from dang on the mailing lists. This code is
2433 2434 basically a modified version of commands.getstatusoutput(), from
2434 2435 the standard library.
2435 2436
2436 2437 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2437 2438 '!!' as a special syntax (shorthand) to access @sx.
2438 2439
2439 2440 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2440 2441 command and return its output as a list split on '\n'.
2441 2442
2442 2443 2004-03-31 Fernando Perez <fperez@colorado.edu>
2443 2444
2444 2445 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2445 2446 method to dictionaries used as FakeModule instances if they lack
2446 2447 it. At least pydoc in python2.3 breaks for runtime-defined
2447 2448 functions without this hack. At some point I need to _really_
2448 2449 understand what FakeModule is doing, because it's a gross hack.
2449 2450 But it solves Arnd's problem for now...
2450 2451
2451 2452 2004-02-27 Fernando Perez <fperez@colorado.edu>
2452 2453
2453 2454 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2454 2455 mode would behave erratically. Also increased the number of
2455 2456 possible logs in rotate mod to 999. Thanks to Rod Holland
2456 2457 <rhh@StructureLABS.com> for the report and fixes.
2457 2458
2458 2459 2004-02-26 Fernando Perez <fperez@colorado.edu>
2459 2460
2460 2461 * IPython/genutils.py (page): Check that the curses module really
2461 2462 has the initscr attribute before trying to use it. For some
2462 2463 reason, the Solaris curses module is missing this. I think this
2463 2464 should be considered a Solaris python bug, but I'm not sure.
2464 2465
2465 2466 2004-01-17 Fernando Perez <fperez@colorado.edu>
2466 2467
2467 2468 * IPython/genutils.py (Stream.__init__): Changes to try to make
2468 2469 ipython robust against stdin/out/err being closed by the user.
2469 2470 This is 'user error' (and blocks a normal python session, at least
2470 2471 the stdout case). However, Ipython should be able to survive such
2471 2472 instances of abuse as gracefully as possible. To simplify the
2472 2473 coding and maintain compatibility with Gary Bishop's Term
2473 2474 contributions, I've made use of classmethods for this. I think
2474 2475 this introduces a dependency on python 2.2.
2475 2476
2476 2477 2004-01-13 Fernando Perez <fperez@colorado.edu>
2477 2478
2478 2479 * IPython/numutils.py (exp_safe): simplified the code a bit and
2479 2480 removed the need for importing the kinds module altogether.
2480 2481
2481 2482 2004-01-06 Fernando Perez <fperez@colorado.edu>
2482 2483
2483 2484 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2484 2485 a magic function instead, after some community feedback. No
2485 2486 special syntax will exist for it, but its name is deliberately
2486 2487 very short.
2487 2488
2488 2489 2003-12-20 Fernando Perez <fperez@colorado.edu>
2489 2490
2490 2491 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2491 2492 new functionality, to automagically assign the result of a shell
2492 2493 command to a variable. I'll solicit some community feedback on
2493 2494 this before making it permanent.
2494 2495
2495 2496 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2496 2497 requested about callables for which inspect couldn't obtain a
2497 2498 proper argspec. Thanks to a crash report sent by Etienne
2498 2499 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2499 2500
2500 2501 2003-12-09 Fernando Perez <fperez@colorado.edu>
2501 2502
2502 2503 * IPython/genutils.py (page): patch for the pager to work across
2503 2504 various versions of Windows. By Gary Bishop.
2504 2505
2505 2506 2003-12-04 Fernando Perez <fperez@colorado.edu>
2506 2507
2507 2508 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2508 2509 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2509 2510 While I tested this and it looks ok, there may still be corner
2510 2511 cases I've missed.
2511 2512
2512 2513 2003-12-01 Fernando Perez <fperez@colorado.edu>
2513 2514
2514 2515 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2515 2516 where a line like 'p,q=1,2' would fail because the automagic
2516 2517 system would be triggered for @p.
2517 2518
2518 2519 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2519 2520 cleanups, code unmodified.
2520 2521
2521 2522 * IPython/genutils.py (Term): added a class for IPython to handle
2522 2523 output. In most cases it will just be a proxy for stdout/err, but
2523 2524 having this allows modifications to be made for some platforms,
2524 2525 such as handling color escapes under Windows. All of this code
2525 2526 was contributed by Gary Bishop, with minor modifications by me.
2526 2527 The actual changes affect many files.
2527 2528
2528 2529 2003-11-30 Fernando Perez <fperez@colorado.edu>
2529 2530
2530 2531 * IPython/iplib.py (file_matches): new completion code, courtesy
2531 2532 of Jeff Collins. This enables filename completion again under
2532 2533 python 2.3, which disabled it at the C level.
2533 2534
2534 2535 2003-11-11 Fernando Perez <fperez@colorado.edu>
2535 2536
2536 2537 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2537 2538 for Numeric.array(map(...)), but often convenient.
2538 2539
2539 2540 2003-11-05 Fernando Perez <fperez@colorado.edu>
2540 2541
2541 2542 * IPython/numutils.py (frange): Changed a call from int() to
2542 2543 int(round()) to prevent a problem reported with arange() in the
2543 2544 numpy list.
2544 2545
2545 2546 2003-10-06 Fernando Perez <fperez@colorado.edu>
2546 2547
2547 2548 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2548 2549 prevent crashes if sys lacks an argv attribute (it happens with
2549 2550 embedded interpreters which build a bare-bones sys module).
2550 2551 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2551 2552
2552 2553 2003-09-24 Fernando Perez <fperez@colorado.edu>
2553 2554
2554 2555 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2555 2556 to protect against poorly written user objects where __getattr__
2556 2557 raises exceptions other than AttributeError. Thanks to a bug
2557 2558 report by Oliver Sander <osander-AT-gmx.de>.
2558 2559
2559 2560 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2560 2561 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2561 2562
2562 2563 2003-09-09 Fernando Perez <fperez@colorado.edu>
2563 2564
2564 2565 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2565 2566 unpacking a list whith a callable as first element would
2566 2567 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2567 2568 Collins.
2568 2569
2569 2570 2003-08-25 *** Released version 0.5.0
2570 2571
2571 2572 2003-08-22 Fernando Perez <fperez@colorado.edu>
2572 2573
2573 2574 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2574 2575 improperly defined user exceptions. Thanks to feedback from Mark
2575 2576 Russell <mrussell-AT-verio.net>.
2576 2577
2577 2578 2003-08-20 Fernando Perez <fperez@colorado.edu>
2578 2579
2579 2580 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2580 2581 printing so that it would print multi-line string forms starting
2581 2582 with a new line. This way the formatting is better respected for
2582 2583 objects which work hard to make nice string forms.
2583 2584
2584 2585 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2585 2586 autocall would overtake data access for objects with both
2586 2587 __getitem__ and __call__.
2587 2588
2588 2589 2003-08-19 *** Released version 0.5.0-rc1
2589 2590
2590 2591 2003-08-19 Fernando Perez <fperez@colorado.edu>
2591 2592
2592 2593 * IPython/deep_reload.py (load_tail): single tiny change here
2593 2594 seems to fix the long-standing bug of dreload() failing to work
2594 2595 for dotted names. But this module is pretty tricky, so I may have
2595 2596 missed some subtlety. Needs more testing!.
2596 2597
2597 2598 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2598 2599 exceptions which have badly implemented __str__ methods.
2599 2600 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2600 2601 which I've been getting reports about from Python 2.3 users. I
2601 2602 wish I had a simple test case to reproduce the problem, so I could
2602 2603 either write a cleaner workaround or file a bug report if
2603 2604 necessary.
2604 2605
2605 2606 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2606 2607 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2607 2608 a bug report by Tjabo Kloppenburg.
2608 2609
2609 2610 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2610 2611 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2611 2612 seems rather unstable. Thanks to a bug report by Tjabo
2612 2613 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2613 2614
2614 2615 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2615 2616 this out soon because of the critical fixes in the inner loop for
2616 2617 generators.
2617 2618
2618 2619 * IPython/Magic.py (Magic.getargspec): removed. This (and
2619 2620 _get_def) have been obsoleted by OInspect for a long time, I
2620 2621 hadn't noticed that they were dead code.
2621 2622 (Magic._ofind): restored _ofind functionality for a few literals
2622 2623 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2623 2624 for things like "hello".capitalize?, since that would require a
2624 2625 potentially dangerous eval() again.
2625 2626
2626 2627 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2627 2628 logic a bit more to clean up the escapes handling and minimize the
2628 2629 use of _ofind to only necessary cases. The interactive 'feel' of
2629 2630 IPython should have improved quite a bit with the changes in
2630 2631 _prefilter and _ofind (besides being far safer than before).
2631 2632
2632 2633 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2633 2634 obscure, never reported). Edit would fail to find the object to
2634 2635 edit under some circumstances.
2635 2636 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2636 2637 which were causing double-calling of generators. Those eval calls
2637 2638 were _very_ dangerous, since code with side effects could be
2638 2639 triggered. As they say, 'eval is evil'... These were the
2639 2640 nastiest evals in IPython. Besides, _ofind is now far simpler,
2640 2641 and it should also be quite a bit faster. Its use of inspect is
2641 2642 also safer, so perhaps some of the inspect-related crashes I've
2642 2643 seen lately with Python 2.3 might be taken care of. That will
2643 2644 need more testing.
2644 2645
2645 2646 2003-08-17 Fernando Perez <fperez@colorado.edu>
2646 2647
2647 2648 * IPython/iplib.py (InteractiveShell._prefilter): significant
2648 2649 simplifications to the logic for handling user escapes. Faster
2649 2650 and simpler code.
2650 2651
2651 2652 2003-08-14 Fernando Perez <fperez@colorado.edu>
2652 2653
2653 2654 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2654 2655 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2655 2656 but it should be quite a bit faster. And the recursive version
2656 2657 generated O(log N) intermediate storage for all rank>1 arrays,
2657 2658 even if they were contiguous.
2658 2659 (l1norm): Added this function.
2659 2660 (norm): Added this function for arbitrary norms (including
2660 2661 l-infinity). l1 and l2 are still special cases for convenience
2661 2662 and speed.
2662 2663
2663 2664 2003-08-03 Fernando Perez <fperez@colorado.edu>
2664 2665
2665 2666 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2666 2667 exceptions, which now raise PendingDeprecationWarnings in Python
2667 2668 2.3. There were some in Magic and some in Gnuplot2.
2668 2669
2669 2670 2003-06-30 Fernando Perez <fperez@colorado.edu>
2670 2671
2671 2672 * IPython/genutils.py (page): modified to call curses only for
2672 2673 terminals where TERM=='xterm'. After problems under many other
2673 2674 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2674 2675
2675 2676 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2676 2677 would be triggered when readline was absent. This was just an old
2677 2678 debugging statement I'd forgotten to take out.
2678 2679
2679 2680 2003-06-20 Fernando Perez <fperez@colorado.edu>
2680 2681
2681 2682 * IPython/genutils.py (clock): modified to return only user time
2682 2683 (not counting system time), after a discussion on scipy. While
2683 2684 system time may be a useful quantity occasionally, it may much
2684 2685 more easily be skewed by occasional swapping or other similar
2685 2686 activity.
2686 2687
2687 2688 2003-06-05 Fernando Perez <fperez@colorado.edu>
2688 2689
2689 2690 * IPython/numutils.py (identity): new function, for building
2690 2691 arbitrary rank Kronecker deltas (mostly backwards compatible with
2691 2692 Numeric.identity)
2692 2693
2693 2694 2003-06-03 Fernando Perez <fperez@colorado.edu>
2694 2695
2695 2696 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2696 2697 arguments passed to magics with spaces, to allow trailing '\' to
2697 2698 work normally (mainly for Windows users).
2698 2699
2699 2700 2003-05-29 Fernando Perez <fperez@colorado.edu>
2700 2701
2701 2702 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2702 2703 instead of pydoc.help. This fixes a bizarre behavior where
2703 2704 printing '%s' % locals() would trigger the help system. Now
2704 2705 ipython behaves like normal python does.
2705 2706
2706 2707 Note that if one does 'from pydoc import help', the bizarre
2707 2708 behavior returns, but this will also happen in normal python, so
2708 2709 it's not an ipython bug anymore (it has to do with how pydoc.help
2709 2710 is implemented).
2710 2711
2711 2712 2003-05-22 Fernando Perez <fperez@colorado.edu>
2712 2713
2713 2714 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2714 2715 return [] instead of None when nothing matches, also match to end
2715 2716 of line. Patch by Gary Bishop.
2716 2717
2717 2718 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2718 2719 protection as before, for files passed on the command line. This
2719 2720 prevents the CrashHandler from kicking in if user files call into
2720 2721 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2721 2722 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2722 2723
2723 2724 2003-05-20 *** Released version 0.4.0
2724 2725
2725 2726 2003-05-20 Fernando Perez <fperez@colorado.edu>
2726 2727
2727 2728 * setup.py: added support for manpages. It's a bit hackish b/c of
2728 2729 a bug in the way the bdist_rpm distutils target handles gzipped
2729 2730 manpages, but it works. After a patch by Jack.
2730 2731
2731 2732 2003-05-19 Fernando Perez <fperez@colorado.edu>
2732 2733
2733 2734 * IPython/numutils.py: added a mockup of the kinds module, since
2734 2735 it was recently removed from Numeric. This way, numutils will
2735 2736 work for all users even if they are missing kinds.
2736 2737
2737 2738 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2738 2739 failure, which can occur with SWIG-wrapped extensions. After a
2739 2740 crash report from Prabhu.
2740 2741
2741 2742 2003-05-16 Fernando Perez <fperez@colorado.edu>
2742 2743
2743 2744 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2744 2745 protect ipython from user code which may call directly
2745 2746 sys.excepthook (this looks like an ipython crash to the user, even
2746 2747 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2747 2748 This is especially important to help users of WxWindows, but may
2748 2749 also be useful in other cases.
2749 2750
2750 2751 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2751 2752 an optional tb_offset to be specified, and to preserve exception
2752 2753 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2753 2754
2754 2755 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2755 2756
2756 2757 2003-05-15 Fernando Perez <fperez@colorado.edu>
2757 2758
2758 2759 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2759 2760 installing for a new user under Windows.
2760 2761
2761 2762 2003-05-12 Fernando Perez <fperez@colorado.edu>
2762 2763
2763 2764 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2764 2765 handler for Emacs comint-based lines. Currently it doesn't do
2765 2766 much (but importantly, it doesn't update the history cache). In
2766 2767 the future it may be expanded if Alex needs more functionality
2767 2768 there.
2768 2769
2769 2770 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2770 2771 info to crash reports.
2771 2772
2772 2773 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2773 2774 just like Python's -c. Also fixed crash with invalid -color
2774 2775 option value at startup. Thanks to Will French
2775 2776 <wfrench-AT-bestweb.net> for the bug report.
2776 2777
2777 2778 2003-05-09 Fernando Perez <fperez@colorado.edu>
2778 2779
2779 2780 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2780 2781 to EvalDict (it's a mapping, after all) and simplified its code
2781 2782 quite a bit, after a nice discussion on c.l.py where Gustavo
2782 2783 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2783 2784
2784 2785 2003-04-30 Fernando Perez <fperez@colorado.edu>
2785 2786
2786 2787 * IPython/genutils.py (timings_out): modified it to reduce its
2787 2788 overhead in the common reps==1 case.
2788 2789
2789 2790 2003-04-29 Fernando Perez <fperez@colorado.edu>
2790 2791
2791 2792 * IPython/genutils.py (timings_out): Modified to use the resource
2792 2793 module, which avoids the wraparound problems of time.clock().
2793 2794
2794 2795 2003-04-17 *** Released version 0.2.15pre4
2795 2796
2796 2797 2003-04-17 Fernando Perez <fperez@colorado.edu>
2797 2798
2798 2799 * setup.py (scriptfiles): Split windows-specific stuff over to a
2799 2800 separate file, in an attempt to have a Windows GUI installer.
2800 2801 That didn't work, but part of the groundwork is done.
2801 2802
2802 2803 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2803 2804 indent/unindent with 4 spaces. Particularly useful in combination
2804 2805 with the new auto-indent option.
2805 2806
2806 2807 2003-04-16 Fernando Perez <fperez@colorado.edu>
2807 2808
2808 2809 * IPython/Magic.py: various replacements of self.rc for
2809 2810 self.shell.rc. A lot more remains to be done to fully disentangle
2810 2811 this class from the main Shell class.
2811 2812
2812 2813 * IPython/GnuplotRuntime.py: added checks for mouse support so
2813 2814 that we don't try to enable it if the current gnuplot doesn't
2814 2815 really support it. Also added checks so that we don't try to
2815 2816 enable persist under Windows (where Gnuplot doesn't recognize the
2816 2817 option).
2817 2818
2818 2819 * IPython/iplib.py (InteractiveShell.interact): Added optional
2819 2820 auto-indenting code, after a patch by King C. Shu
2820 2821 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2821 2822 get along well with pasting indented code. If I ever figure out
2822 2823 how to make that part go well, it will become on by default.
2823 2824
2824 2825 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2825 2826 crash ipython if there was an unmatched '%' in the user's prompt
2826 2827 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2827 2828
2828 2829 * IPython/iplib.py (InteractiveShell.interact): removed the
2829 2830 ability to ask the user whether he wants to crash or not at the
2830 2831 'last line' exception handler. Calling functions at that point
2831 2832 changes the stack, and the error reports would have incorrect
2832 2833 tracebacks.
2833 2834
2834 2835 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2835 2836 pass through a peger a pretty-printed form of any object. After a
2836 2837 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2837 2838
2838 2839 2003-04-14 Fernando Perez <fperez@colorado.edu>
2839 2840
2840 2841 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2841 2842 all files in ~ would be modified at first install (instead of
2842 2843 ~/.ipython). This could be potentially disastrous, as the
2843 2844 modification (make line-endings native) could damage binary files.
2844 2845
2845 2846 2003-04-10 Fernando Perez <fperez@colorado.edu>
2846 2847
2847 2848 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2848 2849 handle only lines which are invalid python. This now means that
2849 2850 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2850 2851 for the bug report.
2851 2852
2852 2853 2003-04-01 Fernando Perez <fperez@colorado.edu>
2853 2854
2854 2855 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2855 2856 where failing to set sys.last_traceback would crash pdb.pm().
2856 2857 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2857 2858 report.
2858 2859
2859 2860 2003-03-25 Fernando Perez <fperez@colorado.edu>
2860 2861
2861 2862 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2862 2863 before printing it (it had a lot of spurious blank lines at the
2863 2864 end).
2864 2865
2865 2866 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2866 2867 output would be sent 21 times! Obviously people don't use this
2867 2868 too often, or I would have heard about it.
2868 2869
2869 2870 2003-03-24 Fernando Perez <fperez@colorado.edu>
2870 2871
2871 2872 * setup.py (scriptfiles): renamed the data_files parameter from
2872 2873 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2873 2874 for the patch.
2874 2875
2875 2876 2003-03-20 Fernando Perez <fperez@colorado.edu>
2876 2877
2877 2878 * IPython/genutils.py (error): added error() and fatal()
2878 2879 functions.
2879 2880
2880 2881 2003-03-18 *** Released version 0.2.15pre3
2881 2882
2882 2883 2003-03-18 Fernando Perez <fperez@colorado.edu>
2883 2884
2884 2885 * setupext/install_data_ext.py
2885 2886 (install_data_ext.initialize_options): Class contributed by Jack
2886 2887 Moffit for fixing the old distutils hack. He is sending this to
2887 2888 the distutils folks so in the future we may not need it as a
2888 2889 private fix.
2889 2890
2890 2891 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2891 2892 changes for Debian packaging. See his patch for full details.
2892 2893 The old distutils hack of making the ipythonrc* files carry a
2893 2894 bogus .py extension is gone, at last. Examples were moved to a
2894 2895 separate subdir under doc/, and the separate executable scripts
2895 2896 now live in their own directory. Overall a great cleanup. The
2896 2897 manual was updated to use the new files, and setup.py has been
2897 2898 fixed for this setup.
2898 2899
2899 2900 * IPython/PyColorize.py (Parser.usage): made non-executable and
2900 2901 created a pycolor wrapper around it to be included as a script.
2901 2902
2902 2903 2003-03-12 *** Released version 0.2.15pre2
2903 2904
2904 2905 2003-03-12 Fernando Perez <fperez@colorado.edu>
2905 2906
2906 2907 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2907 2908 long-standing problem with garbage characters in some terminals.
2908 2909 The issue was really that the \001 and \002 escapes must _only_ be
2909 2910 passed to input prompts (which call readline), but _never_ to
2910 2911 normal text to be printed on screen. I changed ColorANSI to have
2911 2912 two classes: TermColors and InputTermColors, each with the
2912 2913 appropriate escapes for input prompts or normal text. The code in
2913 2914 Prompts.py got slightly more complicated, but this very old and
2914 2915 annoying bug is finally fixed.
2915 2916
2916 2917 All the credit for nailing down the real origin of this problem
2917 2918 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2918 2919 *Many* thanks to him for spending quite a bit of effort on this.
2919 2920
2920 2921 2003-03-05 *** Released version 0.2.15pre1
2921 2922
2922 2923 2003-03-03 Fernando Perez <fperez@colorado.edu>
2923 2924
2924 2925 * IPython/FakeModule.py: Moved the former _FakeModule to a
2925 2926 separate file, because it's also needed by Magic (to fix a similar
2926 2927 pickle-related issue in @run).
2927 2928
2928 2929 2003-03-02 Fernando Perez <fperez@colorado.edu>
2929 2930
2930 2931 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2931 2932 the autocall option at runtime.
2932 2933 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2933 2934 across Magic.py to start separating Magic from InteractiveShell.
2934 2935 (Magic._ofind): Fixed to return proper namespace for dotted
2935 2936 names. Before, a dotted name would always return 'not currently
2936 2937 defined', because it would find the 'parent'. s.x would be found,
2937 2938 but since 'x' isn't defined by itself, it would get confused.
2938 2939 (Magic.magic_run): Fixed pickling problems reported by Ralf
2939 2940 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2940 2941 that I'd used when Mike Heeter reported similar issues at the
2941 2942 top-level, but now for @run. It boils down to injecting the
2942 2943 namespace where code is being executed with something that looks
2943 2944 enough like a module to fool pickle.dump(). Since a pickle stores
2944 2945 a named reference to the importing module, we need this for
2945 2946 pickles to save something sensible.
2946 2947
2947 2948 * IPython/ipmaker.py (make_IPython): added an autocall option.
2948 2949
2949 2950 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2950 2951 the auto-eval code. Now autocalling is an option, and the code is
2951 2952 also vastly safer. There is no more eval() involved at all.
2952 2953
2953 2954 2003-03-01 Fernando Perez <fperez@colorado.edu>
2954 2955
2955 2956 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2956 2957 dict with named keys instead of a tuple.
2957 2958
2958 2959 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2959 2960
2960 2961 * setup.py (make_shortcut): Fixed message about directories
2961 2962 created during Windows installation (the directories were ok, just
2962 2963 the printed message was misleading). Thanks to Chris Liechti
2963 2964 <cliechti-AT-gmx.net> for the heads up.
2964 2965
2965 2966 2003-02-21 Fernando Perez <fperez@colorado.edu>
2966 2967
2967 2968 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2968 2969 of ValueError exception when checking for auto-execution. This
2969 2970 one is raised by things like Numeric arrays arr.flat when the
2970 2971 array is non-contiguous.
2971 2972
2972 2973 2003-01-31 Fernando Perez <fperez@colorado.edu>
2973 2974
2974 2975 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2975 2976 not return any value at all (even though the command would get
2976 2977 executed).
2977 2978 (xsys): Flush stdout right after printing the command to ensure
2978 2979 proper ordering of commands and command output in the total
2979 2980 output.
2980 2981 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2981 2982 system/getoutput as defaults. The old ones are kept for
2982 2983 compatibility reasons, so no code which uses this library needs
2983 2984 changing.
2984 2985
2985 2986 2003-01-27 *** Released version 0.2.14
2986 2987
2987 2988 2003-01-25 Fernando Perez <fperez@colorado.edu>
2988 2989
2989 2990 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2990 2991 functions defined in previous edit sessions could not be re-edited
2991 2992 (because the temp files were immediately removed). Now temp files
2992 2993 are removed only at IPython's exit.
2993 2994 (Magic.magic_run): Improved @run to perform shell-like expansions
2994 2995 on its arguments (~users and $VARS). With this, @run becomes more
2995 2996 like a normal command-line.
2996 2997
2997 2998 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2998 2999 bugs related to embedding and cleaned up that code. A fairly
2999 3000 important one was the impossibility to access the global namespace
3000 3001 through the embedded IPython (only local variables were visible).
3001 3002
3002 3003 2003-01-14 Fernando Perez <fperez@colorado.edu>
3003 3004
3004 3005 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
3005 3006 auto-calling to be a bit more conservative. Now it doesn't get
3006 3007 triggered if any of '!=()<>' are in the rest of the input line, to
3007 3008 allow comparing callables. Thanks to Alex for the heads up.
3008 3009
3009 3010 2003-01-07 Fernando Perez <fperez@colorado.edu>
3010 3011
3011 3012 * IPython/genutils.py (page): fixed estimation of the number of
3012 3013 lines in a string to be paged to simply count newlines. This
3013 3014 prevents over-guessing due to embedded escape sequences. A better
3014 3015 long-term solution would involve stripping out the control chars
3015 3016 for the count, but it's potentially so expensive I just don't
3016 3017 think it's worth doing.
3017 3018
3018 3019 2002-12-19 *** Released version 0.2.14pre50
3019 3020
3020 3021 2002-12-19 Fernando Perez <fperez@colorado.edu>
3021 3022
3022 3023 * tools/release (version): Changed release scripts to inform
3023 3024 Andrea and build a NEWS file with a list of recent changes.
3024 3025
3025 3026 * IPython/ColorANSI.py (__all__): changed terminal detection
3026 3027 code. Seems to work better for xterms without breaking
3027 3028 konsole. Will need more testing to determine if WinXP and Mac OSX
3028 3029 also work ok.
3029 3030
3030 3031 2002-12-18 *** Released version 0.2.14pre49
3031 3032
3032 3033 2002-12-18 Fernando Perez <fperez@colorado.edu>
3033 3034
3034 3035 * Docs: added new info about Mac OSX, from Andrea.
3035 3036
3036 3037 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
3037 3038 allow direct plotting of python strings whose format is the same
3038 3039 of gnuplot data files.
3039 3040
3040 3041 2002-12-16 Fernando Perez <fperez@colorado.edu>
3041 3042
3042 3043 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
3043 3044 value of exit question to be acknowledged.
3044 3045
3045 3046 2002-12-03 Fernando Perez <fperez@colorado.edu>
3046 3047
3047 3048 * IPython/ipmaker.py: removed generators, which had been added
3048 3049 by mistake in an earlier debugging run. This was causing trouble
3049 3050 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
3050 3051 for pointing this out.
3051 3052
3052 3053 2002-11-17 Fernando Perez <fperez@colorado.edu>
3053 3054
3054 3055 * Manual: updated the Gnuplot section.
3055 3056
3056 3057 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
3057 3058 a much better split of what goes in Runtime and what goes in
3058 3059 Interactive.
3059 3060
3060 3061 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
3061 3062 being imported from iplib.
3062 3063
3063 3064 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
3064 3065 for command-passing. Now the global Gnuplot instance is called
3065 3066 'gp' instead of 'g', which was really a far too fragile and
3066 3067 common name.
3067 3068
3068 3069 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
3069 3070 bounding boxes generated by Gnuplot for square plots.
3070 3071
3071 3072 * IPython/genutils.py (popkey): new function added. I should
3072 3073 suggest this on c.l.py as a dict method, it seems useful.
3073 3074
3074 3075 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
3075 3076 to transparently handle PostScript generation. MUCH better than
3076 3077 the previous plot_eps/replot_eps (which I removed now). The code
3077 3078 is also fairly clean and well documented now (including
3078 3079 docstrings).
3079 3080
3080 3081 2002-11-13 Fernando Perez <fperez@colorado.edu>
3081 3082
3082 3083 * IPython/Magic.py (Magic.magic_edit): fixed docstring
3083 3084 (inconsistent with options).
3084 3085
3085 3086 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
3086 3087 manually disabled, I don't know why. Fixed it.
3087 3088 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
3088 3089 eps output.
3089 3090
3090 3091 2002-11-12 Fernando Perez <fperez@colorado.edu>
3091 3092
3092 3093 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
3093 3094 don't propagate up to caller. Fixes crash reported by François
3094 3095 Pinard.
3095 3096
3096 3097 2002-11-09 Fernando Perez <fperez@colorado.edu>
3097 3098
3098 3099 * IPython/ipmaker.py (make_IPython): fixed problem with writing
3099 3100 history file for new users.
3100 3101 (make_IPython): fixed bug where initial install would leave the
3101 3102 user running in the .ipython dir.
3102 3103 (make_IPython): fixed bug where config dir .ipython would be
3103 3104 created regardless of the given -ipythondir option. Thanks to Cory
3104 3105 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
3105 3106
3106 3107 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
3107 3108 type confirmations. Will need to use it in all of IPython's code
3108 3109 consistently.
3109 3110
3110 3111 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
3111 3112 context to print 31 lines instead of the default 5. This will make
3112 3113 the crash reports extremely detailed in case the problem is in
3113 3114 libraries I don't have access to.
3114 3115
3115 3116 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
3116 3117 line of defense' code to still crash, but giving users fair
3117 3118 warning. I don't want internal errors to go unreported: if there's
3118 3119 an internal problem, IPython should crash and generate a full
3119 3120 report.
3120 3121
3121 3122 2002-11-08 Fernando Perez <fperez@colorado.edu>
3122 3123
3123 3124 * IPython/iplib.py (InteractiveShell.interact): added code to trap
3124 3125 otherwise uncaught exceptions which can appear if people set
3125 3126 sys.stdout to something badly broken. Thanks to a crash report
3126 3127 from henni-AT-mail.brainbot.com.
3127 3128
3128 3129 2002-11-04 Fernando Perez <fperez@colorado.edu>
3129 3130
3130 3131 * IPython/iplib.py (InteractiveShell.interact): added
3131 3132 __IPYTHON__active to the builtins. It's a flag which goes on when
3132 3133 the interaction starts and goes off again when it stops. This
3133 3134 allows embedding code to detect being inside IPython. Before this
3134 3135 was done via __IPYTHON__, but that only shows that an IPython
3135 3136 instance has been created.
3136 3137
3137 3138 * IPython/Magic.py (Magic.magic_env): I realized that in a
3138 3139 UserDict, instance.data holds the data as a normal dict. So I
3139 3140 modified @env to return os.environ.data instead of rebuilding a
3140 3141 dict by hand.
3141 3142
3142 3143 2002-11-02 Fernando Perez <fperez@colorado.edu>
3143 3144
3144 3145 * IPython/genutils.py (warn): changed so that level 1 prints no
3145 3146 header. Level 2 is now the default (with 'WARNING' header, as
3146 3147 before). I think I tracked all places where changes were needed in
3147 3148 IPython, but outside code using the old level numbering may have
3148 3149 broken.
3149 3150
3150 3151 * IPython/iplib.py (InteractiveShell.runcode): added this to
3151 3152 handle the tracebacks in SystemExit traps correctly. The previous
3152 3153 code (through interact) was printing more of the stack than
3153 3154 necessary, showing IPython internal code to the user.
3154 3155
3155 3156 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
3156 3157 default. Now that the default at the confirmation prompt is yes,
3157 3158 it's not so intrusive. François' argument that ipython sessions
3158 3159 tend to be complex enough not to lose them from an accidental C-d,
3159 3160 is a valid one.
3160 3161
3161 3162 * IPython/iplib.py (InteractiveShell.interact): added a
3162 3163 showtraceback() call to the SystemExit trap, and modified the exit
3163 3164 confirmation to have yes as the default.
3164 3165
3165 3166 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
3166 3167 this file. It's been gone from the code for a long time, this was
3167 3168 simply leftover junk.
3168 3169
3169 3170 2002-11-01 Fernando Perez <fperez@colorado.edu>
3170 3171
3171 3172 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
3172 3173 added. If set, IPython now traps EOF and asks for
3173 3174 confirmation. After a request by François Pinard.
3174 3175
3175 3176 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
3176 3177 of @abort, and with a new (better) mechanism for handling the
3177 3178 exceptions.
3178 3179
3179 3180 2002-10-27 Fernando Perez <fperez@colorado.edu>
3180 3181
3181 3182 * IPython/usage.py (__doc__): updated the --help information and
3182 3183 the ipythonrc file to indicate that -log generates
3183 3184 ./ipython.log. Also fixed the corresponding info in @logstart.
3184 3185 This and several other fixes in the manuals thanks to reports by
3185 3186 François Pinard <pinard-AT-iro.umontreal.ca>.
3186 3187
3187 3188 * IPython/Logger.py (Logger.switch_log): Fixed error message to
3188 3189 refer to @logstart (instead of @log, which doesn't exist).
3189 3190
3190 3191 * IPython/iplib.py (InteractiveShell._prefilter): fixed
3191 3192 AttributeError crash. Thanks to Christopher Armstrong
3192 3193 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
3193 3194 introduced recently (in 0.2.14pre37) with the fix to the eval
3194 3195 problem mentioned below.
3195 3196
3196 3197 2002-10-17 Fernando Perez <fperez@colorado.edu>
3197 3198
3198 3199 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
3199 3200 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
3200 3201
3201 3202 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
3202 3203 this function to fix a problem reported by Alex Schmolck. He saw
3203 3204 it with list comprehensions and generators, which were getting
3204 3205 called twice. The real problem was an 'eval' call in testing for
3205 3206 automagic which was evaluating the input line silently.
3206 3207
3207 3208 This is a potentially very nasty bug, if the input has side
3208 3209 effects which must not be repeated. The code is much cleaner now,
3209 3210 without any blanket 'except' left and with a regexp test for
3210 3211 actual function names.
3211 3212
3212 3213 But an eval remains, which I'm not fully comfortable with. I just
3213 3214 don't know how to find out if an expression could be a callable in
3214 3215 the user's namespace without doing an eval on the string. However
3215 3216 that string is now much more strictly checked so that no code
3216 3217 slips by, so the eval should only happen for things that can
3217 3218 really be only function/method names.
3218 3219
3219 3220 2002-10-15 Fernando Perez <fperez@colorado.edu>
3220 3221
3221 3222 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
3222 3223 OSX information to main manual, removed README_Mac_OSX file from
3223 3224 distribution. Also updated credits for recent additions.
3224 3225
3225 3226 2002-10-10 Fernando Perez <fperez@colorado.edu>
3226 3227
3227 3228 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3228 3229 terminal-related issues. Many thanks to Andrea Riciputi
3229 3230 <andrea.riciputi-AT-libero.it> for writing it.
3230 3231
3231 3232 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3232 3233 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3233 3234
3234 3235 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3235 3236 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3236 3237 <syver-en-AT-online.no> who both submitted patches for this problem.
3237 3238
3238 3239 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3239 3240 global embedding to make sure that things don't overwrite user
3240 3241 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3241 3242
3242 3243 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3243 3244 compatibility. Thanks to Hayden Callow
3244 3245 <h.callow-AT-elec.canterbury.ac.nz>
3245 3246
3246 3247 2002-10-04 Fernando Perez <fperez@colorado.edu>
3247 3248
3248 3249 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3249 3250 Gnuplot.File objects.
3250 3251
3251 3252 2002-07-23 Fernando Perez <fperez@colorado.edu>
3252 3253
3253 3254 * IPython/genutils.py (timing): Added timings() and timing() for
3254 3255 quick access to the most commonly needed data, the execution
3255 3256 times. Old timing() renamed to timings_out().
3256 3257
3257 3258 2002-07-18 Fernando Perez <fperez@colorado.edu>
3258 3259
3259 3260 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3260 3261 bug with nested instances disrupting the parent's tab completion.
3261 3262
3262 3263 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3263 3264 all_completions code to begin the emacs integration.
3264 3265
3265 3266 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3266 3267 argument to allow titling individual arrays when plotting.
3267 3268
3268 3269 2002-07-15 Fernando Perez <fperez@colorado.edu>
3269 3270
3270 3271 * setup.py (make_shortcut): changed to retrieve the value of
3271 3272 'Program Files' directory from the registry (this value changes in
3272 3273 non-english versions of Windows). Thanks to Thomas Fanslau
3273 3274 <tfanslau-AT-gmx.de> for the report.
3274 3275
3275 3276 2002-07-10 Fernando Perez <fperez@colorado.edu>
3276 3277
3277 3278 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3278 3279 a bug in pdb, which crashes if a line with only whitespace is
3279 3280 entered. Bug report submitted to sourceforge.
3280 3281
3281 3282 2002-07-09 Fernando Perez <fperez@colorado.edu>
3282 3283
3283 3284 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3284 3285 reporting exceptions (it's a bug in inspect.py, I just set a
3285 3286 workaround).
3286 3287
3287 3288 2002-07-08 Fernando Perez <fperez@colorado.edu>
3288 3289
3289 3290 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3290 3291 __IPYTHON__ in __builtins__ to show up in user_ns.
3291 3292
3292 3293 2002-07-03 Fernando Perez <fperez@colorado.edu>
3293 3294
3294 3295 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3295 3296 name from @gp_set_instance to @gp_set_default.
3296 3297
3297 3298 * IPython/ipmaker.py (make_IPython): default editor value set to
3298 3299 '0' (a string), to match the rc file. Otherwise will crash when
3299 3300 .strip() is called on it.
3300 3301
3301 3302
3302 3303 2002-06-28 Fernando Perez <fperez@colorado.edu>
3303 3304
3304 3305 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3305 3306 of files in current directory when a file is executed via
3306 3307 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3307 3308
3308 3309 * setup.py (manfiles): fix for rpm builds, submitted by RA
3309 3310 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3310 3311
3311 3312 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3312 3313 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3313 3314 string!). A. Schmolck caught this one.
3314 3315
3315 3316 2002-06-27 Fernando Perez <fperez@colorado.edu>
3316 3317
3317 3318 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3318 3319 defined files at the cmd line. __name__ wasn't being set to
3319 3320 __main__.
3320 3321
3321 3322 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3322 3323 regular lists and tuples besides Numeric arrays.
3323 3324
3324 3325 * IPython/Prompts.py (CachedOutput.__call__): Added output
3325 3326 supression for input ending with ';'. Similar to Mathematica and
3326 3327 Matlab. The _* vars and Out[] list are still updated, just like
3327 3328 Mathematica behaves.
3328 3329
3329 3330 2002-06-25 Fernando Perez <fperez@colorado.edu>
3330 3331
3331 3332 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3332 3333 .ini extensions for profiels under Windows.
3333 3334
3334 3335 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3335 3336 string form. Fix contributed by Alexander Schmolck
3336 3337 <a.schmolck-AT-gmx.net>
3337 3338
3338 3339 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3339 3340 pre-configured Gnuplot instance.
3340 3341
3341 3342 2002-06-21 Fernando Perez <fperez@colorado.edu>
3342 3343
3343 3344 * IPython/numutils.py (exp_safe): new function, works around the
3344 3345 underflow problems in Numeric.
3345 3346 (log2): New fn. Safe log in base 2: returns exact integer answer
3346 3347 for exact integer powers of 2.
3347 3348
3348 3349 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3349 3350 properly.
3350 3351
3351 3352 2002-06-20 Fernando Perez <fperez@colorado.edu>
3352 3353
3353 3354 * IPython/genutils.py (timing): new function like
3354 3355 Mathematica's. Similar to time_test, but returns more info.
3355 3356
3356 3357 2002-06-18 Fernando Perez <fperez@colorado.edu>
3357 3358
3358 3359 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3359 3360 according to Mike Heeter's suggestions.
3360 3361
3361 3362 2002-06-16 Fernando Perez <fperez@colorado.edu>
3362 3363
3363 3364 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3364 3365 system. GnuplotMagic is gone as a user-directory option. New files
3365 3366 make it easier to use all the gnuplot stuff both from external
3366 3367 programs as well as from IPython. Had to rewrite part of
3367 3368 hardcopy() b/c of a strange bug: often the ps files simply don't
3368 3369 get created, and require a repeat of the command (often several
3369 3370 times).
3370 3371
3371 3372 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3372 3373 resolve output channel at call time, so that if sys.stderr has
3373 3374 been redirected by user this gets honored.
3374 3375
3375 3376 2002-06-13 Fernando Perez <fperez@colorado.edu>
3376 3377
3377 3378 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3378 3379 IPShell. Kept a copy with the old names to avoid breaking people's
3379 3380 embedded code.
3380 3381
3381 3382 * IPython/ipython: simplified it to the bare minimum after
3382 3383 Holger's suggestions. Added info about how to use it in
3383 3384 PYTHONSTARTUP.
3384 3385
3385 3386 * IPython/Shell.py (IPythonShell): changed the options passing
3386 3387 from a string with funky %s replacements to a straight list. Maybe
3387 3388 a bit more typing, but it follows sys.argv conventions, so there's
3388 3389 less special-casing to remember.
3389 3390
3390 3391 2002-06-12 Fernando Perez <fperez@colorado.edu>
3391 3392
3392 3393 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3393 3394 command. Thanks to a suggestion by Mike Heeter.
3394 3395 (Magic.magic_pfile): added behavior to look at filenames if given
3395 3396 arg is not a defined object.
3396 3397 (Magic.magic_save): New @save function to save code snippets. Also
3397 3398 a Mike Heeter idea.
3398 3399
3399 3400 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3400 3401 plot() and replot(). Much more convenient now, especially for
3401 3402 interactive use.
3402 3403
3403 3404 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3404 3405 filenames.
3405 3406
3406 3407 2002-06-02 Fernando Perez <fperez@colorado.edu>
3407 3408
3408 3409 * IPython/Struct.py (Struct.__init__): modified to admit
3409 3410 initialization via another struct.
3410 3411
3411 3412 * IPython/genutils.py (SystemExec.__init__): New stateful
3412 3413 interface to xsys and bq. Useful for writing system scripts.
3413 3414
3414 3415 2002-05-30 Fernando Perez <fperez@colorado.edu>
3415 3416
3416 3417 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3417 3418 documents. This will make the user download smaller (it's getting
3418 3419 too big).
3419 3420
3420 3421 2002-05-29 Fernando Perez <fperez@colorado.edu>
3421 3422
3422 3423 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3423 3424 fix problems with shelve and pickle. Seems to work, but I don't
3424 3425 know if corner cases break it. Thanks to Mike Heeter
3425 3426 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3426 3427
3427 3428 2002-05-24 Fernando Perez <fperez@colorado.edu>
3428 3429
3429 3430 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3430 3431 macros having broken.
3431 3432
3432 3433 2002-05-21 Fernando Perez <fperez@colorado.edu>
3433 3434
3434 3435 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3435 3436 introduced logging bug: all history before logging started was
3436 3437 being written one character per line! This came from the redesign
3437 3438 of the input history as a special list which slices to strings,
3438 3439 not to lists.
3439 3440
3440 3441 2002-05-20 Fernando Perez <fperez@colorado.edu>
3441 3442
3442 3443 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3443 3444 be an attribute of all classes in this module. The design of these
3444 3445 classes needs some serious overhauling.
3445 3446
3446 3447 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3447 3448 which was ignoring '_' in option names.
3448 3449
3449 3450 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3450 3451 'Verbose_novars' to 'Context' and made it the new default. It's a
3451 3452 bit more readable and also safer than verbose.
3452 3453
3453 3454 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3454 3455 triple-quoted strings.
3455 3456
3456 3457 * IPython/OInspect.py (__all__): new module exposing the object
3457 3458 introspection facilities. Now the corresponding magics are dummy
3458 3459 wrappers around this. Having this module will make it much easier
3459 3460 to put these functions into our modified pdb.
3460 3461 This new object inspector system uses the new colorizing module,
3461 3462 so source code and other things are nicely syntax highlighted.
3462 3463
3463 3464 2002-05-18 Fernando Perez <fperez@colorado.edu>
3464 3465
3465 3466 * IPython/ColorANSI.py: Split the coloring tools into a separate
3466 3467 module so I can use them in other code easier (they were part of
3467 3468 ultraTB).
3468 3469
3469 3470 2002-05-17 Fernando Perez <fperez@colorado.edu>
3470 3471
3471 3472 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3472 3473 fixed it to set the global 'g' also to the called instance, as
3473 3474 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3474 3475 user's 'g' variables).
3475 3476
3476 3477 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3477 3478 global variables (aliases to _ih,_oh) so that users which expect
3478 3479 In[5] or Out[7] to work aren't unpleasantly surprised.
3479 3480 (InputList.__getslice__): new class to allow executing slices of
3480 3481 input history directly. Very simple class, complements the use of
3481 3482 macros.
3482 3483
3483 3484 2002-05-16 Fernando Perez <fperez@colorado.edu>
3484 3485
3485 3486 * setup.py (docdirbase): make doc directory be just doc/IPython
3486 3487 without version numbers, it will reduce clutter for users.
3487 3488
3488 3489 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3489 3490 execfile call to prevent possible memory leak. See for details:
3490 3491 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3491 3492
3492 3493 2002-05-15 Fernando Perez <fperez@colorado.edu>
3493 3494
3494 3495 * IPython/Magic.py (Magic.magic_psource): made the object
3495 3496 introspection names be more standard: pdoc, pdef, pfile and
3496 3497 psource. They all print/page their output, and it makes
3497 3498 remembering them easier. Kept old names for compatibility as
3498 3499 aliases.
3499 3500
3500 3501 2002-05-14 Fernando Perez <fperez@colorado.edu>
3501 3502
3502 3503 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3503 3504 what the mouse problem was. The trick is to use gnuplot with temp
3504 3505 files and NOT with pipes (for data communication), because having
3505 3506 both pipes and the mouse on is bad news.
3506 3507
3507 3508 2002-05-13 Fernando Perez <fperez@colorado.edu>
3508 3509
3509 3510 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3510 3511 bug. Information would be reported about builtins even when
3511 3512 user-defined functions overrode them.
3512 3513
3513 3514 2002-05-11 Fernando Perez <fperez@colorado.edu>
3514 3515
3515 3516 * IPython/__init__.py (__all__): removed FlexCompleter from
3516 3517 __all__ so that things don't fail in platforms without readline.
3517 3518
3518 3519 2002-05-10 Fernando Perez <fperez@colorado.edu>
3519 3520
3520 3521 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3521 3522 it requires Numeric, effectively making Numeric a dependency for
3522 3523 IPython.
3523 3524
3524 3525 * Released 0.2.13
3525 3526
3526 3527 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3527 3528 profiler interface. Now all the major options from the profiler
3528 3529 module are directly supported in IPython, both for single
3529 3530 expressions (@prun) and for full programs (@run -p).
3530 3531
3531 3532 2002-05-09 Fernando Perez <fperez@colorado.edu>
3532 3533
3533 3534 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3534 3535 magic properly formatted for screen.
3535 3536
3536 3537 * setup.py (make_shortcut): Changed things to put pdf version in
3537 3538 doc/ instead of doc/manual (had to change lyxport a bit).
3538 3539
3539 3540 * IPython/Magic.py (Profile.string_stats): made profile runs go
3540 3541 through pager (they are long and a pager allows searching, saving,
3541 3542 etc.)
3542 3543
3543 3544 2002-05-08 Fernando Perez <fperez@colorado.edu>
3544 3545
3545 3546 * Released 0.2.12
3546 3547
3547 3548 2002-05-06 Fernando Perez <fperez@colorado.edu>
3548 3549
3549 3550 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3550 3551 introduced); 'hist n1 n2' was broken.
3551 3552 (Magic.magic_pdb): added optional on/off arguments to @pdb
3552 3553 (Magic.magic_run): added option -i to @run, which executes code in
3553 3554 the IPython namespace instead of a clean one. Also added @irun as
3554 3555 an alias to @run -i.
3555 3556
3556 3557 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3557 3558 fixed (it didn't really do anything, the namespaces were wrong).
3558 3559
3559 3560 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3560 3561
3561 3562 * IPython/__init__.py (__all__): Fixed package namespace, now
3562 3563 'import IPython' does give access to IPython.<all> as
3563 3564 expected. Also renamed __release__ to Release.
3564 3565
3565 3566 * IPython/Debugger.py (__license__): created new Pdb class which
3566 3567 functions like a drop-in for the normal pdb.Pdb but does NOT
3567 3568 import readline by default. This way it doesn't muck up IPython's
3568 3569 readline handling, and now tab-completion finally works in the
3569 3570 debugger -- sort of. It completes things globally visible, but the
3570 3571 completer doesn't track the stack as pdb walks it. That's a bit
3571 3572 tricky, and I'll have to implement it later.
3572 3573
3573 3574 2002-05-05 Fernando Perez <fperez@colorado.edu>
3574 3575
3575 3576 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3576 3577 magic docstrings when printed via ? (explicit \'s were being
3577 3578 printed).
3578 3579
3579 3580 * IPython/ipmaker.py (make_IPython): fixed namespace
3580 3581 identification bug. Now variables loaded via logs or command-line
3581 3582 files are recognized in the interactive namespace by @who.
3582 3583
3583 3584 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3584 3585 log replay system stemming from the string form of Structs.
3585 3586
3586 3587 * IPython/Magic.py (Macro.__init__): improved macros to properly
3587 3588 handle magic commands in them.
3588 3589 (Magic.magic_logstart): usernames are now expanded so 'logstart
3589 3590 ~/mylog' now works.
3590 3591
3591 3592 * IPython/iplib.py (complete): fixed bug where paths starting with
3592 3593 '/' would be completed as magic names.
3593 3594
3594 3595 2002-05-04 Fernando Perez <fperez@colorado.edu>
3595 3596
3596 3597 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3597 3598 allow running full programs under the profiler's control.
3598 3599
3599 3600 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3600 3601 mode to report exceptions verbosely but without formatting
3601 3602 variables. This addresses the issue of ipython 'freezing' (it's
3602 3603 not frozen, but caught in an expensive formatting loop) when huge
3603 3604 variables are in the context of an exception.
3604 3605 (VerboseTB.text): Added '--->' markers at line where exception was
3605 3606 triggered. Much clearer to read, especially in NoColor modes.
3606 3607
3607 3608 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3608 3609 implemented in reverse when changing to the new parse_options().
3609 3610
3610 3611 2002-05-03 Fernando Perez <fperez@colorado.edu>
3611 3612
3612 3613 * IPython/Magic.py (Magic.parse_options): new function so that
3613 3614 magics can parse options easier.
3614 3615 (Magic.magic_prun): new function similar to profile.run(),
3615 3616 suggested by Chris Hart.
3616 3617 (Magic.magic_cd): fixed behavior so that it only changes if
3617 3618 directory actually is in history.
3618 3619
3619 3620 * IPython/usage.py (__doc__): added information about potential
3620 3621 slowness of Verbose exception mode when there are huge data
3621 3622 structures to be formatted (thanks to Archie Paulson).
3622 3623
3623 3624 * IPython/ipmaker.py (make_IPython): Changed default logging
3624 3625 (when simply called with -log) to use curr_dir/ipython.log in
3625 3626 rotate mode. Fixed crash which was occuring with -log before
3626 3627 (thanks to Jim Boyle).
3627 3628
3628 3629 2002-05-01 Fernando Perez <fperez@colorado.edu>
3629 3630
3630 3631 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3631 3632 was nasty -- though somewhat of a corner case).
3632 3633
3633 3634 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3634 3635 text (was a bug).
3635 3636
3636 3637 2002-04-30 Fernando Perez <fperez@colorado.edu>
3637 3638
3638 3639 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3639 3640 a print after ^D or ^C from the user so that the In[] prompt
3640 3641 doesn't over-run the gnuplot one.
3641 3642
3642 3643 2002-04-29 Fernando Perez <fperez@colorado.edu>
3643 3644
3644 3645 * Released 0.2.10
3645 3646
3646 3647 * IPython/__release__.py (version): get date dynamically.
3647 3648
3648 3649 * Misc. documentation updates thanks to Arnd's comments. Also ran
3649 3650 a full spellcheck on the manual (hadn't been done in a while).
3650 3651
3651 3652 2002-04-27 Fernando Perez <fperez@colorado.edu>
3652 3653
3653 3654 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3654 3655 starting a log in mid-session would reset the input history list.
3655 3656
3656 3657 2002-04-26 Fernando Perez <fperez@colorado.edu>
3657 3658
3658 3659 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3659 3660 all files were being included in an update. Now anything in
3660 3661 UserConfig that matches [A-Za-z]*.py will go (this excludes
3661 3662 __init__.py)
3662 3663
3663 3664 2002-04-25 Fernando Perez <fperez@colorado.edu>
3664 3665
3665 3666 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3666 3667 to __builtins__ so that any form of embedded or imported code can
3667 3668 test for being inside IPython.
3668 3669
3669 3670 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3670 3671 changed to GnuplotMagic because it's now an importable module,
3671 3672 this makes the name follow that of the standard Gnuplot module.
3672 3673 GnuplotMagic can now be loaded at any time in mid-session.
3673 3674
3674 3675 2002-04-24 Fernando Perez <fperez@colorado.edu>
3675 3676
3676 3677 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3677 3678 the globals (IPython has its own namespace) and the
3678 3679 PhysicalQuantity stuff is much better anyway.
3679 3680
3680 3681 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3681 3682 embedding example to standard user directory for
3682 3683 distribution. Also put it in the manual.
3683 3684
3684 3685 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3685 3686 instance as first argument (so it doesn't rely on some obscure
3686 3687 hidden global).
3687 3688
3688 3689 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3689 3690 delimiters. While it prevents ().TAB from working, it allows
3690 3691 completions in open (... expressions. This is by far a more common
3691 3692 case.
3692 3693
3693 3694 2002-04-23 Fernando Perez <fperez@colorado.edu>
3694 3695
3695 3696 * IPython/Extensions/InterpreterPasteInput.py: new
3696 3697 syntax-processing module for pasting lines with >>> or ... at the
3697 3698 start.
3698 3699
3699 3700 * IPython/Extensions/PhysicalQ_Interactive.py
3700 3701 (PhysicalQuantityInteractive.__int__): fixed to work with either
3701 3702 Numeric or math.
3702 3703
3703 3704 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3704 3705 provided profiles. Now we have:
3705 3706 -math -> math module as * and cmath with its own namespace.
3706 3707 -numeric -> Numeric as *, plus gnuplot & grace
3707 3708 -physics -> same as before
3708 3709
3709 3710 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3710 3711 user-defined magics wouldn't be found by @magic if they were
3711 3712 defined as class methods. Also cleaned up the namespace search
3712 3713 logic and the string building (to use %s instead of many repeated
3713 3714 string adds).
3714 3715
3715 3716 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3716 3717 of user-defined magics to operate with class methods (cleaner, in
3717 3718 line with the gnuplot code).
3718 3719
3719 3720 2002-04-22 Fernando Perez <fperez@colorado.edu>
3720 3721
3721 3722 * setup.py: updated dependency list so that manual is updated when
3722 3723 all included files change.
3723 3724
3724 3725 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3725 3726 the delimiter removal option (the fix is ugly right now).
3726 3727
3727 3728 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3728 3729 all of the math profile (quicker loading, no conflict between
3729 3730 g-9.8 and g-gnuplot).
3730 3731
3731 3732 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3732 3733 name of post-mortem files to IPython_crash_report.txt.
3733 3734
3734 3735 * Cleanup/update of the docs. Added all the new readline info and
3735 3736 formatted all lists as 'real lists'.
3736 3737
3737 3738 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3738 3739 tab-completion options, since the full readline parse_and_bind is
3739 3740 now accessible.
3740 3741
3741 3742 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3742 3743 handling of readline options. Now users can specify any string to
3743 3744 be passed to parse_and_bind(), as well as the delimiters to be
3744 3745 removed.
3745 3746 (InteractiveShell.__init__): Added __name__ to the global
3746 3747 namespace so that things like Itpl which rely on its existence
3747 3748 don't crash.
3748 3749 (InteractiveShell._prefilter): Defined the default with a _ so
3749 3750 that prefilter() is easier to override, while the default one
3750 3751 remains available.
3751 3752
3752 3753 2002-04-18 Fernando Perez <fperez@colorado.edu>
3753 3754
3754 3755 * Added information about pdb in the docs.
3755 3756
3756 3757 2002-04-17 Fernando Perez <fperez@colorado.edu>
3757 3758
3758 3759 * IPython/ipmaker.py (make_IPython): added rc_override option to
3759 3760 allow passing config options at creation time which may override
3760 3761 anything set in the config files or command line. This is
3761 3762 particularly useful for configuring embedded instances.
3762 3763
3763 3764 2002-04-15 Fernando Perez <fperez@colorado.edu>
3764 3765
3765 3766 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3766 3767 crash embedded instances because of the input cache falling out of
3767 3768 sync with the output counter.
3768 3769
3769 3770 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3770 3771 mode which calls pdb after an uncaught exception in IPython itself.
3771 3772
3772 3773 2002-04-14 Fernando Perez <fperez@colorado.edu>
3773 3774
3774 3775 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3775 3776 readline, fix it back after each call.
3776 3777
3777 3778 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3778 3779 method to force all access via __call__(), which guarantees that
3779 3780 traceback references are properly deleted.
3780 3781
3781 3782 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3782 3783 improve printing when pprint is in use.
3783 3784
3784 3785 2002-04-13 Fernando Perez <fperez@colorado.edu>
3785 3786
3786 3787 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3787 3788 exceptions aren't caught anymore. If the user triggers one, he
3788 3789 should know why he's doing it and it should go all the way up,
3789 3790 just like any other exception. So now @abort will fully kill the
3790 3791 embedded interpreter and the embedding code (unless that happens
3791 3792 to catch SystemExit).
3792 3793
3793 3794 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3794 3795 and a debugger() method to invoke the interactive pdb debugger
3795 3796 after printing exception information. Also added the corresponding
3796 3797 -pdb option and @pdb magic to control this feature, and updated
3797 3798 the docs. After a suggestion from Christopher Hart
3798 3799 (hart-AT-caltech.edu).
3799 3800
3800 3801 2002-04-12 Fernando Perez <fperez@colorado.edu>
3801 3802
3802 3803 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3803 3804 the exception handlers defined by the user (not the CrashHandler)
3804 3805 so that user exceptions don't trigger an ipython bug report.
3805 3806
3806 3807 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3807 3808 configurable (it should have always been so).
3808 3809
3809 3810 2002-03-26 Fernando Perez <fperez@colorado.edu>
3810 3811
3811 3812 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3812 3813 and there to fix embedding namespace issues. This should all be
3813 3814 done in a more elegant way.
3814 3815
3815 3816 2002-03-25 Fernando Perez <fperez@colorado.edu>
3816 3817
3817 3818 * IPython/genutils.py (get_home_dir): Try to make it work under
3818 3819 win9x also.
3819 3820
3820 3821 2002-03-20 Fernando Perez <fperez@colorado.edu>
3821 3822
3822 3823 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3823 3824 sys.displayhook untouched upon __init__.
3824 3825
3825 3826 2002-03-19 Fernando Perez <fperez@colorado.edu>
3826 3827
3827 3828 * Released 0.2.9 (for embedding bug, basically).
3828 3829
3829 3830 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3830 3831 exceptions so that enclosing shell's state can be restored.
3831 3832
3832 3833 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3833 3834 naming conventions in the .ipython/ dir.
3834 3835
3835 3836 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3836 3837 from delimiters list so filenames with - in them get expanded.
3837 3838
3838 3839 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3839 3840 sys.displayhook not being properly restored after an embedded call.
3840 3841
3841 3842 2002-03-18 Fernando Perez <fperez@colorado.edu>
3842 3843
3843 3844 * Released 0.2.8
3844 3845
3845 3846 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3846 3847 some files weren't being included in a -upgrade.
3847 3848 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3848 3849 on' so that the first tab completes.
3849 3850 (InteractiveShell.handle_magic): fixed bug with spaces around
3850 3851 quotes breaking many magic commands.
3851 3852
3852 3853 * setup.py: added note about ignoring the syntax error messages at
3853 3854 installation.
3854 3855
3855 3856 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3856 3857 streamlining the gnuplot interface, now there's only one magic @gp.
3857 3858
3858 3859 2002-03-17 Fernando Perez <fperez@colorado.edu>
3859 3860
3860 3861 * IPython/UserConfig/magic_gnuplot.py: new name for the
3861 3862 example-magic_pm.py file. Much enhanced system, now with a shell
3862 3863 for communicating directly with gnuplot, one command at a time.
3863 3864
3864 3865 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3865 3866 setting __name__=='__main__'.
3866 3867
3867 3868 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3868 3869 mini-shell for accessing gnuplot from inside ipython. Should
3869 3870 extend it later for grace access too. Inspired by Arnd's
3870 3871 suggestion.
3871 3872
3872 3873 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3873 3874 calling magic functions with () in their arguments. Thanks to Arnd
3874 3875 Baecker for pointing this to me.
3875 3876
3876 3877 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3877 3878 infinitely for integer or complex arrays (only worked with floats).
3878 3879
3879 3880 2002-03-16 Fernando Perez <fperez@colorado.edu>
3880 3881
3881 3882 * setup.py: Merged setup and setup_windows into a single script
3882 3883 which properly handles things for windows users.
3883 3884
3884 3885 2002-03-15 Fernando Perez <fperez@colorado.edu>
3885 3886
3886 3887 * Big change to the manual: now the magics are all automatically
3887 3888 documented. This information is generated from their docstrings
3888 3889 and put in a latex file included by the manual lyx file. This way
3889 3890 we get always up to date information for the magics. The manual
3890 3891 now also has proper version information, also auto-synced.
3891 3892
3892 3893 For this to work, an undocumented --magic_docstrings option was added.
3893 3894
3894 3895 2002-03-13 Fernando Perez <fperez@colorado.edu>
3895 3896
3896 3897 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3897 3898 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3898 3899
3899 3900 2002-03-12 Fernando Perez <fperez@colorado.edu>
3900 3901
3901 3902 * IPython/ultraTB.py (TermColors): changed color escapes again to
3902 3903 fix the (old, reintroduced) line-wrapping bug. Basically, if
3903 3904 \001..\002 aren't given in the color escapes, lines get wrapped
3904 3905 weirdly. But giving those screws up old xterms and emacs terms. So
3905 3906 I added some logic for emacs terms to be ok, but I can't identify old
3906 3907 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3907 3908
3908 3909 2002-03-10 Fernando Perez <fperez@colorado.edu>
3909 3910
3910 3911 * IPython/usage.py (__doc__): Various documentation cleanups and
3911 3912 updates, both in usage docstrings and in the manual.
3912 3913
3913 3914 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3914 3915 handling of caching. Set minimum acceptabe value for having a
3915 3916 cache at 20 values.
3916 3917
3917 3918 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3918 3919 install_first_time function to a method, renamed it and added an
3919 3920 'upgrade' mode. Now people can update their config directory with
3920 3921 a simple command line switch (-upgrade, also new).
3921 3922
3922 3923 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3923 3924 @file (convenient for automagic users under Python >= 2.2).
3924 3925 Removed @files (it seemed more like a plural than an abbrev. of
3925 3926 'file show').
3926 3927
3927 3928 * IPython/iplib.py (install_first_time): Fixed crash if there were
3928 3929 backup files ('~') in .ipython/ install directory.
3929 3930
3930 3931 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3931 3932 system. Things look fine, but these changes are fairly
3932 3933 intrusive. Test them for a few days.
3933 3934
3934 3935 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3935 3936 the prompts system. Now all in/out prompt strings are user
3936 3937 controllable. This is particularly useful for embedding, as one
3937 3938 can tag embedded instances with particular prompts.
3938 3939
3939 3940 Also removed global use of sys.ps1/2, which now allows nested
3940 3941 embeddings without any problems. Added command-line options for
3941 3942 the prompt strings.
3942 3943
3943 3944 2002-03-08 Fernando Perez <fperez@colorado.edu>
3944 3945
3945 3946 * IPython/UserConfig/example-embed-short.py (ipshell): added
3946 3947 example file with the bare minimum code for embedding.
3947 3948
3948 3949 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3949 3950 functionality for the embeddable shell to be activated/deactivated
3950 3951 either globally or at each call.
3951 3952
3952 3953 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3953 3954 rewriting the prompt with '--->' for auto-inputs with proper
3954 3955 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3955 3956 this is handled by the prompts class itself, as it should.
3956 3957
3957 3958 2002-03-05 Fernando Perez <fperez@colorado.edu>
3958 3959
3959 3960 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3960 3961 @logstart to avoid name clashes with the math log function.
3961 3962
3962 3963 * Big updates to X/Emacs section of the manual.
3963 3964
3964 3965 * Removed ipython_emacs. Milan explained to me how to pass
3965 3966 arguments to ipython through Emacs. Some day I'm going to end up
3966 3967 learning some lisp...
3967 3968
3968 3969 2002-03-04 Fernando Perez <fperez@colorado.edu>
3969 3970
3970 3971 * IPython/ipython_emacs: Created script to be used as the
3971 3972 py-python-command Emacs variable so we can pass IPython
3972 3973 parameters. I can't figure out how to tell Emacs directly to pass
3973 3974 parameters to IPython, so a dummy shell script will do it.
3974 3975
3975 3976 Other enhancements made for things to work better under Emacs'
3976 3977 various types of terminals. Many thanks to Milan Zamazal
3977 3978 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3978 3979
3979 3980 2002-03-01 Fernando Perez <fperez@colorado.edu>
3980 3981
3981 3982 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3982 3983 that loading of readline is now optional. This gives better
3983 3984 control to emacs users.
3984 3985
3985 3986 * IPython/ultraTB.py (__date__): Modified color escape sequences
3986 3987 and now things work fine under xterm and in Emacs' term buffers
3987 3988 (though not shell ones). Well, in emacs you get colors, but all
3988 3989 seem to be 'light' colors (no difference between dark and light
3989 3990 ones). But the garbage chars are gone, and also in xterms. It
3990 3991 seems that now I'm using 'cleaner' ansi sequences.
3991 3992
3992 3993 2002-02-21 Fernando Perez <fperez@colorado.edu>
3993 3994
3994 3995 * Released 0.2.7 (mainly to publish the scoping fix).
3995 3996
3996 3997 * IPython/Logger.py (Logger.logstate): added. A corresponding
3997 3998 @logstate magic was created.
3998 3999
3999 4000 * IPython/Magic.py: fixed nested scoping problem under Python
4000 4001 2.1.x (automagic wasn't working).
4001 4002
4002 4003 2002-02-20 Fernando Perez <fperez@colorado.edu>
4003 4004
4004 4005 * Released 0.2.6.
4005 4006
4006 4007 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
4007 4008 option so that logs can come out without any headers at all.
4008 4009
4009 4010 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
4010 4011 SciPy.
4011 4012
4012 4013 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
4013 4014 that embedded IPython calls don't require vars() to be explicitly
4014 4015 passed. Now they are extracted from the caller's frame (code
4015 4016 snatched from Eric Jones' weave). Added better documentation to
4016 4017 the section on embedding and the example file.
4017 4018
4018 4019 * IPython/genutils.py (page): Changed so that under emacs, it just
4019 4020 prints the string. You can then page up and down in the emacs
4020 4021 buffer itself. This is how the builtin help() works.
4021 4022
4022 4023 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
4023 4024 macro scoping: macros need to be executed in the user's namespace
4024 4025 to work as if they had been typed by the user.
4025 4026
4026 4027 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
4027 4028 execute automatically (no need to type 'exec...'). They then
4028 4029 behave like 'true macros'. The printing system was also modified
4029 4030 for this to work.
4030 4031
4031 4032 2002-02-19 Fernando Perez <fperez@colorado.edu>
4032 4033
4033 4034 * IPython/genutils.py (page_file): new function for paging files
4034 4035 in an OS-independent way. Also necessary for file viewing to work
4035 4036 well inside Emacs buffers.
4036 4037 (page): Added checks for being in an emacs buffer.
4037 4038 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
4038 4039 same bug in iplib.
4039 4040
4040 4041 2002-02-18 Fernando Perez <fperez@colorado.edu>
4041 4042
4042 4043 * IPython/iplib.py (InteractiveShell.init_readline): modified use
4043 4044 of readline so that IPython can work inside an Emacs buffer.
4044 4045
4045 4046 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
4046 4047 method signatures (they weren't really bugs, but it looks cleaner
4047 4048 and keeps PyChecker happy).
4048 4049
4049 4050 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
4050 4051 for implementing various user-defined hooks. Currently only
4051 4052 display is done.
4052 4053
4053 4054 * IPython/Prompts.py (CachedOutput._display): changed display
4054 4055 functions so that they can be dynamically changed by users easily.
4055 4056
4056 4057 * IPython/Extensions/numeric_formats.py (num_display): added an
4057 4058 extension for printing NumPy arrays in flexible manners. It
4058 4059 doesn't do anything yet, but all the structure is in
4059 4060 place. Ultimately the plan is to implement output format control
4060 4061 like in Octave.
4061 4062
4062 4063 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
4063 4064 methods are found at run-time by all the automatic machinery.
4064 4065
4065 4066 2002-02-17 Fernando Perez <fperez@colorado.edu>
4066 4067
4067 4068 * setup_Windows.py (make_shortcut): documented. Cleaned up the
4068 4069 whole file a little.
4069 4070
4070 4071 * ToDo: closed this document. Now there's a new_design.lyx
4071 4072 document for all new ideas. Added making a pdf of it for the
4072 4073 end-user distro.
4073 4074
4074 4075 * IPython/Logger.py (Logger.switch_log): Created this to replace
4075 4076 logon() and logoff(). It also fixes a nasty crash reported by
4076 4077 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
4077 4078
4078 4079 * IPython/iplib.py (complete): got auto-completion to work with
4079 4080 automagic (I had wanted this for a long time).
4080 4081
4081 4082 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
4082 4083 to @file, since file() is now a builtin and clashes with automagic
4083 4084 for @file.
4084 4085
4085 4086 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
4086 4087 of this was previously in iplib, which had grown to more than 2000
4087 4088 lines, way too long. No new functionality, but it makes managing
4088 4089 the code a bit easier.
4089 4090
4090 4091 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
4091 4092 information to crash reports.
4092 4093
4093 4094 2002-02-12 Fernando Perez <fperez@colorado.edu>
4094 4095
4095 4096 * Released 0.2.5.
4096 4097
4097 4098 2002-02-11 Fernando Perez <fperez@colorado.edu>
4098 4099
4099 4100 * Wrote a relatively complete Windows installer. It puts
4100 4101 everything in place, creates Start Menu entries and fixes the
4101 4102 color issues. Nothing fancy, but it works.
4102 4103
4103 4104 2002-02-10 Fernando Perez <fperez@colorado.edu>
4104 4105
4105 4106 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
4106 4107 os.path.expanduser() call so that we can type @run ~/myfile.py and
4107 4108 have thigs work as expected.
4108 4109
4109 4110 * IPython/genutils.py (page): fixed exception handling so things
4110 4111 work both in Unix and Windows correctly. Quitting a pager triggers
4111 4112 an IOError/broken pipe in Unix, and in windows not finding a pager
4112 4113 is also an IOError, so I had to actually look at the return value
4113 4114 of the exception, not just the exception itself. Should be ok now.
4114 4115
4115 4116 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
4116 4117 modified to allow case-insensitive color scheme changes.
4117 4118
4118 4119 2002-02-09 Fernando Perez <fperez@colorado.edu>
4119 4120
4120 4121 * IPython/genutils.py (native_line_ends): new function to leave
4121 4122 user config files with os-native line-endings.
4122 4123
4123 4124 * README and manual updates.
4124 4125
4125 4126 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
4126 4127 instead of StringType to catch Unicode strings.
4127 4128
4128 4129 * IPython/genutils.py (filefind): fixed bug for paths with
4129 4130 embedded spaces (very common in Windows).
4130 4131
4131 4132 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
4132 4133 files under Windows, so that they get automatically associated
4133 4134 with a text editor. Windows makes it a pain to handle
4134 4135 extension-less files.
4135 4136
4136 4137 * IPython/iplib.py (InteractiveShell.init_readline): Made the
4137 4138 warning about readline only occur for Posix. In Windows there's no
4138 4139 way to get readline, so why bother with the warning.
4139 4140
4140 4141 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
4141 4142 for __str__ instead of dir(self), since dir() changed in 2.2.
4142 4143
4143 4144 * Ported to Windows! Tested on XP, I suspect it should work fine
4144 4145 on NT/2000, but I don't think it will work on 98 et al. That
4145 4146 series of Windows is such a piece of junk anyway that I won't try
4146 4147 porting it there. The XP port was straightforward, showed a few
4147 4148 bugs here and there (fixed all), in particular some string
4148 4149 handling stuff which required considering Unicode strings (which
4149 4150 Windows uses). This is good, but hasn't been too tested :) No
4150 4151 fancy installer yet, I'll put a note in the manual so people at
4151 4152 least make manually a shortcut.
4152 4153
4153 4154 * IPython/iplib.py (Magic.magic_colors): Unified the color options
4154 4155 into a single one, "colors". This now controls both prompt and
4155 4156 exception color schemes, and can be changed both at startup
4156 4157 (either via command-line switches or via ipythonrc files) and at
4157 4158 runtime, with @colors.
4158 4159 (Magic.magic_run): renamed @prun to @run and removed the old
4159 4160 @run. The two were too similar to warrant keeping both.
4160 4161
4161 4162 2002-02-03 Fernando Perez <fperez@colorado.edu>
4162 4163
4163 4164 * IPython/iplib.py (install_first_time): Added comment on how to
4164 4165 configure the color options for first-time users. Put a <return>
4165 4166 request at the end so that small-terminal users get a chance to
4166 4167 read the startup info.
4167 4168
4168 4169 2002-01-23 Fernando Perez <fperez@colorado.edu>
4169 4170
4170 4171 * IPython/iplib.py (CachedOutput.update): Changed output memory
4171 4172 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
4172 4173 input history we still use _i. Did this b/c these variable are
4173 4174 very commonly used in interactive work, so the less we need to
4174 4175 type the better off we are.
4175 4176 (Magic.magic_prun): updated @prun to better handle the namespaces
4176 4177 the file will run in, including a fix for __name__ not being set
4177 4178 before.
4178 4179
4179 4180 2002-01-20 Fernando Perez <fperez@colorado.edu>
4180 4181
4181 4182 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
4182 4183 extra garbage for Python 2.2. Need to look more carefully into
4183 4184 this later.
4184 4185
4185 4186 2002-01-19 Fernando Perez <fperez@colorado.edu>
4186 4187
4187 4188 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
4188 4189 display SyntaxError exceptions properly formatted when they occur
4189 4190 (they can be triggered by imported code).
4190 4191
4191 4192 2002-01-18 Fernando Perez <fperez@colorado.edu>
4192 4193
4193 4194 * IPython/iplib.py (InteractiveShell.safe_execfile): now
4194 4195 SyntaxError exceptions are reported nicely formatted, instead of
4195 4196 spitting out only offset information as before.
4196 4197 (Magic.magic_prun): Added the @prun function for executing
4197 4198 programs with command line args inside IPython.
4198 4199
4199 4200 2002-01-16 Fernando Perez <fperez@colorado.edu>
4200 4201
4201 4202 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
4202 4203 to *not* include the last item given in a range. This brings their
4203 4204 behavior in line with Python's slicing:
4204 4205 a[n1:n2] -> a[n1]...a[n2-1]
4205 4206 It may be a bit less convenient, but I prefer to stick to Python's
4206 4207 conventions *everywhere*, so users never have to wonder.
4207 4208 (Magic.magic_macro): Added @macro function to ease the creation of
4208 4209 macros.
4209 4210
4210 4211 2002-01-05 Fernando Perez <fperez@colorado.edu>
4211 4212
4212 4213 * Released 0.2.4.
4213 4214
4214 4215 * IPython/iplib.py (Magic.magic_pdef):
4215 4216 (InteractiveShell.safe_execfile): report magic lines and error
4216 4217 lines without line numbers so one can easily copy/paste them for
4217 4218 re-execution.
4218 4219
4219 4220 * Updated manual with recent changes.
4220 4221
4221 4222 * IPython/iplib.py (Magic.magic_oinfo): added constructor
4222 4223 docstring printing when class? is called. Very handy for knowing
4223 4224 how to create class instances (as long as __init__ is well
4224 4225 documented, of course :)
4225 4226 (Magic.magic_doc): print both class and constructor docstrings.
4226 4227 (Magic.magic_pdef): give constructor info if passed a class and
4227 4228 __call__ info for callable object instances.
4228 4229
4229 4230 2002-01-04 Fernando Perez <fperez@colorado.edu>
4230 4231
4231 4232 * Made deep_reload() off by default. It doesn't always work
4232 4233 exactly as intended, so it's probably safer to have it off. It's
4233 4234 still available as dreload() anyway, so nothing is lost.
4234 4235
4235 4236 2002-01-02 Fernando Perez <fperez@colorado.edu>
4236 4237
4237 4238 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4238 4239 so I wanted an updated release).
4239 4240
4240 4241 2001-12-27 Fernando Perez <fperez@colorado.edu>
4241 4242
4242 4243 * IPython/iplib.py (InteractiveShell.interact): Added the original
4243 4244 code from 'code.py' for this module in order to change the
4244 4245 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4245 4246 the history cache would break when the user hit Ctrl-C, and
4246 4247 interact() offers no way to add any hooks to it.
4247 4248
4248 4249 2001-12-23 Fernando Perez <fperez@colorado.edu>
4249 4250
4250 4251 * setup.py: added check for 'MANIFEST' before trying to remove
4251 4252 it. Thanks to Sean Reifschneider.
4252 4253
4253 4254 2001-12-22 Fernando Perez <fperez@colorado.edu>
4254 4255
4255 4256 * Released 0.2.2.
4256 4257
4257 4258 * Finished (reasonably) writing the manual. Later will add the
4258 4259 python-standard navigation stylesheets, but for the time being
4259 4260 it's fairly complete. Distribution will include html and pdf
4260 4261 versions.
4261 4262
4262 4263 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4263 4264 (MayaVi author).
4264 4265
4265 4266 2001-12-21 Fernando Perez <fperez@colorado.edu>
4266 4267
4267 4268 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4268 4269 good public release, I think (with the manual and the distutils
4269 4270 installer). The manual can use some work, but that can go
4270 4271 slowly. Otherwise I think it's quite nice for end users. Next
4271 4272 summer, rewrite the guts of it...
4272 4273
4273 4274 * Changed format of ipythonrc files to use whitespace as the
4274 4275 separator instead of an explicit '='. Cleaner.
4275 4276
4276 4277 2001-12-20 Fernando Perez <fperez@colorado.edu>
4277 4278
4278 4279 * Started a manual in LyX. For now it's just a quick merge of the
4279 4280 various internal docstrings and READMEs. Later it may grow into a
4280 4281 nice, full-blown manual.
4281 4282
4282 4283 * Set up a distutils based installer. Installation should now be
4283 4284 trivially simple for end-users.
4284 4285
4285 4286 2001-12-11 Fernando Perez <fperez@colorado.edu>
4286 4287
4287 4288 * Released 0.2.0. First public release, announced it at
4288 4289 comp.lang.python. From now on, just bugfixes...
4289 4290
4290 4291 * Went through all the files, set copyright/license notices and
4291 4292 cleaned up things. Ready for release.
4292 4293
4293 4294 2001-12-10 Fernando Perez <fperez@colorado.edu>
4294 4295
4295 4296 * Changed the first-time installer not to use tarfiles. It's more
4296 4297 robust now and less unix-dependent. Also makes it easier for
4297 4298 people to later upgrade versions.
4298 4299
4299 4300 * Changed @exit to @abort to reflect the fact that it's pretty
4300 4301 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4301 4302 becomes significant only when IPyhton is embedded: in that case,
4302 4303 C-D closes IPython only, but @abort kills the enclosing program
4303 4304 too (unless it had called IPython inside a try catching
4304 4305 SystemExit).
4305 4306
4306 4307 * Created Shell module which exposes the actuall IPython Shell
4307 4308 classes, currently the normal and the embeddable one. This at
4308 4309 least offers a stable interface we won't need to change when
4309 4310 (later) the internals are rewritten. That rewrite will be confined
4310 4311 to iplib and ipmaker, but the Shell interface should remain as is.
4311 4312
4312 4313 * Added embed module which offers an embeddable IPShell object,
4313 4314 useful to fire up IPython *inside* a running program. Great for
4314 4315 debugging or dynamical data analysis.
4315 4316
4316 4317 2001-12-08 Fernando Perez <fperez@colorado.edu>
4317 4318
4318 4319 * Fixed small bug preventing seeing info from methods of defined
4319 4320 objects (incorrect namespace in _ofind()).
4320 4321
4321 4322 * Documentation cleanup. Moved the main usage docstrings to a
4322 4323 separate file, usage.py (cleaner to maintain, and hopefully in the
4323 4324 future some perlpod-like way of producing interactive, man and
4324 4325 html docs out of it will be found).
4325 4326
4326 4327 * Added @profile to see your profile at any time.
4327 4328
4328 4329 * Added @p as an alias for 'print'. It's especially convenient if
4329 4330 using automagic ('p x' prints x).
4330 4331
4331 4332 * Small cleanups and fixes after a pychecker run.
4332 4333
4333 4334 * Changed the @cd command to handle @cd - and @cd -<n> for
4334 4335 visiting any directory in _dh.
4335 4336
4336 4337 * Introduced _dh, a history of visited directories. @dhist prints
4337 4338 it out with numbers.
4338 4339
4339 4340 2001-12-07 Fernando Perez <fperez@colorado.edu>
4340 4341
4341 4342 * Released 0.1.22
4342 4343
4343 4344 * Made initialization a bit more robust against invalid color
4344 4345 options in user input (exit, not traceback-crash).
4345 4346
4346 4347 * Changed the bug crash reporter to write the report only in the
4347 4348 user's .ipython directory. That way IPython won't litter people's
4348 4349 hard disks with crash files all over the place. Also print on
4349 4350 screen the necessary mail command.
4350 4351
4351 4352 * With the new ultraTB, implemented LightBG color scheme for light
4352 4353 background terminals. A lot of people like white backgrounds, so I
4353 4354 guess we should at least give them something readable.
4354 4355
4355 4356 2001-12-06 Fernando Perez <fperez@colorado.edu>
4356 4357
4357 4358 * Modified the structure of ultraTB. Now there's a proper class
4358 4359 for tables of color schemes which allow adding schemes easily and
4359 4360 switching the active scheme without creating a new instance every
4360 4361 time (which was ridiculous). The syntax for creating new schemes
4361 4362 is also cleaner. I think ultraTB is finally done, with a clean
4362 4363 class structure. Names are also much cleaner (now there's proper
4363 4364 color tables, no need for every variable to also have 'color' in
4364 4365 its name).
4365 4366
4366 4367 * Broke down genutils into separate files. Now genutils only
4367 4368 contains utility functions, and classes have been moved to their
4368 4369 own files (they had enough independent functionality to warrant
4369 4370 it): ConfigLoader, OutputTrap, Struct.
4370 4371
4371 4372 2001-12-05 Fernando Perez <fperez@colorado.edu>
4372 4373
4373 4374 * IPython turns 21! Released version 0.1.21, as a candidate for
4374 4375 public consumption. If all goes well, release in a few days.
4375 4376
4376 4377 * Fixed path bug (files in Extensions/ directory wouldn't be found
4377 4378 unless IPython/ was explicitly in sys.path).
4378 4379
4379 4380 * Extended the FlexCompleter class as MagicCompleter to allow
4380 4381 completion of @-starting lines.
4381 4382
4382 4383 * Created __release__.py file as a central repository for release
4383 4384 info that other files can read from.
4384 4385
4385 4386 * Fixed small bug in logging: when logging was turned on in
4386 4387 mid-session, old lines with special meanings (!@?) were being
4387 4388 logged without the prepended comment, which is necessary since
4388 4389 they are not truly valid python syntax. This should make session
4389 4390 restores produce less errors.
4390 4391
4391 4392 * The namespace cleanup forced me to make a FlexCompleter class
4392 4393 which is nothing but a ripoff of rlcompleter, but with selectable
4393 4394 namespace (rlcompleter only works in __main__.__dict__). I'll try
4394 4395 to submit a note to the authors to see if this change can be
4395 4396 incorporated in future rlcompleter releases (Dec.6: done)
4396 4397
4397 4398 * More fixes to namespace handling. It was a mess! Now all
4398 4399 explicit references to __main__.__dict__ are gone (except when
4399 4400 really needed) and everything is handled through the namespace
4400 4401 dicts in the IPython instance. We seem to be getting somewhere
4401 4402 with this, finally...
4402 4403
4403 4404 * Small documentation updates.
4404 4405
4405 4406 * Created the Extensions directory under IPython (with an
4406 4407 __init__.py). Put the PhysicalQ stuff there. This directory should
4407 4408 be used for all special-purpose extensions.
4408 4409
4409 4410 * File renaming:
4410 4411 ipythonlib --> ipmaker
4411 4412 ipplib --> iplib
4412 4413 This makes a bit more sense in terms of what these files actually do.
4413 4414
4414 4415 * Moved all the classes and functions in ipythonlib to ipplib, so
4415 4416 now ipythonlib only has make_IPython(). This will ease up its
4416 4417 splitting in smaller functional chunks later.
4417 4418
4418 4419 * Cleaned up (done, I think) output of @whos. Better column
4419 4420 formatting, and now shows str(var) for as much as it can, which is
4420 4421 typically what one gets with a 'print var'.
4421 4422
4422 4423 2001-12-04 Fernando Perez <fperez@colorado.edu>
4423 4424
4424 4425 * Fixed namespace problems. Now builtin/IPyhton/user names get
4425 4426 properly reported in their namespace. Internal namespace handling
4426 4427 is finally getting decent (not perfect yet, but much better than
4427 4428 the ad-hoc mess we had).
4428 4429
4429 4430 * Removed -exit option. If people just want to run a python
4430 4431 script, that's what the normal interpreter is for. Less
4431 4432 unnecessary options, less chances for bugs.
4432 4433
4433 4434 * Added a crash handler which generates a complete post-mortem if
4434 4435 IPython crashes. This will help a lot in tracking bugs down the
4435 4436 road.
4436 4437
4437 4438 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4438 4439 which were boud to functions being reassigned would bypass the
4439 4440 logger, breaking the sync of _il with the prompt counter. This
4440 4441 would then crash IPython later when a new line was logged.
4441 4442
4442 4443 2001-12-02 Fernando Perez <fperez@colorado.edu>
4443 4444
4444 4445 * Made IPython a package. This means people don't have to clutter
4445 4446 their sys.path with yet another directory. Changed the INSTALL
4446 4447 file accordingly.
4447 4448
4448 4449 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4449 4450 sorts its output (so @who shows it sorted) and @whos formats the
4450 4451 table according to the width of the first column. Nicer, easier to
4451 4452 read. Todo: write a generic table_format() which takes a list of
4452 4453 lists and prints it nicely formatted, with optional row/column
4453 4454 separators and proper padding and justification.
4454 4455
4455 4456 * Released 0.1.20
4456 4457
4457 4458 * Fixed bug in @log which would reverse the inputcache list (a
4458 4459 copy operation was missing).
4459 4460
4460 4461 * Code cleanup. @config was changed to use page(). Better, since
4461 4462 its output is always quite long.
4462 4463
4463 4464 * Itpl is back as a dependency. I was having too many problems
4464 4465 getting the parametric aliases to work reliably, and it's just
4465 4466 easier to code weird string operations with it than playing %()s
4466 4467 games. It's only ~6k, so I don't think it's too big a deal.
4467 4468
4468 4469 * Found (and fixed) a very nasty bug with history. !lines weren't
4469 4470 getting cached, and the out of sync caches would crash
4470 4471 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4471 4472 division of labor a bit better. Bug fixed, cleaner structure.
4472 4473
4473 4474 2001-12-01 Fernando Perez <fperez@colorado.edu>
4474 4475
4475 4476 * Released 0.1.19
4476 4477
4477 4478 * Added option -n to @hist to prevent line number printing. Much
4478 4479 easier to copy/paste code this way.
4479 4480
4480 4481 * Created global _il to hold the input list. Allows easy
4481 4482 re-execution of blocks of code by slicing it (inspired by Janko's
4482 4483 comment on 'macros').
4483 4484
4484 4485 * Small fixes and doc updates.
4485 4486
4486 4487 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4487 4488 much too fragile with automagic. Handles properly multi-line
4488 4489 statements and takes parameters.
4489 4490
4490 4491 2001-11-30 Fernando Perez <fperez@colorado.edu>
4491 4492
4492 4493 * Version 0.1.18 released.
4493 4494
4494 4495 * Fixed nasty namespace bug in initial module imports.
4495 4496
4496 4497 * Added copyright/license notes to all code files (except
4497 4498 DPyGetOpt). For the time being, LGPL. That could change.
4498 4499
4499 4500 * Rewrote a much nicer README, updated INSTALL, cleaned up
4500 4501 ipythonrc-* samples.
4501 4502
4502 4503 * Overall code/documentation cleanup. Basically ready for
4503 4504 release. Only remaining thing: licence decision (LGPL?).
4504 4505
4505 4506 * Converted load_config to a class, ConfigLoader. Now recursion
4506 4507 control is better organized. Doesn't include the same file twice.
4507 4508
4508 4509 2001-11-29 Fernando Perez <fperez@colorado.edu>
4509 4510
4510 4511 * Got input history working. Changed output history variables from
4511 4512 _p to _o so that _i is for input and _o for output. Just cleaner
4512 4513 convention.
4513 4514
4514 4515 * Implemented parametric aliases. This pretty much allows the
4515 4516 alias system to offer full-blown shell convenience, I think.
4516 4517
4517 4518 * Version 0.1.17 released, 0.1.18 opened.
4518 4519
4519 4520 * dot_ipython/ipythonrc (alias): added documentation.
4520 4521 (xcolor): Fixed small bug (xcolors -> xcolor)
4521 4522
4522 4523 * Changed the alias system. Now alias is a magic command to define
4523 4524 aliases just like the shell. Rationale: the builtin magics should
4524 4525 be there for things deeply connected to IPython's
4525 4526 architecture. And this is a much lighter system for what I think
4526 4527 is the really important feature: allowing users to define quickly
4527 4528 magics that will do shell things for them, so they can customize
4528 4529 IPython easily to match their work habits. If someone is really
4529 4530 desperate to have another name for a builtin alias, they can
4530 4531 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4531 4532 works.
4532 4533
4533 4534 2001-11-28 Fernando Perez <fperez@colorado.edu>
4534 4535
4535 4536 * Changed @file so that it opens the source file at the proper
4536 4537 line. Since it uses less, if your EDITOR environment is
4537 4538 configured, typing v will immediately open your editor of choice
4538 4539 right at the line where the object is defined. Not as quick as
4539 4540 having a direct @edit command, but for all intents and purposes it
4540 4541 works. And I don't have to worry about writing @edit to deal with
4541 4542 all the editors, less does that.
4542 4543
4543 4544 * Version 0.1.16 released, 0.1.17 opened.
4544 4545
4545 4546 * Fixed some nasty bugs in the page/page_dumb combo that could
4546 4547 crash IPython.
4547 4548
4548 4549 2001-11-27 Fernando Perez <fperez@colorado.edu>
4549 4550
4550 4551 * Version 0.1.15 released, 0.1.16 opened.
4551 4552
4552 4553 * Finally got ? and ?? to work for undefined things: now it's
4553 4554 possible to type {}.get? and get information about the get method
4554 4555 of dicts, or os.path? even if only os is defined (so technically
4555 4556 os.path isn't). Works at any level. For example, after import os,
4556 4557 os?, os.path?, os.path.abspath? all work. This is great, took some
4557 4558 work in _ofind.
4558 4559
4559 4560 * Fixed more bugs with logging. The sanest way to do it was to add
4560 4561 to @log a 'mode' parameter. Killed two in one shot (this mode
4561 4562 option was a request of Janko's). I think it's finally clean
4562 4563 (famous last words).
4563 4564
4564 4565 * Added a page_dumb() pager which does a decent job of paging on
4565 4566 screen, if better things (like less) aren't available. One less
4566 4567 unix dependency (someday maybe somebody will port this to
4567 4568 windows).
4568 4569
4569 4570 * Fixed problem in magic_log: would lock of logging out if log
4570 4571 creation failed (because it would still think it had succeeded).
4571 4572
4572 4573 * Improved the page() function using curses to auto-detect screen
4573 4574 size. Now it can make a much better decision on whether to print
4574 4575 or page a string. Option screen_length was modified: a value 0
4575 4576 means auto-detect, and that's the default now.
4576 4577
4577 4578 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4578 4579 go out. I'll test it for a few days, then talk to Janko about
4579 4580 licences and announce it.
4580 4581
4581 4582 * Fixed the length of the auto-generated ---> prompt which appears
4582 4583 for auto-parens and auto-quotes. Getting this right isn't trivial,
4583 4584 with all the color escapes, different prompt types and optional
4584 4585 separators. But it seems to be working in all the combinations.
4585 4586
4586 4587 2001-11-26 Fernando Perez <fperez@colorado.edu>
4587 4588
4588 4589 * Wrote a regexp filter to get option types from the option names
4589 4590 string. This eliminates the need to manually keep two duplicate
4590 4591 lists.
4591 4592
4592 4593 * Removed the unneeded check_option_names. Now options are handled
4593 4594 in a much saner manner and it's easy to visually check that things
4594 4595 are ok.
4595 4596
4596 4597 * Updated version numbers on all files I modified to carry a
4597 4598 notice so Janko and Nathan have clear version markers.
4598 4599
4599 4600 * Updated docstring for ultraTB with my changes. I should send
4600 4601 this to Nathan.
4601 4602
4602 4603 * Lots of small fixes. Ran everything through pychecker again.
4603 4604
4604 4605 * Made loading of deep_reload an cmd line option. If it's not too
4605 4606 kosher, now people can just disable it. With -nodeep_reload it's
4606 4607 still available as dreload(), it just won't overwrite reload().
4607 4608
4608 4609 * Moved many options to the no| form (-opt and -noopt
4609 4610 accepted). Cleaner.
4610 4611
4611 4612 * Changed magic_log so that if called with no parameters, it uses
4612 4613 'rotate' mode. That way auto-generated logs aren't automatically
4613 4614 over-written. For normal logs, now a backup is made if it exists
4614 4615 (only 1 level of backups). A new 'backup' mode was added to the
4615 4616 Logger class to support this. This was a request by Janko.
4616 4617
4617 4618 * Added @logoff/@logon to stop/restart an active log.
4618 4619
4619 4620 * Fixed a lot of bugs in log saving/replay. It was pretty
4620 4621 broken. Now special lines (!@,/) appear properly in the command
4621 4622 history after a log replay.
4622 4623
4623 4624 * Tried and failed to implement full session saving via pickle. My
4624 4625 idea was to pickle __main__.__dict__, but modules can't be
4625 4626 pickled. This would be a better alternative to replaying logs, but
4626 4627 seems quite tricky to get to work. Changed -session to be called
4627 4628 -logplay, which more accurately reflects what it does. And if we
4628 4629 ever get real session saving working, -session is now available.
4629 4630
4630 4631 * Implemented color schemes for prompts also. As for tracebacks,
4631 4632 currently only NoColor and Linux are supported. But now the
4632 4633 infrastructure is in place, based on a generic ColorScheme
4633 4634 class. So writing and activating new schemes both for the prompts
4634 4635 and the tracebacks should be straightforward.
4635 4636
4636 4637 * Version 0.1.13 released, 0.1.14 opened.
4637 4638
4638 4639 * Changed handling of options for output cache. Now counter is
4639 4640 hardwired starting at 1 and one specifies the maximum number of
4640 4641 entries *in the outcache* (not the max prompt counter). This is
4641 4642 much better, since many statements won't increase the cache
4642 4643 count. It also eliminated some confusing options, now there's only
4643 4644 one: cache_size.
4644 4645
4645 4646 * Added 'alias' magic function and magic_alias option in the
4646 4647 ipythonrc file. Now the user can easily define whatever names he
4647 4648 wants for the magic functions without having to play weird
4648 4649 namespace games. This gives IPython a real shell-like feel.
4649 4650
4650 4651 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4651 4652 @ or not).
4652 4653
4653 4654 This was one of the last remaining 'visible' bugs (that I know
4654 4655 of). I think if I can clean up the session loading so it works
4655 4656 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4656 4657 about licensing).
4657 4658
4658 4659 2001-11-25 Fernando Perez <fperez@colorado.edu>
4659 4660
4660 4661 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4661 4662 there's a cleaner distinction between what ? and ?? show.
4662 4663
4663 4664 * Added screen_length option. Now the user can define his own
4664 4665 screen size for page() operations.
4665 4666
4666 4667 * Implemented magic shell-like functions with automatic code
4667 4668 generation. Now adding another function is just a matter of adding
4668 4669 an entry to a dict, and the function is dynamically generated at
4669 4670 run-time. Python has some really cool features!
4670 4671
4671 4672 * Renamed many options to cleanup conventions a little. Now all
4672 4673 are lowercase, and only underscores where needed. Also in the code
4673 4674 option name tables are clearer.
4674 4675
4675 4676 * Changed prompts a little. Now input is 'In [n]:' instead of
4676 4677 'In[n]:='. This allows it the numbers to be aligned with the
4677 4678 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4678 4679 Python (it was a Mathematica thing). The '...' continuation prompt
4679 4680 was also changed a little to align better.
4680 4681
4681 4682 * Fixed bug when flushing output cache. Not all _p<n> variables
4682 4683 exist, so their deletion needs to be wrapped in a try:
4683 4684
4684 4685 * Figured out how to properly use inspect.formatargspec() (it
4685 4686 requires the args preceded by *). So I removed all the code from
4686 4687 _get_pdef in Magic, which was just replicating that.
4687 4688
4688 4689 * Added test to prefilter to allow redefining magic function names
4689 4690 as variables. This is ok, since the @ form is always available,
4690 4691 but whe should allow the user to define a variable called 'ls' if
4691 4692 he needs it.
4692 4693
4693 4694 * Moved the ToDo information from README into a separate ToDo.
4694 4695
4695 4696 * General code cleanup and small bugfixes. I think it's close to a
4696 4697 state where it can be released, obviously with a big 'beta'
4697 4698 warning on it.
4698 4699
4699 4700 * Got the magic function split to work. Now all magics are defined
4700 4701 in a separate class. It just organizes things a bit, and now
4701 4702 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4702 4703 was too long).
4703 4704
4704 4705 * Changed @clear to @reset to avoid potential confusions with
4705 4706 the shell command clear. Also renamed @cl to @clear, which does
4706 4707 exactly what people expect it to from their shell experience.
4707 4708
4708 4709 Added a check to the @reset command (since it's so
4709 4710 destructive, it's probably a good idea to ask for confirmation).
4710 4711 But now reset only works for full namespace resetting. Since the
4711 4712 del keyword is already there for deleting a few specific
4712 4713 variables, I don't see the point of having a redundant magic
4713 4714 function for the same task.
4714 4715
4715 4716 2001-11-24 Fernando Perez <fperez@colorado.edu>
4716 4717
4717 4718 * Updated the builtin docs (esp. the ? ones).
4718 4719
4719 4720 * Ran all the code through pychecker. Not terribly impressed with
4720 4721 it: lots of spurious warnings and didn't really find anything of
4721 4722 substance (just a few modules being imported and not used).
4722 4723
4723 4724 * Implemented the new ultraTB functionality into IPython. New
4724 4725 option: xcolors. This chooses color scheme. xmode now only selects
4725 4726 between Plain and Verbose. Better orthogonality.
4726 4727
4727 4728 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4728 4729 mode and color scheme for the exception handlers. Now it's
4729 4730 possible to have the verbose traceback with no coloring.
4730 4731
4731 4732 2001-11-23 Fernando Perez <fperez@colorado.edu>
4732 4733
4733 4734 * Version 0.1.12 released, 0.1.13 opened.
4734 4735
4735 4736 * Removed option to set auto-quote and auto-paren escapes by
4736 4737 user. The chances of breaking valid syntax are just too high. If
4737 4738 someone *really* wants, they can always dig into the code.
4738 4739
4739 4740 * Made prompt separators configurable.
4740 4741
4741 4742 2001-11-22 Fernando Perez <fperez@colorado.edu>
4742 4743
4743 4744 * Small bugfixes in many places.
4744 4745
4745 4746 * Removed the MyCompleter class from ipplib. It seemed redundant
4746 4747 with the C-p,C-n history search functionality. Less code to
4747 4748 maintain.
4748 4749
4749 4750 * Moved all the original ipython.py code into ipythonlib.py. Right
4750 4751 now it's just one big dump into a function called make_IPython, so
4751 4752 no real modularity has been gained. But at least it makes the
4752 4753 wrapper script tiny, and since ipythonlib is a module, it gets
4753 4754 compiled and startup is much faster.
4754 4755
4755 4756 This is a reasobably 'deep' change, so we should test it for a
4756 4757 while without messing too much more with the code.
4757 4758
4758 4759 2001-11-21 Fernando Perez <fperez@colorado.edu>
4759 4760
4760 4761 * Version 0.1.11 released, 0.1.12 opened for further work.
4761 4762
4762 4763 * Removed dependency on Itpl. It was only needed in one place. It
4763 4764 would be nice if this became part of python, though. It makes life
4764 4765 *a lot* easier in some cases.
4765 4766
4766 4767 * Simplified the prefilter code a bit. Now all handlers are
4767 4768 expected to explicitly return a value (at least a blank string).
4768 4769
4769 4770 * Heavy edits in ipplib. Removed the help system altogether. Now
4770 4771 obj?/?? is used for inspecting objects, a magic @doc prints
4771 4772 docstrings, and full-blown Python help is accessed via the 'help'
4772 4773 keyword. This cleans up a lot of code (less to maintain) and does
4773 4774 the job. Since 'help' is now a standard Python component, might as
4774 4775 well use it and remove duplicate functionality.
4775 4776
4776 4777 Also removed the option to use ipplib as a standalone program. By
4777 4778 now it's too dependent on other parts of IPython to function alone.
4778 4779
4779 4780 * Fixed bug in genutils.pager. It would crash if the pager was
4780 4781 exited immediately after opening (broken pipe).
4781 4782
4782 4783 * Trimmed down the VerboseTB reporting a little. The header is
4783 4784 much shorter now and the repeated exception arguments at the end
4784 4785 have been removed. For interactive use the old header seemed a bit
4785 4786 excessive.
4786 4787
4787 4788 * Fixed small bug in output of @whos for variables with multi-word
4788 4789 types (only first word was displayed).
4789 4790
4790 4791 2001-11-17 Fernando Perez <fperez@colorado.edu>
4791 4792
4792 4793 * Version 0.1.10 released, 0.1.11 opened for further work.
4793 4794
4794 4795 * Modified dirs and friends. dirs now *returns* the stack (not
4795 4796 prints), so one can manipulate it as a variable. Convenient to
4796 4797 travel along many directories.
4797 4798
4798 4799 * Fixed bug in magic_pdef: would only work with functions with
4799 4800 arguments with default values.
4800 4801
4801 4802 2001-11-14 Fernando Perez <fperez@colorado.edu>
4802 4803
4803 4804 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4804 4805 example with IPython. Various other minor fixes and cleanups.
4805 4806
4806 4807 * Version 0.1.9 released, 0.1.10 opened for further work.
4807 4808
4808 4809 * Added sys.path to the list of directories searched in the
4809 4810 execfile= option. It used to be the current directory and the
4810 4811 user's IPYTHONDIR only.
4811 4812
4812 4813 2001-11-13 Fernando Perez <fperez@colorado.edu>
4813 4814
4814 4815 * Reinstated the raw_input/prefilter separation that Janko had
4815 4816 initially. This gives a more convenient setup for extending the
4816 4817 pre-processor from the outside: raw_input always gets a string,
4817 4818 and prefilter has to process it. We can then redefine prefilter
4818 4819 from the outside and implement extensions for special
4819 4820 purposes.
4820 4821
4821 4822 Today I got one for inputting PhysicalQuantity objects
4822 4823 (from Scientific) without needing any function calls at
4823 4824 all. Extremely convenient, and it's all done as a user-level
4824 4825 extension (no IPython code was touched). Now instead of:
4825 4826 a = PhysicalQuantity(4.2,'m/s**2')
4826 4827 one can simply say
4827 4828 a = 4.2 m/s**2
4828 4829 or even
4829 4830 a = 4.2 m/s^2
4830 4831
4831 4832 I use this, but it's also a proof of concept: IPython really is
4832 4833 fully user-extensible, even at the level of the parsing of the
4833 4834 command line. It's not trivial, but it's perfectly doable.
4834 4835
4835 4836 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4836 4837 the problem of modules being loaded in the inverse order in which
4837 4838 they were defined in
4838 4839
4839 4840 * Version 0.1.8 released, 0.1.9 opened for further work.
4840 4841
4841 4842 * Added magics pdef, source and file. They respectively show the
4842 4843 definition line ('prototype' in C), source code and full python
4843 4844 file for any callable object. The object inspector oinfo uses
4844 4845 these to show the same information.
4845 4846
4846 4847 * Version 0.1.7 released, 0.1.8 opened for further work.
4847 4848
4848 4849 * Separated all the magic functions into a class called Magic. The
4849 4850 InteractiveShell class was becoming too big for Xemacs to handle
4850 4851 (de-indenting a line would lock it up for 10 seconds while it
4851 4852 backtracked on the whole class!)
4852 4853
4853 4854 FIXME: didn't work. It can be done, but right now namespaces are
4854 4855 all messed up. Do it later (reverted it for now, so at least
4855 4856 everything works as before).
4856 4857
4857 4858 * Got the object introspection system (magic_oinfo) working! I
4858 4859 think this is pretty much ready for release to Janko, so he can
4859 4860 test it for a while and then announce it. Pretty much 100% of what
4860 4861 I wanted for the 'phase 1' release is ready. Happy, tired.
4861 4862
4862 4863 2001-11-12 Fernando Perez <fperez@colorado.edu>
4863 4864
4864 4865 * Version 0.1.6 released, 0.1.7 opened for further work.
4865 4866
4866 4867 * Fixed bug in printing: it used to test for truth before
4867 4868 printing, so 0 wouldn't print. Now checks for None.
4868 4869
4869 4870 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4870 4871 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4871 4872 reaches by hand into the outputcache. Think of a better way to do
4872 4873 this later.
4873 4874
4874 4875 * Various small fixes thanks to Nathan's comments.
4875 4876
4876 4877 * Changed magic_pprint to magic_Pprint. This way it doesn't
4877 4878 collide with pprint() and the name is consistent with the command
4878 4879 line option.
4879 4880
4880 4881 * Changed prompt counter behavior to be fully like
4881 4882 Mathematica's. That is, even input that doesn't return a result
4882 4883 raises the prompt counter. The old behavior was kind of confusing
4883 4884 (getting the same prompt number several times if the operation
4884 4885 didn't return a result).
4885 4886
4886 4887 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4887 4888
4888 4889 * Fixed -Classic mode (wasn't working anymore).
4889 4890
4890 4891 * Added colored prompts using Nathan's new code. Colors are
4891 4892 currently hardwired, they can be user-configurable. For
4892 4893 developers, they can be chosen in file ipythonlib.py, at the
4893 4894 beginning of the CachedOutput class def.
4894 4895
4895 4896 2001-11-11 Fernando Perez <fperez@colorado.edu>
4896 4897
4897 4898 * Version 0.1.5 released, 0.1.6 opened for further work.
4898 4899
4899 4900 * Changed magic_env to *return* the environment as a dict (not to
4900 4901 print it). This way it prints, but it can also be processed.
4901 4902
4902 4903 * Added Verbose exception reporting to interactive
4903 4904 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4904 4905 traceback. Had to make some changes to the ultraTB file. This is
4905 4906 probably the last 'big' thing in my mental todo list. This ties
4906 4907 in with the next entry:
4907 4908
4908 4909 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4909 4910 has to specify is Plain, Color or Verbose for all exception
4910 4911 handling.
4911 4912
4912 4913 * Removed ShellServices option. All this can really be done via
4913 4914 the magic system. It's easier to extend, cleaner and has automatic
4914 4915 namespace protection and documentation.
4915 4916
4916 4917 2001-11-09 Fernando Perez <fperez@colorado.edu>
4917 4918
4918 4919 * Fixed bug in output cache flushing (missing parameter to
4919 4920 __init__). Other small bugs fixed (found using pychecker).
4920 4921
4921 4922 * Version 0.1.4 opened for bugfixing.
4922 4923
4923 4924 2001-11-07 Fernando Perez <fperez@colorado.edu>
4924 4925
4925 4926 * Version 0.1.3 released, mainly because of the raw_input bug.
4926 4927
4927 4928 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4928 4929 and when testing for whether things were callable, a call could
4929 4930 actually be made to certain functions. They would get called again
4930 4931 once 'really' executed, with a resulting double call. A disaster
4931 4932 in many cases (list.reverse() would never work!).
4932 4933
4933 4934 * Removed prefilter() function, moved its code to raw_input (which
4934 4935 after all was just a near-empty caller for prefilter). This saves
4935 4936 a function call on every prompt, and simplifies the class a tiny bit.
4936 4937
4937 4938 * Fix _ip to __ip name in magic example file.
4938 4939
4939 4940 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4940 4941 work with non-gnu versions of tar.
4941 4942
4942 4943 2001-11-06 Fernando Perez <fperez@colorado.edu>
4943 4944
4944 4945 * Version 0.1.2. Just to keep track of the recent changes.
4945 4946
4946 4947 * Fixed nasty bug in output prompt routine. It used to check 'if
4947 4948 arg != None...'. Problem is, this fails if arg implements a
4948 4949 special comparison (__cmp__) which disallows comparing to
4949 4950 None. Found it when trying to use the PhysicalQuantity module from
4950 4951 ScientificPython.
4951 4952
4952 4953 2001-11-05 Fernando Perez <fperez@colorado.edu>
4953 4954
4954 4955 * Also added dirs. Now the pushd/popd/dirs family functions
4955 4956 basically like the shell, with the added convenience of going home
4956 4957 when called with no args.
4957 4958
4958 4959 * pushd/popd slightly modified to mimic shell behavior more
4959 4960 closely.
4960 4961
4961 4962 * Added env,pushd,popd from ShellServices as magic functions. I
4962 4963 think the cleanest will be to port all desired functions from
4963 4964 ShellServices as magics and remove ShellServices altogether. This
4964 4965 will provide a single, clean way of adding functionality
4965 4966 (shell-type or otherwise) to IP.
4966 4967
4967 4968 2001-11-04 Fernando Perez <fperez@colorado.edu>
4968 4969
4969 4970 * Added .ipython/ directory to sys.path. This way users can keep
4970 4971 customizations there and access them via import.
4971 4972
4972 4973 2001-11-03 Fernando Perez <fperez@colorado.edu>
4973 4974
4974 4975 * Opened version 0.1.1 for new changes.
4975 4976
4976 4977 * Changed version number to 0.1.0: first 'public' release, sent to
4977 4978 Nathan and Janko.
4978 4979
4979 4980 * Lots of small fixes and tweaks.
4980 4981
4981 4982 * Minor changes to whos format. Now strings are shown, snipped if
4982 4983 too long.
4983 4984
4984 4985 * Changed ShellServices to work on __main__ so they show up in @who
4985 4986
4986 4987 * Help also works with ? at the end of a line:
4987 4988 ?sin and sin?
4988 4989 both produce the same effect. This is nice, as often I use the
4989 4990 tab-complete to find the name of a method, but I used to then have
4990 4991 to go to the beginning of the line to put a ? if I wanted more
4991 4992 info. Now I can just add the ? and hit return. Convenient.
4992 4993
4993 4994 2001-11-02 Fernando Perez <fperez@colorado.edu>
4994 4995
4995 4996 * Python version check (>=2.1) added.
4996 4997
4997 4998 * Added LazyPython documentation. At this point the docs are quite
4998 4999 a mess. A cleanup is in order.
4999 5000
5000 5001 * Auto-installer created. For some bizarre reason, the zipfiles
5001 5002 module isn't working on my system. So I made a tar version
5002 5003 (hopefully the command line options in various systems won't kill
5003 5004 me).
5004 5005
5005 5006 * Fixes to Struct in genutils. Now all dictionary-like methods are
5006 5007 protected (reasonably).
5007 5008
5008 5009 * Added pager function to genutils and changed ? to print usage
5009 5010 note through it (it was too long).
5010 5011
5011 5012 * Added the LazyPython functionality. Works great! I changed the
5012 5013 auto-quote escape to ';', it's on home row and next to '. But
5013 5014 both auto-quote and auto-paren (still /) escapes are command-line
5014 5015 parameters.
5015 5016
5016 5017
5017 5018 2001-11-01 Fernando Perez <fperez@colorado.edu>
5018 5019
5019 5020 * Version changed to 0.0.7. Fairly large change: configuration now
5020 5021 is all stored in a directory, by default .ipython. There, all
5021 5022 config files have normal looking names (not .names)
5022 5023
5023 5024 * Version 0.0.6 Released first to Lucas and Archie as a test
5024 5025 run. Since it's the first 'semi-public' release, change version to
5025 5026 > 0.0.6 for any changes now.
5026 5027
5027 5028 * Stuff I had put in the ipplib.py changelog:
5028 5029
5029 5030 Changes to InteractiveShell:
5030 5031
5031 5032 - Made the usage message a parameter.
5032 5033
5033 5034 - Require the name of the shell variable to be given. It's a bit
5034 5035 of a hack, but allows the name 'shell' not to be hardwire in the
5035 5036 magic (@) handler, which is problematic b/c it requires
5036 5037 polluting the global namespace with 'shell'. This in turn is
5037 5038 fragile: if a user redefines a variable called shell, things
5038 5039 break.
5039 5040
5040 5041 - magic @: all functions available through @ need to be defined
5041 5042 as magic_<name>, even though they can be called simply as
5042 5043 @<name>. This allows the special command @magic to gather
5043 5044 information automatically about all existing magic functions,
5044 5045 even if they are run-time user extensions, by parsing the shell
5045 5046 instance __dict__ looking for special magic_ names.
5046 5047
5047 5048 - mainloop: added *two* local namespace parameters. This allows
5048 5049 the class to differentiate between parameters which were there
5049 5050 before and after command line initialization was processed. This
5050 5051 way, later @who can show things loaded at startup by the
5051 5052 user. This trick was necessary to make session saving/reloading
5052 5053 really work: ideally after saving/exiting/reloading a session,
5053 5054 *everythin* should look the same, including the output of @who. I
5054 5055 was only able to make this work with this double namespace
5055 5056 trick.
5056 5057
5057 5058 - added a header to the logfile which allows (almost) full
5058 5059 session restoring.
5059 5060
5060 5061 - prepend lines beginning with @ or !, with a and log
5061 5062 them. Why? !lines: may be useful to know what you did @lines:
5062 5063 they may affect session state. So when restoring a session, at
5063 5064 least inform the user of their presence. I couldn't quite get
5064 5065 them to properly re-execute, but at least the user is warned.
5065 5066
5066 5067 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now