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