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