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