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