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