##// END OF EJS Templates
- Work around pexcept buglet which causes wraparound problems with long...
fptest -
Show More
@@ -1,526 +1,548 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Tools for inspecting Python objects.
3 3
4 4 Uses syntax highlighting for presenting the various information elements.
5 5
6 6 Similar in spirit to the inspect module, but all calls take a name argument to
7 7 reference the name under which an object is being read.
8 8
9 $Id: OInspect.py 1625 2006-08-12 10:34:44Z vivainio $
9 $Id: OInspect.py 1850 2006-10-28 19:48:13Z fptest $
10 10 """
11 11
12 12 #*****************************************************************************
13 13 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
14 14 #
15 15 # Distributed under the terms of the BSD License. The full license is in
16 16 # the file COPYING, distributed as part of this software.
17 17 #*****************************************************************************
18 18
19 19 from IPython import Release
20 20 __author__ = '%s <%s>' % Release.authors['Fernando']
21 21 __license__ = Release.license
22 22
23 23 __all__ = ['Inspector','InspectColors']
24 24
25 25 # stdlib modules
26 26 import __builtin__
27 27 import inspect
28 28 import linecache
29 29 import string
30 30 import StringIO
31 31 import types
32 32 import os
33 33 import sys
34 34 # IPython's own
35 35 from IPython import PyColorize
36 36 from IPython.genutils import page,indent,Term,mkdict
37 37 from IPython.Itpl import itpl
38 38 from IPython.wildcard import list_namespace
39 39 from IPython.ColorANSI import *
40 40
41 41 #****************************************************************************
42 42 # HACK!!! This is a crude fix for bugs in python 2.3's inspect module. We
43 43 # simply monkeypatch inspect with code copied from python 2.4.
44 44 if sys.version_info[:2] == (2,3):
45 45 from inspect import ismodule, getabsfile, modulesbyfile
46 46 def getmodule(object):
47 47 """Return the module an object was defined in, or None if not found."""
48 48 if ismodule(object):
49 49 return object
50 50 if hasattr(object, '__module__'):
51 51 return sys.modules.get(object.__module__)
52 52 try:
53 53 file = getabsfile(object)
54 54 except TypeError:
55 55 return None
56 56 if file in modulesbyfile:
57 57 return sys.modules.get(modulesbyfile[file])
58 58 for module in sys.modules.values():
59 59 if hasattr(module, '__file__'):
60 60 modulesbyfile[
61 61 os.path.realpath(
62 62 getabsfile(module))] = module.__name__
63 63 if file in modulesbyfile:
64 64 return sys.modules.get(modulesbyfile[file])
65 65 main = sys.modules['__main__']
66 66 if not hasattr(object, '__name__'):
67 67 return None
68 68 if hasattr(main, object.__name__):
69 69 mainobject = getattr(main, object.__name__)
70 70 if mainobject is object:
71 71 return main
72 72 builtin = sys.modules['__builtin__']
73 73 if hasattr(builtin, object.__name__):
74 74 builtinobject = getattr(builtin, object.__name__)
75 75 if builtinobject is object:
76 76 return builtin
77 77
78 78 inspect.getmodule = getmodule
79 79
80 80 #****************************************************************************
81 81 # Builtin color schemes
82 82
83 83 Colors = TermColors # just a shorthand
84 84
85 85 # Build a few color schemes
86 86 NoColor = ColorScheme(
87 87 'NoColor',{
88 88 'header' : Colors.NoColor,
89 89 'normal' : Colors.NoColor # color off (usu. Colors.Normal)
90 90 } )
91 91
92 92 LinuxColors = ColorScheme(
93 93 'Linux',{
94 94 'header' : Colors.LightRed,
95 95 'normal' : Colors.Normal # color off (usu. Colors.Normal)
96 96 } )
97 97
98 98 LightBGColors = ColorScheme(
99 99 'LightBG',{
100 100 'header' : Colors.Red,
101 101 'normal' : Colors.Normal # color off (usu. Colors.Normal)
102 102 } )
103 103
104 104 # Build table of color schemes (needed by the parser)
105 105 InspectColors = ColorSchemeTable([NoColor,LinuxColors,LightBGColors],
106 106 'Linux')
107 107
108 108 #****************************************************************************
109 109 # Auxiliary functions
110 110 def getdoc(obj):
111 111 """Stable wrapper around inspect.getdoc.
112 112
113 113 This can't crash because of attribute problems.
114 114
115 115 It also attempts to call a getdoc() method on the given object. This
116 116 allows objects which provide their docstrings via non-standard mechanisms
117 117 (like Pyro proxies) to still be inspected by ipython's ? system."""
118 118
119 119 ds = None # default return value
120 120 try:
121 121 ds = inspect.getdoc(obj)
122 122 except:
123 123 # Harden against an inspect failure, which can occur with
124 124 # SWIG-wrapped extensions.
125 125 pass
126 126 # Allow objects to offer customized documentation via a getdoc method:
127 127 try:
128 128 ds2 = obj.getdoc()
129 129 except:
130 130 pass
131 131 else:
132 132 # if we get extra info, we add it to the normal docstring.
133 133 if ds is None:
134 134 ds = ds2
135 135 else:
136 136 ds = '%s\n%s' % (ds,ds2)
137 137 return ds
138 138
139 def getsource(obj,is_binary=False):
140 """Wrapper around inspect.getsource.
141
142 This can be modified by other projects to provide customized source
143 extraction.
144
145 Inputs:
146
147 - obj: an object whose source code we will attempt to extract.
148
149 Optional inputs:
150
151 - is_binary: whether the object is known to come from a binary source.
152 This implementation will skip returning any output for binary objects, but
153 custom extractors may know how to meaninfully process them."""
154
155 if is_binary:
156 return None
157 else:
158 return inspect.getsource(obj)
159
139 160 #****************************************************************************
140 161 # Class definitions
141 162
142 163 class myStringIO(StringIO.StringIO):
143 164 """Adds a writeln method to normal StringIO."""
144 165 def writeln(self,*arg,**kw):
145 166 """Does a write() and then a write('\n')"""
146 167 self.write(*arg,**kw)
147 168 self.write('\n')
148 169
149 170 class Inspector:
150 171 def __init__(self,color_table,code_color_table,scheme,
151 172 str_detail_level=0):
152 173 self.color_table = color_table
153 174 self.parser = PyColorize.Parser(code_color_table,out='str')
154 175 self.format = self.parser.format
155 176 self.str_detail_level = str_detail_level
156 177 self.set_active_scheme(scheme)
157 178
158 179 def __getargspec(self,obj):
159 180 """Get the names and default values of a function's arguments.
160 181
161 182 A tuple of four things is returned: (args, varargs, varkw, defaults).
162 183 'args' is a list of the argument names (it may contain nested lists).
163 184 'varargs' and 'varkw' are the names of the * and ** arguments or None.
164 185 'defaults' is an n-tuple of the default values of the last n arguments.
165 186
166 187 Modified version of inspect.getargspec from the Python Standard
167 188 Library."""
168 189
169 190 if inspect.isfunction(obj):
170 191 func_obj = obj
171 192 elif inspect.ismethod(obj):
172 193 func_obj = obj.im_func
173 194 else:
174 195 raise TypeError, 'arg is not a Python function'
175 196 args, varargs, varkw = inspect.getargs(func_obj.func_code)
176 197 return args, varargs, varkw, func_obj.func_defaults
177 198
178 199 def __getdef(self,obj,oname=''):
179 200 """Return the definition header for any callable object.
180 201
181 202 If any exception is generated, None is returned instead and the
182 203 exception is suppressed."""
183 204
184 205 try:
185 206 return oname + inspect.formatargspec(*self.__getargspec(obj))
186 207 except:
187 208 return None
188 209
189 210 def __head(self,h):
190 211 """Return a header string with proper colors."""
191 212 return '%s%s%s' % (self.color_table.active_colors.header,h,
192 213 self.color_table.active_colors.normal)
193 214
194 215 def set_active_scheme(self,scheme):
195 216 self.color_table.set_active_scheme(scheme)
196 217 self.parser.color_table.set_active_scheme(scheme)
197 218
198 219 def noinfo(self,msg,oname):
199 220 """Generic message when no information is found."""
200 221 print 'No %s found' % msg,
201 222 if oname:
202 223 print 'for %s' % oname
203 224 else:
204 225 print
205 226
206 227 def pdef(self,obj,oname=''):
207 228 """Print the definition header for any callable object.
208 229
209 230 If the object is a class, print the constructor information."""
210 231
211 232 if not callable(obj):
212 233 print 'Object is not callable.'
213 234 return
214 235
215 236 header = ''
216 237 if type(obj) is types.ClassType:
217 238 header = self.__head('Class constructor information:\n')
218 239 obj = obj.__init__
219 240 elif type(obj) is types.InstanceType:
220 241 obj = obj.__call__
221 242
222 243 output = self.__getdef(obj,oname)
223 244 if output is None:
224 245 self.noinfo('definition header',oname)
225 246 else:
226 247 print >>Term.cout, header,self.format(output),
227 248
228 249 def pdoc(self,obj,oname='',formatter = None):
229 250 """Print the docstring for any object.
230 251
231 252 Optional:
232 253 -formatter: a function to run the docstring through for specially
233 254 formatted docstrings."""
234 255
235 256 head = self.__head # so that itpl can find it even if private
236 257 ds = getdoc(obj)
237 258 if formatter:
238 259 ds = formatter(ds)
239 260 if type(obj) is types.ClassType:
240 261 init_ds = getdoc(obj.__init__)
241 262 output = itpl('$head("Class Docstring:")\n'
242 263 '$indent(ds)\n'
243 264 '$head("Constructor Docstring"):\n'
244 265 '$indent(init_ds)')
245 266 elif type(obj) is types.InstanceType and hasattr(obj,'__call__'):
246 267 call_ds = getdoc(obj.__call__)
247 268 if call_ds:
248 269 output = itpl('$head("Class Docstring:")\n$indent(ds)\n'
249 270 '$head("Calling Docstring:")\n$indent(call_ds)')
250 271 else:
251 272 output = ds
252 273 else:
253 274 output = ds
254 275 if output is None:
255 276 self.noinfo('documentation',oname)
256 277 return
257 278 page(output)
258 279
259 280 def psource(self,obj,oname=''):
260 281 """Print the source code for an object."""
261 282
262 283 # Flush the source cache because inspect can return out-of-date source
263 284 linecache.checkcache()
264 285 try:
265 src = inspect.getsource(obj)
286 src = getsource(obj)
266 287 except:
267 288 self.noinfo('source',oname)
268 289 else:
269 290 page(self.format(src))
270 291
271 292 def pfile(self,obj,oname=''):
272 293 """Show the whole file where an object was defined."""
273 294 try:
274 295 sourcelines,lineno = inspect.getsourcelines(obj)
275 296 except:
276 297 self.noinfo('file',oname)
277 298 else:
278 299 # run contents of file through pager starting at line
279 300 # where the object is defined
280 301 ofile = inspect.getabsfile(obj)
281 302
282 303 if (ofile.endswith('.so') or ofile.endswith('.dll')):
283 304 print 'File %r is binary, not printing.' % ofile
284 305 elif not os.path.isfile(ofile):
285 306 print 'File %r does not exist, not printing.' % ofile
286 307 else:
287 308 # Print only text files, not extension binaries.
288 309 page(self.format(open(ofile).read()),lineno)
289 310 #page(self.format(open(inspect.getabsfile(obj)).read()),lineno)
290 311
291 312 def pinfo(self,obj,oname='',formatter=None,info=None,detail_level=0):
292 313 """Show detailed information about an object.
293 314
294 315 Optional arguments:
295 316
296 317 - oname: name of the variable pointing to the object.
297 318
298 319 - formatter: special formatter for docstrings (see pdoc)
299 320
300 321 - info: a structure with some information fields which may have been
301 322 precomputed already.
302 323
303 324 - detail_level: if set to 1, more information is given.
304 325 """
305 326
306 327 obj_type = type(obj)
307 328
308 329 header = self.__head
309 330 if info is None:
310 331 ismagic = 0
311 332 isalias = 0
312 333 ospace = ''
313 334 else:
314 335 ismagic = info.ismagic
315 336 isalias = info.isalias
316 337 ospace = info.namespace
317 338 # Get docstring, special-casing aliases:
318 339 if isalias:
319 340 ds = "Alias to the system command:\n %s" % obj[1]
320 341 else:
321 342 ds = getdoc(obj)
322 343 if ds is None:
323 344 ds = '<no docstring>'
324 345 if formatter is not None:
325 346 ds = formatter(ds)
326 347
327 348 # store output in a list which gets joined with \n at the end.
328 349 out = myStringIO()
329 350
330 351 string_max = 200 # max size of strings to show (snipped if longer)
331 352 shalf = int((string_max -5)/2)
332 353
333 354 if ismagic:
334 355 obj_type_name = 'Magic function'
335 356 elif isalias:
336 357 obj_type_name = 'System alias'
337 358 else:
338 359 obj_type_name = obj_type.__name__
339 360 out.writeln(header('Type:\t\t')+obj_type_name)
340 361
341 362 try:
342 363 bclass = obj.__class__
343 364 out.writeln(header('Base Class:\t')+str(bclass))
344 365 except: pass
345 366
346 367 # String form, but snip if too long in ? form (full in ??)
347 368 if detail_level >= self.str_detail_level:
348 369 try:
349 370 ostr = str(obj)
350 371 str_head = 'String Form:'
351 372 if not detail_level and len(ostr)>string_max:
352 373 ostr = ostr[:shalf] + ' <...> ' + ostr[-shalf:]
353 374 ostr = ("\n" + " " * len(str_head.expandtabs())).\
354 375 join(map(string.strip,ostr.split("\n")))
355 376 if ostr.find('\n') > -1:
356 377 # Print multi-line strings starting at the next line.
357 378 str_sep = '\n'
358 379 else:
359 380 str_sep = '\t'
360 381 out.writeln("%s%s%s" % (header(str_head),str_sep,ostr))
361 382 except:
362 383 pass
363 384
364 385 if ospace:
365 386 out.writeln(header('Namespace:\t')+ospace)
366 387
367 388 # Length (for strings and lists)
368 389 try:
369 390 length = str(len(obj))
370 391 out.writeln(header('Length:\t\t')+length)
371 392 except: pass
372 393
373 394 # Filename where object was defined
374 395 binary_file = False
375 396 try:
376 397 fname = inspect.getabsfile(obj)
377 398 if fname.endswith('<string>'):
378 399 fname = 'Dynamically generated function. No source code available.'
379 400 if (fname.endswith('.so') or fname.endswith('.dll') or
380 401 not os.path.isfile(fname)):
381 402 binary_file = True
382 403 out.writeln(header('File:\t\t')+fname)
383 404 except:
384 405 # if anything goes wrong, we don't want to show source, so it's as
385 406 # if the file was binary
386 407 binary_file = True
387 408
388 409 # reconstruct the function definition and print it:
389 410 defln = self.__getdef(obj,oname)
390 411 if defln:
391 412 out.write(header('Definition:\t')+self.format(defln))
392 413
393 414 # Docstrings only in detail 0 mode, since source contains them (we
394 415 # avoid repetitions). If source fails, we add them back, see below.
395 416 if ds and detail_level == 0:
396 417 out.writeln(header('Docstring:\n') + indent(ds))
397 418
398 419
399 420 # Original source code for any callable
400 421 if detail_level:
401 422 # Flush the source cache because inspect can return out-of-date source
402 423 linecache.checkcache()
403 424 source_success = False
404 425 try:
405 if not binary_file:
406 source = self.format(inspect.getsource(obj))
426 source = self.format(getsource(obj,binary_file))
427 if source:
407 428 out.write(header('Source:\n')+source.rstrip())
408 429 source_success = True
409 except:
430 except Exception, msg:
410 431 pass
411 432
412 433 if ds and not source_success:
413 out.writeln(header('Docstring [source file open failed]:\n') + indent(ds))
434 out.writeln(header('Docstring [source file open failed]:\n')
435 + indent(ds))
414 436
415 437 # Constructor docstring for classes
416 438 if obj_type is types.ClassType:
417 439 # reconstruct the function definition and print it:
418 440 try:
419 441 obj_init = obj.__init__
420 442 except AttributeError:
421 443 init_def = init_ds = None
422 444 else:
423 445 init_def = self.__getdef(obj_init,oname)
424 446 init_ds = getdoc(obj_init)
425 447
426 448 if init_def or init_ds:
427 449 out.writeln(header('\nConstructor information:'))
428 450 if init_def:
429 451 out.write(header('Definition:\t')+ self.format(init_def))
430 452 if init_ds:
431 453 out.writeln(header('Docstring:\n') + indent(init_ds))
432 454 # and class docstring for instances:
433 455 elif obj_type is types.InstanceType:
434 456
435 457 # First, check whether the instance docstring is identical to the
436 458 # class one, and print it separately if they don't coincide. In
437 459 # most cases they will, but it's nice to print all the info for
438 460 # objects which use instance-customized docstrings.
439 461 if ds:
440 462 class_ds = getdoc(obj.__class__)
441 463 if class_ds and ds != class_ds:
442 464 out.writeln(header('Class Docstring:\n') +
443 465 indent(class_ds))
444 466
445 467 # Next, try to show constructor docstrings
446 468 try:
447 469 init_ds = getdoc(obj.__init__)
448 470 except AttributeError:
449 471 init_ds = None
450 472 if init_ds:
451 473 out.writeln(header('Constructor Docstring:\n') +
452 474 indent(init_ds))
453 475
454 476 # Call form docstring for callable instances
455 477 if hasattr(obj,'__call__'):
456 478 out.writeln(header('Callable:\t')+'Yes')
457 479 call_def = self.__getdef(obj.__call__,oname)
458 480 if call_def is None:
459 481 out.write(header('Call def:\t')+
460 482 'Calling definition not available.')
461 483 else:
462 484 out.write(header('Call def:\t')+self.format(call_def))
463 485 call_ds = getdoc(obj.__call__)
464 486 if call_ds:
465 487 out.writeln(header('Call docstring:\n') + indent(call_ds))
466 488
467 489 # Finally send to printer/pager
468 490 output = out.getvalue()
469 491 if output:
470 492 page(output)
471 493 # end pinfo
472 494
473 495 def psearch(self,pattern,ns_table,ns_search=[],
474 496 ignore_case=False,show_all=False):
475 497 """Search namespaces with wildcards for objects.
476 498
477 499 Arguments:
478 500
479 501 - pattern: string containing shell-like wildcards to use in namespace
480 502 searches and optionally a type specification to narrow the search to
481 503 objects of that type.
482 504
483 505 - ns_table: dict of name->namespaces for search.
484 506
485 507 Optional arguments:
486 508
487 509 - ns_search: list of namespace names to include in search.
488 510
489 511 - ignore_case(False): make the search case-insensitive.
490 512
491 513 - show_all(False): show all names, including those starting with
492 514 underscores.
493 515 """
494 516 # defaults
495 517 type_pattern = 'all'
496 518 filter = ''
497 519
498 520 cmds = pattern.split()
499 521 len_cmds = len(cmds)
500 522 if len_cmds == 1:
501 523 # Only filter pattern given
502 524 filter = cmds[0]
503 525 elif len_cmds == 2:
504 526 # Both filter and type specified
505 527 filter,type_pattern = cmds
506 528 else:
507 529 raise ValueError('invalid argument string for psearch: <%s>' %
508 530 pattern)
509 531
510 532 # filter search namespaces
511 533 for name in ns_search:
512 534 if name not in ns_table:
513 535 raise ValueError('invalid namespace <%s>. Valid names: %s' %
514 536 (name,ns_table.keys()))
515 537
516 538 #print 'type_pattern:',type_pattern # dbg
517 539 search_result = []
518 540 for ns_name in ns_search:
519 541 ns = ns_table[ns_name]
520 542 tmp_res = list(list_namespace(ns,type_pattern,filter,
521 543 ignore_case=ignore_case,
522 544 show_all=show_all))
523 545 search_result.extend(tmp_res)
524 546 search_result.sort()
525 547
526 548 page('\n'.join(search_result))
@@ -1,588 +1,588 b''
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 Classes for handling input/output prompts.
4 4
5 $Id: Prompts.py 1366 2006-06-15 19:45:50Z vivainio $"""
5 $Id: Prompts.py 1850 2006-10-28 19:48:13Z fptest $"""
6 6
7 7 #*****************************************************************************
8 8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
9 9 #
10 10 # Distributed under the terms of the BSD License. The full license is in
11 11 # the file COPYING, distributed as part of this software.
12 12 #*****************************************************************************
13 13
14 14 from IPython import Release
15 15 __author__ = '%s <%s>' % Release.authors['Fernando']
16 16 __license__ = Release.license
17 17 __version__ = Release.version
18 18
19 19 #****************************************************************************
20 20 # Required modules
21 21 import __builtin__
22 22 import os
23 23 import socket
24 24 import sys
25 25 import time
26 26
27 27 # IPython's own
28 28 from IPython import ColorANSI
29 29 from IPython.Itpl import ItplNS
30 30 from IPython.ipstruct import Struct
31 31 from IPython.macro import Macro
32 32 from IPython.genutils import *
33 33
34 34 #****************************************************************************
35 35 #Color schemes for Prompts.
36 36
37 37 PromptColors = ColorANSI.ColorSchemeTable()
38 38 InputColors = ColorANSI.InputTermColors # just a shorthand
39 39 Colors = ColorANSI.TermColors # just a shorthand
40 40
41 41 PromptColors.add_scheme(ColorANSI.ColorScheme(
42 42 'NoColor',
43 43 in_prompt = InputColors.NoColor, # Input prompt
44 44 in_number = InputColors.NoColor, # Input prompt number
45 45 in_prompt2 = InputColors.NoColor, # Continuation prompt
46 46 in_normal = InputColors.NoColor, # color off (usu. Colors.Normal)
47 47
48 48 out_prompt = Colors.NoColor, # Output prompt
49 49 out_number = Colors.NoColor, # Output prompt number
50 50
51 51 normal = Colors.NoColor # color off (usu. Colors.Normal)
52 52 ))
53 53
54 54 # make some schemes as instances so we can copy them for modification easily:
55 55 __PColLinux = ColorANSI.ColorScheme(
56 56 'Linux',
57 57 in_prompt = InputColors.Green,
58 58 in_number = InputColors.LightGreen,
59 59 in_prompt2 = InputColors.Green,
60 60 in_normal = InputColors.Normal, # color off (usu. Colors.Normal)
61 61
62 62 out_prompt = Colors.Red,
63 63 out_number = Colors.LightRed,
64 64
65 65 normal = Colors.Normal
66 66 )
67 67 # Don't forget to enter it into the table!
68 68 PromptColors.add_scheme(__PColLinux)
69 69
70 70 # Slightly modified Linux for light backgrounds
71 71 __PColLightBG = __PColLinux.copy('LightBG')
72 72
73 73 __PColLightBG.colors.update(
74 74 in_prompt = InputColors.Blue,
75 75 in_number = InputColors.LightBlue,
76 76 in_prompt2 = InputColors.Blue
77 77 )
78 78 PromptColors.add_scheme(__PColLightBG)
79 79
80 80 del Colors,InputColors
81 81
82 82 #-----------------------------------------------------------------------------
83 83 def multiple_replace(dict, text):
84 84 """ Replace in 'text' all occurences of any key in the given
85 85 dictionary by its corresponding value. Returns the new string."""
86 86
87 87 # Function by Xavier Defrang, originally found at:
88 88 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81330
89 89
90 90 # Create a regular expression from the dictionary keys
91 91 regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys())))
92 92 # For each match, look-up corresponding value in dictionary
93 93 return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)
94 94
95 95 #-----------------------------------------------------------------------------
96 96 # Special characters that can be used in prompt templates, mainly bash-like
97 97
98 98 # If $HOME isn't defined (Windows), make it an absurd string so that it can
99 99 # never be expanded out into '~'. Basically anything which can never be a
100 100 # reasonable directory name will do, we just want the $HOME -> '~' operation
101 101 # to become a no-op. We pre-compute $HOME here so it's not done on every
102 102 # prompt call.
103 103
104 104 # FIXME:
105 105
106 106 # - This should be turned into a class which does proper namespace management,
107 107 # since the prompt specials need to be evaluated in a certain namespace.
108 108 # Currently it's just globals, which need to be managed manually by code
109 109 # below.
110 110
111 111 # - I also need to split up the color schemes from the prompt specials
112 112 # somehow. I don't have a clean design for that quite yet.
113 113
114 114 HOME = os.environ.get("HOME","//////:::::ZZZZZ,,,~~~")
115 115
116 116 # We precompute a few more strings here for the prompt_specials, which are
117 117 # fixed once ipython starts. This reduces the runtime overhead of computing
118 118 # prompt strings.
119 119 USER = os.environ.get("USER")
120 120 HOSTNAME = socket.gethostname()
121 121 HOSTNAME_SHORT = HOSTNAME.split(".")[0]
122 122 ROOT_SYMBOL = "$#"[os.name=='nt' or os.getuid()==0]
123 123
124 124 prompt_specials_color = {
125 125 # Prompt/history count
126 126 '%n' : '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
127 127 '\\#': '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
128 128 # Prompt/history count, with the actual digits replaced by dots. Used
129 129 # mainly in continuation prompts (prompt_in2)
130 130 '\\D': '${"."*len(str(self.cache.prompt_count))}',
131 131 # Current working directory
132 132 '\\w': '${os.getcwd()}',
133 133 # Current time
134 134 '\\t' : '${time.strftime("%H:%M:%S")}',
135 135 # Basename of current working directory.
136 136 # (use os.sep to make this portable across OSes)
137 137 '\\W' : '${os.getcwd().split("%s")[-1]}' % os.sep,
138 138 # These X<N> are an extension to the normal bash prompts. They return
139 139 # N terms of the path, after replacing $HOME with '~'
140 140 '\\X0': '${os.getcwd().replace("%s","~")}' % HOME,
141 141 '\\X1': '${self.cwd_filt(1)}',
142 142 '\\X2': '${self.cwd_filt(2)}',
143 143 '\\X3': '${self.cwd_filt(3)}',
144 144 '\\X4': '${self.cwd_filt(4)}',
145 145 '\\X5': '${self.cwd_filt(5)}',
146 146 # Y<N> are similar to X<N>, but they show '~' if it's the directory
147 147 # N+1 in the list. Somewhat like %cN in tcsh.
148 148 '\\Y0': '${self.cwd_filt2(0)}',
149 149 '\\Y1': '${self.cwd_filt2(1)}',
150 150 '\\Y2': '${self.cwd_filt2(2)}',
151 151 '\\Y3': '${self.cwd_filt2(3)}',
152 152 '\\Y4': '${self.cwd_filt2(4)}',
153 153 '\\Y5': '${self.cwd_filt2(5)}',
154 154 # Hostname up to first .
155 155 '\\h': HOSTNAME_SHORT,
156 156 # Full hostname
157 157 '\\H': HOSTNAME,
158 158 # Username of current user
159 159 '\\u': USER,
160 160 # Escaped '\'
161 161 '\\\\': '\\',
162 162 # Newline
163 163 '\\n': '\n',
164 164 # Carriage return
165 165 '\\r': '\r',
166 166 # Release version
167 167 '\\v': __version__,
168 168 # Root symbol ($ or #)
169 169 '\\$': ROOT_SYMBOL,
170 170 }
171 171
172 172 # A copy of the prompt_specials dictionary but with all color escapes removed,
173 173 # so we can correctly compute the prompt length for the auto_rewrite method.
174 174 prompt_specials_nocolor = prompt_specials_color.copy()
175 175 prompt_specials_nocolor['%n'] = '${self.cache.prompt_count}'
176 176 prompt_specials_nocolor['\\#'] = '${self.cache.prompt_count}'
177 177
178 178 # Add in all the InputTermColors color escapes as valid prompt characters.
179 179 # They all get added as \\C_COLORNAME, so that we don't have any conflicts
180 180 # with a color name which may begin with a letter used by any other of the
181 181 # allowed specials. This of course means that \\C will never be allowed for
182 182 # anything else.
183 183 input_colors = ColorANSI.InputTermColors
184 184 for _color in dir(input_colors):
185 185 if _color[0] != '_':
186 186 c_name = '\\C_'+_color
187 187 prompt_specials_color[c_name] = getattr(input_colors,_color)
188 188 prompt_specials_nocolor[c_name] = ''
189 189
190 190 # we default to no color for safety. Note that prompt_specials is a global
191 191 # variable used by all prompt objects.
192 192 prompt_specials = prompt_specials_nocolor
193 193
194 194 #-----------------------------------------------------------------------------
195 195 def str_safe(arg):
196 196 """Convert to a string, without ever raising an exception.
197 197
198 198 If str(arg) fails, <ERROR: ... > is returned, where ... is the exception
199 199 error message."""
200 200
201 201 try:
202 202 out = str(arg)
203 203 except UnicodeError:
204 204 try:
205 205 out = arg.encode('utf_8','replace')
206 206 except Exception,msg:
207 207 # let's keep this little duplication here, so that the most common
208 208 # case doesn't suffer from a double try wrapping.
209 209 out = '<ERROR: %s>' % msg
210 210 except Exception,msg:
211 211 out = '<ERROR: %s>' % msg
212 212 return out
213 213
214 214 class BasePrompt:
215 215 """Interactive prompt similar to Mathematica's."""
216 216 def __init__(self,cache,sep,prompt,pad_left=False):
217 217
218 218 # Hack: we access information about the primary prompt through the
219 219 # cache argument. We need this, because we want the secondary prompt
220 220 # to be aligned with the primary one. Color table info is also shared
221 221 # by all prompt classes through the cache. Nice OO spaghetti code!
222 222 self.cache = cache
223 223 self.sep = sep
224 224
225 225 # regexp to count the number of spaces at the end of a prompt
226 226 # expression, useful for prompt auto-rewriting
227 227 self.rspace = re.compile(r'(\s*)$')
228 228 # Flag to left-pad prompt strings to match the length of the primary
229 229 # prompt
230 230 self.pad_left = pad_left
231 231 # Set template to create each actual prompt (where numbers change)
232 232 self.p_template = prompt
233 233 self.set_p_str()
234 234
235 235 def set_p_str(self):
236 236 """ Set the interpolating prompt strings.
237 237
238 238 This must be called every time the color settings change, because the
239 239 prompt_specials global may have changed."""
240 240
241 241 import os,time # needed in locals for prompt string handling
242 242 loc = locals()
243 243 self.p_str = ItplNS('%s%s%s' %
244 244 ('${self.sep}${self.col_p}',
245 245 multiple_replace(prompt_specials, self.p_template),
246 246 '${self.col_norm}'),self.cache.user_ns,loc)
247
247
248 248 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
249 249 self.p_template),
250 250 self.cache.user_ns,loc)
251 251
252 252 def write(self,msg): # dbg
253 253 sys.stdout.write(msg)
254 254 return ''
255 255
256 256 def __str__(self):
257 257 """Return a string form of the prompt.
258 258
259 259 This for is useful for continuation and output prompts, since it is
260 260 left-padded to match lengths with the primary one (if the
261 261 self.pad_left attribute is set)."""
262 262
263 263 out_str = str_safe(self.p_str)
264 264 if self.pad_left:
265 265 # We must find the amount of padding required to match lengths,
266 266 # taking the color escapes (which are invisible on-screen) into
267 267 # account.
268 268 esc_pad = len(out_str) - len(str_safe(self.p_str_nocolor))
269 269 format = '%%%ss' % (len(str(self.cache.last_prompt))+esc_pad)
270 270 return format % out_str
271 271 else:
272 272 return out_str
273 273
274 274 # these path filters are put in as methods so that we can control the
275 275 # namespace where the prompt strings get evaluated
276 276 def cwd_filt(self,depth):
277 277 """Return the last depth elements of the current working directory.
278 278
279 279 $HOME is always replaced with '~'.
280 280 If depth==0, the full path is returned."""
281 281
282 282 cwd = os.getcwd().replace(HOME,"~")
283 283 out = os.sep.join(cwd.split(os.sep)[-depth:])
284 284 if out:
285 285 return out
286 286 else:
287 287 return os.sep
288 288
289 289 def cwd_filt2(self,depth):
290 290 """Return the last depth elements of the current working directory.
291 291
292 292 $HOME is always replaced with '~'.
293 293 If depth==0, the full path is returned."""
294 294
295 295 cwd = os.getcwd().replace(HOME,"~").split(os.sep)
296 296 if '~' in cwd and len(cwd) == depth+1:
297 297 depth += 1
298 298 out = os.sep.join(cwd[-depth:])
299 299 if out:
300 300 return out
301 301 else:
302 302 return os.sep
303 303
304 304 class Prompt1(BasePrompt):
305 305 """Input interactive prompt similar to Mathematica's."""
306 306
307 307 def __init__(self,cache,sep='\n',prompt='In [\\#]: ',pad_left=True):
308 308 BasePrompt.__init__(self,cache,sep,prompt,pad_left)
309 309
310 310 def set_colors(self):
311 311 self.set_p_str()
312 312 Colors = self.cache.color_table.active_colors # shorthand
313 313 self.col_p = Colors.in_prompt
314 314 self.col_num = Colors.in_number
315 315 self.col_norm = Colors.in_normal
316 316 # We need a non-input version of these escapes for the '--->'
317 317 # auto-call prompts used in the auto_rewrite() method.
318 318 self.col_p_ni = self.col_p.replace('\001','').replace('\002','')
319 319 self.col_norm_ni = Colors.normal
320 320
321 321 def __str__(self):
322 322 self.cache.prompt_count += 1
323 323 self.cache.last_prompt = str_safe(self.p_str_nocolor).split('\n')[-1]
324 324 return str_safe(self.p_str)
325 325
326 326 def auto_rewrite(self):
327 327 """Print a string of the form '--->' which lines up with the previous
328 328 input string. Useful for systems which re-write the user input when
329 329 handling automatically special syntaxes."""
330 330
331 331 curr = str(self.cache.last_prompt)
332 332 nrspaces = len(self.rspace.search(curr).group())
333 333 return '%s%s>%s%s' % (self.col_p_ni,'-'*(len(curr)-nrspaces-1),
334 334 ' '*nrspaces,self.col_norm_ni)
335 335
336 336 class PromptOut(BasePrompt):
337 337 """Output interactive prompt similar to Mathematica's."""
338 338
339 339 def __init__(self,cache,sep='',prompt='Out[\\#]: ',pad_left=True):
340 340 BasePrompt.__init__(self,cache,sep,prompt,pad_left)
341 341 if not self.p_template:
342 342 self.__str__ = lambda: ''
343 343
344 344 def set_colors(self):
345 345 self.set_p_str()
346 346 Colors = self.cache.color_table.active_colors # shorthand
347 347 self.col_p = Colors.out_prompt
348 348 self.col_num = Colors.out_number
349 349 self.col_norm = Colors.normal
350 350
351 351 class Prompt2(BasePrompt):
352 352 """Interactive continuation prompt."""
353 353
354 354 def __init__(self,cache,prompt=' .\\D.: ',pad_left=True):
355 355 self.cache = cache
356 356 self.p_template = prompt
357 357 self.pad_left = pad_left
358 358 self.set_p_str()
359 359
360 360 def set_p_str(self):
361 361 import os,time # needed in locals for prompt string handling
362 362 loc = locals()
363 363 self.p_str = ItplNS('%s%s%s' %
364 364 ('${self.col_p2}',
365 365 multiple_replace(prompt_specials, self.p_template),
366 366 '$self.col_norm'),
367 367 self.cache.user_ns,loc)
368 368 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
369 369 self.p_template),
370 370 self.cache.user_ns,loc)
371 371
372 372 def set_colors(self):
373 373 self.set_p_str()
374 374 Colors = self.cache.color_table.active_colors
375 375 self.col_p2 = Colors.in_prompt2
376 376 self.col_norm = Colors.in_normal
377 377 # FIXME (2004-06-16) HACK: prevent crashes for users who haven't
378 378 # updated their prompt_in2 definitions. Remove eventually.
379 379 self.col_p = Colors.out_prompt
380 380 self.col_num = Colors.out_number
381 381
382 382
383 383 #-----------------------------------------------------------------------------
384 384 class CachedOutput:
385 385 """Class for printing output from calculations while keeping a cache of
386 386 reults. It dynamically creates global variables prefixed with _ which
387 387 contain these results.
388 388
389 389 Meant to be used as a sys.displayhook replacement, providing numbered
390 390 prompts and cache services.
391 391
392 392 Initialize with initial and final values for cache counter (this defines
393 393 the maximum size of the cache."""
394 394
395 395 def __init__(self,shell,cache_size,Pprint,
396 396 colors='NoColor',input_sep='\n',
397 397 output_sep='\n',output_sep2='',
398 398 ps1 = None, ps2 = None,ps_out = None,pad_left=True):
399 399
400 400 cache_size_min = 3
401 401 if cache_size <= 0:
402 402 self.do_full_cache = 0
403 403 cache_size = 0
404 404 elif cache_size < cache_size_min:
405 405 self.do_full_cache = 0
406 406 cache_size = 0
407 407 warn('caching was disabled (min value for cache size is %s).' %
408 408 cache_size_min,level=3)
409 409 else:
410 410 self.do_full_cache = 1
411 411
412 412 self.cache_size = cache_size
413 413 self.input_sep = input_sep
414 414
415 415 # we need a reference to the user-level namespace
416 416 self.shell = shell
417 417 self.user_ns = shell.user_ns
418 418 # and to the user's input
419 419 self.input_hist = shell.input_hist
420 420 # and to the user's logger, for logging output
421 421 self.logger = shell.logger
422 422
423 423 # Set input prompt strings and colors
424 424 if cache_size == 0:
425 425 if ps1.find('%n') > -1 or ps1.find('\\#') > -1: ps1 = '>>> '
426 426 if ps2.find('%n') > -1 or ps2.find('\\#') > -1: ps2 = '... '
427 427 self.ps1_str = self._set_prompt_str(ps1,'In [\\#]: ','>>> ')
428 428 self.ps2_str = self._set_prompt_str(ps2,' .\\D.: ','... ')
429 429 self.ps_out_str = self._set_prompt_str(ps_out,'Out[\\#]: ','')
430 430
431 431 self.color_table = PromptColors
432 432 self.prompt1 = Prompt1(self,sep=input_sep,prompt=self.ps1_str,
433 433 pad_left=pad_left)
434 434 self.prompt2 = Prompt2(self,prompt=self.ps2_str,pad_left=pad_left)
435 435 self.prompt_out = PromptOut(self,sep='',prompt=self.ps_out_str,
436 436 pad_left=pad_left)
437 437 self.set_colors(colors)
438 438
439 439 # other more normal stuff
440 440 # b/c each call to the In[] prompt raises it by 1, even the first.
441 441 self.prompt_count = 0
442 442 # Store the last prompt string each time, we need it for aligning
443 443 # continuation and auto-rewrite prompts
444 444 self.last_prompt = ''
445 445 self.Pprint = Pprint
446 446 self.output_sep = output_sep
447 447 self.output_sep2 = output_sep2
448 448 self._,self.__,self.___ = '','',''
449 449 self.pprint_types = map(type,[(),[],{}])
450 450
451 451 # these are deliberately global:
452 452 to_user_ns = {'_':self._,'__':self.__,'___':self.___}
453 453 self.user_ns.update(to_user_ns)
454 454
455 455 def _set_prompt_str(self,p_str,cache_def,no_cache_def):
456 456 if p_str is None:
457 457 if self.do_full_cache:
458 458 return cache_def
459 459 else:
460 460 return no_cache_def
461 461 else:
462 462 return p_str
463 463
464 464 def set_colors(self,colors):
465 465 """Set the active color scheme and configure colors for the three
466 466 prompt subsystems."""
467 467
468 468 # FIXME: the prompt_specials global should be gobbled inside this
469 469 # class instead. Do it when cleaning up the whole 3-prompt system.
470 470 global prompt_specials
471 471 if colors.lower()=='nocolor':
472 472 prompt_specials = prompt_specials_nocolor
473 473 else:
474 474 prompt_specials = prompt_specials_color
475 475
476 476 self.color_table.set_active_scheme(colors)
477 477 self.prompt1.set_colors()
478 478 self.prompt2.set_colors()
479 479 self.prompt_out.set_colors()
480 480
481 481 def __call__(self,arg=None):
482 482 """Printing with history cache management.
483 483
484 484 This is invoked everytime the interpreter needs to print, and is
485 485 activated by setting the variable sys.displayhook to it."""
486 486
487 487 # If something injected a '_' variable in __builtin__, delete
488 488 # ipython's automatic one so we don't clobber that. gettext() in
489 489 # particular uses _, so we need to stay away from it.
490 490 if '_' in __builtin__.__dict__:
491 491 try:
492 492 del self.user_ns['_']
493 493 except KeyError:
494 494 pass
495 495 if arg is not None:
496 496 cout_write = Term.cout.write # fast lookup
497 497 # first handle the cache and counters
498 498
499 499 # do not print output if input ends in ';'
500 500 if self.input_hist[self.prompt_count].endswith(';\n'):
501 501 return
502 502 # don't use print, puts an extra space
503 503 cout_write(self.output_sep)
504 504 outprompt = self.shell.hooks.generate_output_prompt()
505 505 if self.do_full_cache:
506 506 cout_write(outprompt)
507 507
508 508 if isinstance(arg,Macro):
509 509 print 'Executing Macro...'
510 510 # in case the macro takes a long time to execute
511 511 Term.cout.flush()
512 512 self.shell.runlines(arg.value)
513 513 return None
514 514
515 515 # and now call a possibly user-defined print mechanism
516 516 manipulated_val = self.display(arg)
517 517
518 518 # user display hooks can change the variable to be stored in
519 519 # output history
520 520
521 521 if manipulated_val is not None:
522 522 arg = manipulated_val
523 523
524 524 # avoid recursive reference when displaying _oh/Out
525 525 if arg is not self.user_ns['_oh']:
526 526 self.update(arg)
527 527
528 528 if self.logger.log_output:
529 529 self.logger.log_write(repr(arg),'output')
530 530 cout_write(self.output_sep2)
531 531 Term.cout.flush()
532 532
533 533 def _display(self,arg):
534 534 """Default printer method, uses pprint.
535 535
536 536 Do ip.set_hook("result_display", my_displayhook) for custom result
537 537 display, e.g. when your own objects need special formatting.
538 538 """
539 539
540 540 return self.shell.hooks.result_display(arg)
541 541
542 542 # Assign the default display method:
543 543 display = _display
544 544
545 545 def update(self,arg):
546 546 #print '***cache_count', self.cache_count # dbg
547 547 if len(self.user_ns['_oh']) >= self.cache_size and self.do_full_cache:
548 548 warn('Output cache limit (currently '+
549 549 `self.cache_size`+' entries) hit.\n'
550 550 'Flushing cache and resetting history counter...\n'
551 551 'The only history variables available will be _,__,___ and _1\n'
552 552 'with the current result.')
553 553
554 554 self.flush()
555 555 # Don't overwrite '_' and friends if '_' is in __builtin__ (otherwise
556 556 # we cause buggy behavior for things like gettext).
557 557 if '_' not in __builtin__.__dict__:
558 558 self.___ = self.__
559 559 self.__ = self._
560 560 self._ = arg
561 561 self.user_ns.update({'_':self._,'__':self.__,'___':self.___})
562 562
563 563 # hackish access to top-level namespace to create _1,_2... dynamically
564 564 to_main = {}
565 565 if self.do_full_cache:
566 566 new_result = '_'+`self.prompt_count`
567 567 to_main[new_result] = arg
568 568 self.user_ns.update(to_main)
569 569 self.user_ns['_oh'][self.prompt_count] = arg
570 570
571 571 def flush(self):
572 572 if not self.do_full_cache:
573 573 raise ValueError,"You shouldn't have reached the cache flush "\
574 574 "if full caching is not enabled!"
575 575 # delete auto-generated vars from global namespace
576 576
577 577 for n in range(1,self.prompt_count + 1):
578 578 key = '_'+`n`
579 579 try:
580 580 del self.user_ns[key]
581 581 except: pass
582 582 self.user_ns['_oh'].clear()
583 583
584 584 if '_' not in __builtin__.__dict__:
585 585 self.user_ns.update({'_':None,'__':None, '___':None})
586 586 import gc
587 587 gc.collect() # xxx needed?
588 588
@@ -1,2432 +1,2434 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 1828 2006-10-16 02:04:33Z fptest $
9 $Id: iplib.py 1850 2006-10-28 19:48:13Z fptest $
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 pdb
51 51 import pydoc
52 52 import re
53 53 import shutil
54 54 import string
55 55 import sys
56 56 import tempfile
57 57 import traceback
58 58 import types
59 59 import pickleshare
60 60 from sets import Set
61 61 from pprint import pprint, pformat
62 62
63 63 # IPython's own modules
64 64 import IPython
65 65 from IPython import OInspect,PyColorize,ultraTB
66 66 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
67 67 from IPython.FakeModule import FakeModule
68 68 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
69 69 from IPython.Logger import Logger
70 70 from IPython.Magic import Magic
71 71 from IPython.Prompts import CachedOutput
72 72 from IPython.ipstruct import Struct
73 73 from IPython.background_jobs import BackgroundJobManager
74 74 from IPython.usage import cmd_line_usage,interactive_usage
75 75 from IPython.genutils import *
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 # Set all default hooks, defined in the IPython.hooks module.
409 409 hooks = IPython.hooks
410 410 for hook_name in hooks.__all__:
411 411 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
412 412 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
413 413 #print "bound hook",hook_name
414 414
415 415 # Flag to mark unconditional exit
416 416 self.exit_now = False
417 417
418 418 self.usage_min = """\
419 419 An enhanced console for Python.
420 420 Some of its features are:
421 421 - Readline support if the readline library is present.
422 422 - Tab completion in the local namespace.
423 423 - Logging of input, see command-line options.
424 424 - System shell escape via ! , eg !ls.
425 425 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
426 426 - Keeps track of locally defined variables via %who, %whos.
427 427 - Show object information with a ? eg ?x or x? (use ?? for more info).
428 428 """
429 429 if usage: self.usage = usage
430 430 else: self.usage = self.usage_min
431 431
432 432 # Storage
433 433 self.rc = rc # This will hold all configuration information
434 434 self.pager = 'less'
435 435 # temporary files used for various purposes. Deleted at exit.
436 436 self.tempfiles = []
437 437
438 438 # Keep track of readline usage (later set by init_readline)
439 439 self.has_readline = False
440 440
441 441 # template for logfile headers. It gets resolved at runtime by the
442 442 # logstart method.
443 443 self.loghead_tpl = \
444 444 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
445 445 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
446 446 #log# opts = %s
447 447 #log# args = %s
448 448 #log# It is safe to make manual edits below here.
449 449 #log#-----------------------------------------------------------------------
450 450 """
451 451 # for pushd/popd management
452 452 try:
453 453 self.home_dir = get_home_dir()
454 454 except HomeDirError,msg:
455 455 fatal(msg)
456 456
457 457 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
458 458
459 459 # Functions to call the underlying shell.
460 460
461 461 # utility to expand user variables via Itpl
462 462 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
463 463 self.user_ns))
464 464 # The first is similar to os.system, but it doesn't return a value,
465 465 # and it allows interpolation of variables in the user's namespace.
466 466 self.system = lambda cmd: shell(self.var_expand(cmd),
467 467 header='IPython system call: ',
468 468 verbose=self.rc.system_verbose)
469 469 # These are for getoutput and getoutputerror:
470 470 self.getoutput = lambda cmd: \
471 471 getoutput(self.var_expand(cmd),
472 472 header='IPython system call: ',
473 473 verbose=self.rc.system_verbose)
474 474 self.getoutputerror = lambda cmd: \
475 475 getoutputerror(self.var_expand(cmd),
476 476 header='IPython system call: ',
477 477 verbose=self.rc.system_verbose)
478 478
479 479 # RegExp for splitting line contents into pre-char//first
480 480 # word-method//rest. For clarity, each group in on one line.
481 481
482 482 # WARNING: update the regexp if the above escapes are changed, as they
483 483 # are hardwired in.
484 484
485 485 # Don't get carried away with trying to make the autocalling catch too
486 486 # much: it's better to be conservative rather than to trigger hidden
487 487 # evals() somewhere and end up causing side effects.
488 488
489 489 self.line_split = re.compile(r'^([\s*,;/])'
490 490 r'([\?\w\.]+\w*\s*)'
491 491 r'(\(?.*$)')
492 492
493 493 # Original re, keep around for a while in case changes break something
494 494 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
495 495 # r'(\s*[\?\w\.]+\w*\s*)'
496 496 # r'(\(?.*$)')
497 497
498 498 # RegExp to identify potential function names
499 499 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
500 500
501 501 # RegExp to exclude strings with this start from autocalling. In
502 502 # particular, all binary operators should be excluded, so that if foo
503 503 # is callable, foo OP bar doesn't become foo(OP bar), which is
504 504 # invalid. The characters '!=()' don't need to be checked for, as the
505 505 # _prefilter routine explicitely does so, to catch direct calls and
506 506 # rebindings of existing names.
507 507
508 508 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
509 509 # it affects the rest of the group in square brackets.
510 510 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
511 511 '|^is |^not |^in |^and |^or ')
512 512
513 513 # try to catch also methods for stuff in lists/tuples/dicts: off
514 514 # (experimental). For this to work, the line_split regexp would need
515 515 # to be modified so it wouldn't break things at '['. That line is
516 516 # nasty enough that I shouldn't change it until I can test it _well_.
517 517 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
518 518
519 519 # keep track of where we started running (mainly for crash post-mortem)
520 520 self.starting_dir = os.getcwd()
521 521
522 522 # Various switches which can be set
523 523 self.CACHELENGTH = 5000 # this is cheap, it's just text
524 524 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
525 525 self.banner2 = banner2
526 526
527 527 # TraceBack handlers:
528 528
529 529 # Syntax error handler.
530 530 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
531 531
532 532 # The interactive one is initialized with an offset, meaning we always
533 533 # want to remove the topmost item in the traceback, which is our own
534 534 # internal code. Valid modes: ['Plain','Context','Verbose']
535 535 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
536 536 color_scheme='NoColor',
537 537 tb_offset = 1)
538 538
539 539 # IPython itself shouldn't crash. This will produce a detailed
540 540 # post-mortem if it does. But we only install the crash handler for
541 541 # non-threaded shells, the threaded ones use a normal verbose reporter
542 542 # and lose the crash handler. This is because exceptions in the main
543 543 # thread (such as in GUI code) propagate directly to sys.excepthook,
544 544 # and there's no point in printing crash dumps for every user exception.
545 545 if self.isthreaded:
546 546 ipCrashHandler = ultraTB.FormattedTB()
547 547 else:
548 548 from IPython import CrashHandler
549 549 ipCrashHandler = CrashHandler.IPythonCrashHandler(self)
550 550 self.set_crash_handler(ipCrashHandler)
551 551
552 552 # and add any custom exception handlers the user may have specified
553 553 self.set_custom_exc(*custom_exceptions)
554 554
555 555 # indentation management
556 556 self.autoindent = False
557 557 self.indent_current_nsp = 0
558 558
559 559 # Make some aliases automatically
560 560 # Prepare list of shell aliases to auto-define
561 561 if os.name == 'posix':
562 562 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
563 563 'mv mv -i','rm rm -i','cp cp -i',
564 564 'cat cat','less less','clear clear',
565 565 # a better ls
566 566 'ls ls -F',
567 567 # long ls
568 568 'll ls -lF')
569 569 # Extra ls aliases with color, which need special treatment on BSD
570 570 # variants
571 571 ls_extra = ( # color ls
572 572 'lc ls -F -o --color',
573 573 # ls normal files only
574 574 'lf ls -F -o --color %l | grep ^-',
575 575 # ls symbolic links
576 576 'lk ls -F -o --color %l | grep ^l',
577 577 # directories or links to directories,
578 578 'ldir ls -F -o --color %l | grep /$',
579 579 # things which are executable
580 580 'lx ls -F -o --color %l | grep ^-..x',
581 581 )
582 582 # The BSDs don't ship GNU ls, so they don't understand the
583 583 # --color switch out of the box
584 584 if 'bsd' in sys.platform:
585 585 ls_extra = ( # ls normal files only
586 586 'lf ls -lF | grep ^-',
587 587 # ls symbolic links
588 588 'lk ls -lF | grep ^l',
589 589 # directories or links to directories,
590 590 'ldir ls -lF | grep /$',
591 591 # things which are executable
592 592 'lx ls -lF | grep ^-..x',
593 593 )
594 594 auto_alias = auto_alias + ls_extra
595 595 elif os.name in ['nt','dos']:
596 596 auto_alias = ('dir dir /on', 'ls dir /on',
597 597 'ddir dir /ad /on', 'ldir dir /ad /on',
598 598 'mkdir mkdir','rmdir rmdir','echo echo',
599 599 'ren ren','cls cls','copy copy')
600 600 else:
601 601 auto_alias = ()
602 602 self.auto_alias = [s.split(None,1) for s in auto_alias]
603 603 # Call the actual (public) initializer
604 604 self.init_auto_alias()
605 605
606 606 # Produce a public API instance
607 607 self.api = IPython.ipapi.IPApi(self)
608 608
609 609 # track which builtins we add, so we can clean up later
610 610 self.builtins_added = {}
611 611 # This method will add the necessary builtins for operation, but
612 612 # tracking what it did via the builtins_added dict.
613 613 self.add_builtins()
614 614
615 615 # end __init__
616 616
617 617 def pre_config_initialization(self):
618 618 """Pre-configuration init method
619 619
620 620 This is called before the configuration files are processed to
621 621 prepare the services the config files might need.
622 622
623 623 self.rc already has reasonable default values at this point.
624 624 """
625 625 rc = self.rc
626 626
627 627 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
628 628
629 629 def post_config_initialization(self):
630 630 """Post configuration init method
631 631
632 632 This is called after the configuration files have been processed to
633 633 'finalize' the initialization."""
634 634
635 635 rc = self.rc
636 636
637 637 # Object inspector
638 638 self.inspector = OInspect.Inspector(OInspect.InspectColors,
639 639 PyColorize.ANSICodeColors,
640 640 'NoColor',
641 641 rc.object_info_string_level)
642 642
643 643 # Load readline proper
644 644 if rc.readline:
645 645 self.init_readline()
646 646
647 647 # local shortcut, this is used a LOT
648 648 self.log = self.logger.log
649 649
650 650 # Initialize cache, set in/out prompts and printing system
651 651 self.outputcache = CachedOutput(self,
652 652 rc.cache_size,
653 653 rc.pprint,
654 654 input_sep = rc.separate_in,
655 655 output_sep = rc.separate_out,
656 656 output_sep2 = rc.separate_out2,
657 657 ps1 = rc.prompt_in1,
658 658 ps2 = rc.prompt_in2,
659 659 ps_out = rc.prompt_out,
660 660 pad_left = rc.prompts_pad_left)
661 661
662 662 # user may have over-ridden the default print hook:
663 663 try:
664 664 self.outputcache.__class__.display = self.hooks.display
665 665 except AttributeError:
666 666 pass
667 667
668 # I don't like assigning globally to sys, because it means when embedding
669 # instances, each embedded instance overrides the previous choice. But
670 # sys.displayhook seems to be called internally by exec, so I don't see a
671 # way around it.
668 # I don't like assigning globally to sys, because it means when
669 # embedding instances, each embedded instance overrides the previous
670 # choice. But sys.displayhook seems to be called internally by exec,
671 # so I don't see a way around it. We first save the original and then
672 # overwrite it.
673 self.sys_displayhook = sys.displayhook
672 674 sys.displayhook = self.outputcache
673
675
674 676 # Set user colors (don't do it in the constructor above so that it
675 677 # doesn't crash if colors option is invalid)
676 678 self.magic_colors(rc.colors)
677 679
678 680 # Set calling of pdb on exceptions
679 681 self.call_pdb = rc.pdb
680 682
681 683 # Load user aliases
682 684 for alias in rc.alias:
683 685 self.magic_alias(alias)
684 686 self.hooks.late_startup_hook()
685 687
686 688 batchrun = False
687 689 for batchfile in [path(arg) for arg in self.rc.args
688 690 if arg.lower().endswith('.ipy')]:
689 691 if not batchfile.isfile():
690 692 print "No such batch file:", batchfile
691 693 continue
692 694 self.api.runlines(batchfile.text())
693 695 batchrun = True
694 696 if batchrun:
695 697 self.exit_now = True
696 698
697 699 def add_builtins(self):
698 700 """Store ipython references into the builtin namespace.
699 701
700 702 Some parts of ipython operate via builtins injected here, which hold a
701 703 reference to IPython itself."""
702 704
703 705 # TODO: deprecate all except _ip; 'jobs' should be installed
704 706 # by an extension and the rest are under _ip, ipalias is redundant
705 707 builtins_new = dict(__IPYTHON__ = self,
706 708 ip_set_hook = self.set_hook,
707 709 jobs = self.jobs,
708 710 ipmagic = self.ipmagic,
709 711 ipalias = self.ipalias,
710 712 ipsystem = self.ipsystem,
711 713 _ip = self.api
712 714 )
713 715 for biname,bival in builtins_new.items():
714 716 try:
715 717 # store the orignal value so we can restore it
716 718 self.builtins_added[biname] = __builtin__.__dict__[biname]
717 719 except KeyError:
718 720 # or mark that it wasn't defined, and we'll just delete it at
719 721 # cleanup
720 722 self.builtins_added[biname] = Undefined
721 723 __builtin__.__dict__[biname] = bival
722 724
723 725 # Keep in the builtins a flag for when IPython is active. We set it
724 726 # with setdefault so that multiple nested IPythons don't clobber one
725 727 # another. Each will increase its value by one upon being activated,
726 728 # which also gives us a way to determine the nesting level.
727 729 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
728 730
729 731 def clean_builtins(self):
730 732 """Remove any builtins which might have been added by add_builtins, or
731 733 restore overwritten ones to their previous values."""
732 734 for biname,bival in self.builtins_added.items():
733 735 if bival is Undefined:
734 736 del __builtin__.__dict__[biname]
735 737 else:
736 738 __builtin__.__dict__[biname] = bival
737 739 self.builtins_added.clear()
738 740
739 741 def set_hook(self,name,hook, priority = 50):
740 742 """set_hook(name,hook) -> sets an internal IPython hook.
741 743
742 744 IPython exposes some of its internal API as user-modifiable hooks. By
743 745 adding your function to one of these hooks, you can modify IPython's
744 746 behavior to call at runtime your own routines."""
745 747
746 748 # At some point in the future, this should validate the hook before it
747 749 # accepts it. Probably at least check that the hook takes the number
748 750 # of args it's supposed to.
749 751 dp = getattr(self.hooks, name, None)
750 752 if name not in IPython.hooks.__all__:
751 753 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
752 754 if not dp:
753 755 dp = IPython.hooks.CommandChainDispatcher()
754 756
755 757 f = new.instancemethod(hook,self,self.__class__)
756 758 try:
757 759 dp.add(f,priority)
758 760 except AttributeError:
759 761 # it was not commandchain, plain old func - replace
760 762 dp = f
761 763
762 764 setattr(self.hooks,name, dp)
763 765
764 766
765 767 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
766 768
767 769 def set_crash_handler(self,crashHandler):
768 770 """Set the IPython crash handler.
769 771
770 772 This must be a callable with a signature suitable for use as
771 773 sys.excepthook."""
772 774
773 775 # Install the given crash handler as the Python exception hook
774 776 sys.excepthook = crashHandler
775 777
776 778 # The instance will store a pointer to this, so that runtime code
777 779 # (such as magics) can access it. This is because during the
778 780 # read-eval loop, it gets temporarily overwritten (to deal with GUI
779 781 # frameworks).
780 782 self.sys_excepthook = sys.excepthook
781 783
782 784
783 785 def set_custom_exc(self,exc_tuple,handler):
784 786 """set_custom_exc(exc_tuple,handler)
785 787
786 788 Set a custom exception handler, which will be called if any of the
787 789 exceptions in exc_tuple occur in the mainloop (specifically, in the
788 790 runcode() method.
789 791
790 792 Inputs:
791 793
792 794 - exc_tuple: a *tuple* of valid exceptions to call the defined
793 795 handler for. It is very important that you use a tuple, and NOT A
794 796 LIST here, because of the way Python's except statement works. If
795 797 you only want to trap a single exception, use a singleton tuple:
796 798
797 799 exc_tuple == (MyCustomException,)
798 800
799 801 - handler: this must be defined as a function with the following
800 802 basic interface: def my_handler(self,etype,value,tb).
801 803
802 804 This will be made into an instance method (via new.instancemethod)
803 805 of IPython itself, and it will be called if any of the exceptions
804 806 listed in the exc_tuple are caught. If the handler is None, an
805 807 internal basic one is used, which just prints basic info.
806 808
807 809 WARNING: by putting in your own exception handler into IPython's main
808 810 execution loop, you run a very good chance of nasty crashes. This
809 811 facility should only be used if you really know what you are doing."""
810 812
811 813 assert type(exc_tuple)==type(()) , \
812 814 "The custom exceptions must be given AS A TUPLE."
813 815
814 816 def dummy_handler(self,etype,value,tb):
815 817 print '*** Simple custom exception handler ***'
816 818 print 'Exception type :',etype
817 819 print 'Exception value:',value
818 820 print 'Traceback :',tb
819 821 print 'Source code :','\n'.join(self.buffer)
820 822
821 823 if handler is None: handler = dummy_handler
822 824
823 825 self.CustomTB = new.instancemethod(handler,self,self.__class__)
824 826 self.custom_exceptions = exc_tuple
825 827
826 828 def set_custom_completer(self,completer,pos=0):
827 829 """set_custom_completer(completer,pos=0)
828 830
829 831 Adds a new custom completer function.
830 832
831 833 The position argument (defaults to 0) is the index in the completers
832 834 list where you want the completer to be inserted."""
833 835
834 836 newcomp = new.instancemethod(completer,self.Completer,
835 837 self.Completer.__class__)
836 838 self.Completer.matchers.insert(pos,newcomp)
837 839
838 840 def _get_call_pdb(self):
839 841 return self._call_pdb
840 842
841 843 def _set_call_pdb(self,val):
842 844
843 845 if val not in (0,1,False,True):
844 846 raise ValueError,'new call_pdb value must be boolean'
845 847
846 848 # store value in instance
847 849 self._call_pdb = val
848 850
849 851 # notify the actual exception handlers
850 852 self.InteractiveTB.call_pdb = val
851 853 if self.isthreaded:
852 854 try:
853 855 self.sys_excepthook.call_pdb = val
854 856 except:
855 857 warn('Failed to activate pdb for threaded exception handler')
856 858
857 859 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
858 860 'Control auto-activation of pdb at exceptions')
859 861
860 862
861 863 # These special functions get installed in the builtin namespace, to
862 864 # provide programmatic (pure python) access to magics, aliases and system
863 865 # calls. This is important for logging, user scripting, and more.
864 866
865 867 # We are basically exposing, via normal python functions, the three
866 868 # mechanisms in which ipython offers special call modes (magics for
867 869 # internal control, aliases for direct system access via pre-selected
868 870 # names, and !cmd for calling arbitrary system commands).
869 871
870 872 def ipmagic(self,arg_s):
871 873 """Call a magic function by name.
872 874
873 875 Input: a string containing the name of the magic function to call and any
874 876 additional arguments to be passed to the magic.
875 877
876 878 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
877 879 prompt:
878 880
879 881 In[1]: %name -opt foo bar
880 882
881 883 To call a magic without arguments, simply use ipmagic('name').
882 884
883 885 This provides a proper Python function to call IPython's magics in any
884 886 valid Python code you can type at the interpreter, including loops and
885 887 compound statements. It is added by IPython to the Python builtin
886 888 namespace upon initialization."""
887 889
888 890 args = arg_s.split(' ',1)
889 891 magic_name = args[0]
890 892 magic_name = magic_name.lstrip(self.ESC_MAGIC)
891 893
892 894 try:
893 895 magic_args = args[1]
894 896 except IndexError:
895 897 magic_args = ''
896 898 fn = getattr(self,'magic_'+magic_name,None)
897 899 if fn is None:
898 900 error("Magic function `%s` not found." % magic_name)
899 901 else:
900 902 magic_args = self.var_expand(magic_args)
901 903 return fn(magic_args)
902 904
903 905 def ipalias(self,arg_s):
904 906 """Call an alias by name.
905 907
906 908 Input: a string containing the name of the alias to call and any
907 909 additional arguments to be passed to the magic.
908 910
909 911 ipalias('name -opt foo bar') is equivalent to typing at the ipython
910 912 prompt:
911 913
912 914 In[1]: name -opt foo bar
913 915
914 916 To call an alias without arguments, simply use ipalias('name').
915 917
916 918 This provides a proper Python function to call IPython's aliases in any
917 919 valid Python code you can type at the interpreter, including loops and
918 920 compound statements. It is added by IPython to the Python builtin
919 921 namespace upon initialization."""
920 922
921 923 args = arg_s.split(' ',1)
922 924 alias_name = args[0]
923 925 try:
924 926 alias_args = args[1]
925 927 except IndexError:
926 928 alias_args = ''
927 929 if alias_name in self.alias_table:
928 930 self.call_alias(alias_name,alias_args)
929 931 else:
930 932 error("Alias `%s` not found." % alias_name)
931 933
932 934 def ipsystem(self,arg_s):
933 935 """Make a system call, using IPython."""
934 936
935 937 self.system(arg_s)
936 938
937 939 def complete(self,text):
938 940 """Return a sorted list of all possible completions on text.
939 941
940 942 Inputs:
941 943
942 944 - text: a string of text to be completed on.
943 945
944 946 This is a wrapper around the completion mechanism, similar to what
945 947 readline does at the command line when the TAB key is hit. By
946 948 exposing it as a method, it can be used by other non-readline
947 949 environments (such as GUIs) for text completion.
948 950
949 951 Simple usage example:
950 952
951 953 In [1]: x = 'hello'
952 954
953 955 In [2]: __IP.complete('x.l')
954 956 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
955 957
956 958 complete = self.Completer.complete
957 959 state = 0
958 960 # use a dict so we get unique keys, since ipyhton's multiple
959 961 # completers can return duplicates.
960 962 comps = {}
961 963 while True:
962 964 newcomp = complete(text,state)
963 965 if newcomp is None:
964 966 break
965 967 comps[newcomp] = 1
966 968 state += 1
967 969 outcomps = comps.keys()
968 970 outcomps.sort()
969 971 return outcomps
970 972
971 973 def set_completer_frame(self, frame=None):
972 974 if frame:
973 975 self.Completer.namespace = frame.f_locals
974 976 self.Completer.global_namespace = frame.f_globals
975 977 else:
976 978 self.Completer.namespace = self.user_ns
977 979 self.Completer.global_namespace = self.user_global_ns
978 980
979 981 def init_auto_alias(self):
980 982 """Define some aliases automatically.
981 983
982 984 These are ALL parameter-less aliases"""
983 985
984 986 for alias,cmd in self.auto_alias:
985 987 self.alias_table[alias] = (0,cmd)
986 988
987 989 def alias_table_validate(self,verbose=0):
988 990 """Update information about the alias table.
989 991
990 992 In particular, make sure no Python keywords/builtins are in it."""
991 993
992 994 no_alias = self.no_alias
993 995 for k in self.alias_table.keys():
994 996 if k in no_alias:
995 997 del self.alias_table[k]
996 998 if verbose:
997 999 print ("Deleting alias <%s>, it's a Python "
998 1000 "keyword or builtin." % k)
999 1001
1000 1002 def set_autoindent(self,value=None):
1001 1003 """Set the autoindent flag, checking for readline support.
1002 1004
1003 1005 If called with no arguments, it acts as a toggle."""
1004 1006
1005 1007 if not self.has_readline:
1006 1008 if os.name == 'posix':
1007 1009 warn("The auto-indent feature requires the readline library")
1008 1010 self.autoindent = 0
1009 1011 return
1010 1012 if value is None:
1011 1013 self.autoindent = not self.autoindent
1012 1014 else:
1013 1015 self.autoindent = value
1014 1016
1015 1017 def rc_set_toggle(self,rc_field,value=None):
1016 1018 """Set or toggle a field in IPython's rc config. structure.
1017 1019
1018 1020 If called with no arguments, it acts as a toggle.
1019 1021
1020 1022 If called with a non-existent field, the resulting AttributeError
1021 1023 exception will propagate out."""
1022 1024
1023 1025 rc_val = getattr(self.rc,rc_field)
1024 1026 if value is None:
1025 1027 value = not rc_val
1026 1028 setattr(self.rc,rc_field,value)
1027 1029
1028 1030 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1029 1031 """Install the user configuration directory.
1030 1032
1031 1033 Can be called when running for the first time or to upgrade the user's
1032 1034 .ipython/ directory with the mode parameter. Valid modes are 'install'
1033 1035 and 'upgrade'."""
1034 1036
1035 1037 def wait():
1036 1038 try:
1037 1039 raw_input("Please press <RETURN> to start IPython.")
1038 1040 except EOFError:
1039 1041 print >> Term.cout
1040 1042 print '*'*70
1041 1043
1042 1044 cwd = os.getcwd() # remember where we started
1043 1045 glb = glob.glob
1044 1046 print '*'*70
1045 1047 if mode == 'install':
1046 1048 print \
1047 1049 """Welcome to IPython. I will try to create a personal configuration directory
1048 1050 where you can customize many aspects of IPython's functionality in:\n"""
1049 1051 else:
1050 1052 print 'I am going to upgrade your configuration in:'
1051 1053
1052 1054 print ipythondir
1053 1055
1054 1056 rcdirend = os.path.join('IPython','UserConfig')
1055 1057 cfg = lambda d: os.path.join(d,rcdirend)
1056 1058 try:
1057 1059 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1058 1060 except IOError:
1059 1061 warning = """
1060 1062 Installation error. IPython's directory was not found.
1061 1063
1062 1064 Check the following:
1063 1065
1064 1066 The ipython/IPython directory should be in a directory belonging to your
1065 1067 PYTHONPATH environment variable (that is, it should be in a directory
1066 1068 belonging to sys.path). You can copy it explicitly there or just link to it.
1067 1069
1068 1070 IPython will proceed with builtin defaults.
1069 1071 """
1070 1072 warn(warning)
1071 1073 wait()
1072 1074 return
1073 1075
1074 1076 if mode == 'install':
1075 1077 try:
1076 1078 shutil.copytree(rcdir,ipythondir)
1077 1079 os.chdir(ipythondir)
1078 1080 rc_files = glb("ipythonrc*")
1079 1081 for rc_file in rc_files:
1080 1082 os.rename(rc_file,rc_file+rc_suffix)
1081 1083 except:
1082 1084 warning = """
1083 1085
1084 1086 There was a problem with the installation:
1085 1087 %s
1086 1088 Try to correct it or contact the developers if you think it's a bug.
1087 1089 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1088 1090 warn(warning)
1089 1091 wait()
1090 1092 return
1091 1093
1092 1094 elif mode == 'upgrade':
1093 1095 try:
1094 1096 os.chdir(ipythondir)
1095 1097 except:
1096 1098 print """
1097 1099 Can not upgrade: changing to directory %s failed. Details:
1098 1100 %s
1099 1101 """ % (ipythondir,sys.exc_info()[1])
1100 1102 wait()
1101 1103 return
1102 1104 else:
1103 1105 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1104 1106 for new_full_path in sources:
1105 1107 new_filename = os.path.basename(new_full_path)
1106 1108 if new_filename.startswith('ipythonrc'):
1107 1109 new_filename = new_filename + rc_suffix
1108 1110 # The config directory should only contain files, skip any
1109 1111 # directories which may be there (like CVS)
1110 1112 if os.path.isdir(new_full_path):
1111 1113 continue
1112 1114 if os.path.exists(new_filename):
1113 1115 old_file = new_filename+'.old'
1114 1116 if os.path.exists(old_file):
1115 1117 os.remove(old_file)
1116 1118 os.rename(new_filename,old_file)
1117 1119 shutil.copy(new_full_path,new_filename)
1118 1120 else:
1119 1121 raise ValueError,'unrecognized mode for install:',`mode`
1120 1122
1121 1123 # Fix line-endings to those native to each platform in the config
1122 1124 # directory.
1123 1125 try:
1124 1126 os.chdir(ipythondir)
1125 1127 except:
1126 1128 print """
1127 1129 Problem: changing to directory %s failed.
1128 1130 Details:
1129 1131 %s
1130 1132
1131 1133 Some configuration files may have incorrect line endings. This should not
1132 1134 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1133 1135 wait()
1134 1136 else:
1135 1137 for fname in glb('ipythonrc*'):
1136 1138 try:
1137 1139 native_line_ends(fname,backup=0)
1138 1140 except IOError:
1139 1141 pass
1140 1142
1141 1143 if mode == 'install':
1142 1144 print """
1143 1145 Successful installation!
1144 1146
1145 1147 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1146 1148 IPython manual (there are both HTML and PDF versions supplied with the
1147 1149 distribution) to make sure that your system environment is properly configured
1148 1150 to take advantage of IPython's features.
1149 1151
1150 1152 Important note: the configuration system has changed! The old system is
1151 1153 still in place, but its setting may be partly overridden by the settings in
1152 1154 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1153 1155 if some of the new settings bother you.
1154 1156
1155 1157 """
1156 1158 else:
1157 1159 print """
1158 1160 Successful upgrade!
1159 1161
1160 1162 All files in your directory:
1161 1163 %(ipythondir)s
1162 1164 which would have been overwritten by the upgrade were backed up with a .old
1163 1165 extension. If you had made particular customizations in those files you may
1164 1166 want to merge them back into the new files.""" % locals()
1165 1167 wait()
1166 1168 os.chdir(cwd)
1167 1169 # end user_setup()
1168 1170
1169 1171 def atexit_operations(self):
1170 1172 """This will be executed at the time of exit.
1171 1173
1172 1174 Saving of persistent data should be performed here. """
1173 1175
1174 1176 #print '*** IPython exit cleanup ***' # dbg
1175 1177 # input history
1176 1178 self.savehist()
1177 1179
1178 1180 # Cleanup all tempfiles left around
1179 1181 for tfile in self.tempfiles:
1180 1182 try:
1181 1183 os.unlink(tfile)
1182 1184 except OSError:
1183 1185 pass
1184 1186
1185 1187 # save the "persistent data" catch-all dictionary
1186 1188 self.hooks.shutdown_hook()
1187 1189
1188 1190 def savehist(self):
1189 1191 """Save input history to a file (via readline library)."""
1190 1192 try:
1191 1193 self.readline.write_history_file(self.histfile)
1192 1194 except:
1193 1195 print 'Unable to save IPython command history to file: ' + \
1194 1196 `self.histfile`
1195 1197
1196 1198 def pre_readline(self):
1197 1199 """readline hook to be used at the start of each line.
1198 1200
1199 1201 Currently it handles auto-indent only."""
1200 1202
1201 1203 #debugx('self.indent_current_nsp','pre_readline:')
1202 1204 self.readline.insert_text(self.indent_current_str())
1203 1205
1204 1206 def init_readline(self):
1205 1207 """Command history completion/saving/reloading."""
1206 1208
1207 1209 import IPython.rlineimpl as readline
1208 1210 if not readline.have_readline:
1209 1211 self.has_readline = 0
1210 1212 self.readline = None
1211 1213 # no point in bugging windows users with this every time:
1212 1214 warn('Readline services not available on this platform.')
1213 1215 else:
1214 1216 sys.modules['readline'] = readline
1215 1217 import atexit
1216 1218 from IPython.completer import IPCompleter
1217 1219 self.Completer = IPCompleter(self,
1218 1220 self.user_ns,
1219 1221 self.user_global_ns,
1220 1222 self.rc.readline_omit__names,
1221 1223 self.alias_table)
1222 1224
1223 1225 # Platform-specific configuration
1224 1226 if os.name == 'nt':
1225 1227 self.readline_startup_hook = readline.set_pre_input_hook
1226 1228 else:
1227 1229 self.readline_startup_hook = readline.set_startup_hook
1228 1230
1229 1231 # Load user's initrc file (readline config)
1230 1232 inputrc_name = os.environ.get('INPUTRC')
1231 1233 if inputrc_name is None:
1232 1234 home_dir = get_home_dir()
1233 1235 if home_dir is not None:
1234 1236 inputrc_name = os.path.join(home_dir,'.inputrc')
1235 1237 if os.path.isfile(inputrc_name):
1236 1238 try:
1237 1239 readline.read_init_file(inputrc_name)
1238 1240 except:
1239 1241 warn('Problems reading readline initialization file <%s>'
1240 1242 % inputrc_name)
1241 1243
1242 1244 self.has_readline = 1
1243 1245 self.readline = readline
1244 1246 # save this in sys so embedded copies can restore it properly
1245 1247 sys.ipcompleter = self.Completer.complete
1246 1248 readline.set_completer(self.Completer.complete)
1247 1249
1248 1250 # Configure readline according to user's prefs
1249 1251 for rlcommand in self.rc.readline_parse_and_bind:
1250 1252 readline.parse_and_bind(rlcommand)
1251 1253
1252 1254 # remove some chars from the delimiters list
1253 1255 delims = readline.get_completer_delims()
1254 1256 delims = delims.translate(string._idmap,
1255 1257 self.rc.readline_remove_delims)
1256 1258 readline.set_completer_delims(delims)
1257 1259 # otherwise we end up with a monster history after a while:
1258 1260 readline.set_history_length(1000)
1259 1261 try:
1260 1262 #print '*** Reading readline history' # dbg
1261 1263 readline.read_history_file(self.histfile)
1262 1264 except IOError:
1263 1265 pass # It doesn't exist yet.
1264 1266
1265 1267 atexit.register(self.atexit_operations)
1266 1268 del atexit
1267 1269
1268 1270 # Configure auto-indent for all platforms
1269 1271 self.set_autoindent(self.rc.autoindent)
1270 1272
1271 1273 def ask_yes_no(self,prompt,default=True):
1272 1274 if self.rc.quiet:
1273 1275 return True
1274 1276 return ask_yes_no(prompt,default)
1275 1277
1276 1278 def _should_recompile(self,e):
1277 1279 """Utility routine for edit_syntax_error"""
1278 1280
1279 1281 if e.filename in ('<ipython console>','<input>','<string>',
1280 1282 '<console>','<BackgroundJob compilation>',
1281 1283 None):
1282 1284
1283 1285 return False
1284 1286 try:
1285 1287 if (self.rc.autoedit_syntax and
1286 1288 not self.ask_yes_no('Return to editor to correct syntax error? '
1287 1289 '[Y/n] ','y')):
1288 1290 return False
1289 1291 except EOFError:
1290 1292 return False
1291 1293
1292 1294 def int0(x):
1293 1295 try:
1294 1296 return int(x)
1295 1297 except TypeError:
1296 1298 return 0
1297 1299 # always pass integer line and offset values to editor hook
1298 1300 self.hooks.fix_error_editor(e.filename,
1299 1301 int0(e.lineno),int0(e.offset),e.msg)
1300 1302 return True
1301 1303
1302 1304 def edit_syntax_error(self):
1303 1305 """The bottom half of the syntax error handler called in the main loop.
1304 1306
1305 1307 Loop until syntax error is fixed or user cancels.
1306 1308 """
1307 1309
1308 1310 while self.SyntaxTB.last_syntax_error:
1309 1311 # copy and clear last_syntax_error
1310 1312 err = self.SyntaxTB.clear_err_state()
1311 1313 if not self._should_recompile(err):
1312 1314 return
1313 1315 try:
1314 1316 # may set last_syntax_error again if a SyntaxError is raised
1315 1317 self.safe_execfile(err.filename,self.user_ns)
1316 1318 except:
1317 1319 self.showtraceback()
1318 1320 else:
1319 1321 try:
1320 1322 f = file(err.filename)
1321 1323 try:
1322 1324 sys.displayhook(f.read())
1323 1325 finally:
1324 1326 f.close()
1325 1327 except:
1326 1328 self.showtraceback()
1327 1329
1328 1330 def showsyntaxerror(self, filename=None):
1329 1331 """Display the syntax error that just occurred.
1330 1332
1331 1333 This doesn't display a stack trace because there isn't one.
1332 1334
1333 1335 If a filename is given, it is stuffed in the exception instead
1334 1336 of what was there before (because Python's parser always uses
1335 1337 "<string>" when reading from a string).
1336 1338 """
1337 1339 etype, value, last_traceback = sys.exc_info()
1338 1340
1339 1341 # See note about these variables in showtraceback() below
1340 1342 sys.last_type = etype
1341 1343 sys.last_value = value
1342 1344 sys.last_traceback = last_traceback
1343 1345
1344 1346 if filename and etype is SyntaxError:
1345 1347 # Work hard to stuff the correct filename in the exception
1346 1348 try:
1347 1349 msg, (dummy_filename, lineno, offset, line) = value
1348 1350 except:
1349 1351 # Not the format we expect; leave it alone
1350 1352 pass
1351 1353 else:
1352 1354 # Stuff in the right filename
1353 1355 try:
1354 1356 # Assume SyntaxError is a class exception
1355 1357 value = SyntaxError(msg, (filename, lineno, offset, line))
1356 1358 except:
1357 1359 # If that failed, assume SyntaxError is a string
1358 1360 value = msg, (filename, lineno, offset, line)
1359 1361 self.SyntaxTB(etype,value,[])
1360 1362
1361 1363 def debugger(self):
1362 1364 """Call the pdb debugger."""
1363 1365
1364 1366 if not self.rc.pdb:
1365 1367 return
1366 1368 pdb.pm()
1367 1369
1368 1370 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1369 1371 """Display the exception that just occurred.
1370 1372
1371 1373 If nothing is known about the exception, this is the method which
1372 1374 should be used throughout the code for presenting user tracebacks,
1373 1375 rather than directly invoking the InteractiveTB object.
1374 1376
1375 1377 A specific showsyntaxerror() also exists, but this method can take
1376 1378 care of calling it if needed, so unless you are explicitly catching a
1377 1379 SyntaxError exception, don't try to analyze the stack manually and
1378 1380 simply call this method."""
1379 1381
1380 1382 # Though this won't be called by syntax errors in the input line,
1381 1383 # there may be SyntaxError cases whith imported code.
1382 1384 if exc_tuple is None:
1383 1385 etype, value, tb = sys.exc_info()
1384 1386 else:
1385 1387 etype, value, tb = exc_tuple
1386 1388 if etype is SyntaxError:
1387 1389 self.showsyntaxerror(filename)
1388 1390 else:
1389 1391 # WARNING: these variables are somewhat deprecated and not
1390 1392 # necessarily safe to use in a threaded environment, but tools
1391 1393 # like pdb depend on their existence, so let's set them. If we
1392 1394 # find problems in the field, we'll need to revisit their use.
1393 1395 sys.last_type = etype
1394 1396 sys.last_value = value
1395 1397 sys.last_traceback = tb
1396 1398
1397 1399 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1398 1400 if self.InteractiveTB.call_pdb and self.has_readline:
1399 1401 # pdb mucks up readline, fix it back
1400 1402 self.readline.set_completer(self.Completer.complete)
1401 1403
1402 1404 def mainloop(self,banner=None):
1403 1405 """Creates the local namespace and starts the mainloop.
1404 1406
1405 1407 If an optional banner argument is given, it will override the
1406 1408 internally created default banner."""
1407 1409
1408 1410 if self.rc.c: # Emulate Python's -c option
1409 1411 self.exec_init_cmd()
1410 1412 if banner is None:
1411 1413 if not self.rc.banner:
1412 1414 banner = ''
1413 1415 # banner is string? Use it directly!
1414 1416 elif isinstance(self.rc.banner,basestring):
1415 1417 banner = self.rc.banner
1416 1418 else:
1417 1419 banner = self.BANNER+self.banner2
1418 1420
1419 1421 self.interact(banner)
1420 1422
1421 1423 def exec_init_cmd(self):
1422 1424 """Execute a command given at the command line.
1423 1425
1424 1426 This emulates Python's -c option."""
1425 1427
1426 1428 #sys.argv = ['-c']
1427 1429 self.push(self.rc.c)
1428 1430
1429 1431 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1430 1432 """Embeds IPython into a running python program.
1431 1433
1432 1434 Input:
1433 1435
1434 1436 - header: An optional header message can be specified.
1435 1437
1436 1438 - local_ns, global_ns: working namespaces. If given as None, the
1437 1439 IPython-initialized one is updated with __main__.__dict__, so that
1438 1440 program variables become visible but user-specific configuration
1439 1441 remains possible.
1440 1442
1441 1443 - stack_depth: specifies how many levels in the stack to go to
1442 1444 looking for namespaces (when local_ns and global_ns are None). This
1443 1445 allows an intermediate caller to make sure that this function gets
1444 1446 the namespace from the intended level in the stack. By default (0)
1445 1447 it will get its locals and globals from the immediate caller.
1446 1448
1447 1449 Warning: it's possible to use this in a program which is being run by
1448 1450 IPython itself (via %run), but some funny things will happen (a few
1449 1451 globals get overwritten). In the future this will be cleaned up, as
1450 1452 there is no fundamental reason why it can't work perfectly."""
1451 1453
1452 1454 # Get locals and globals from caller
1453 1455 if local_ns is None or global_ns is None:
1454 1456 call_frame = sys._getframe(stack_depth).f_back
1455 1457
1456 1458 if local_ns is None:
1457 1459 local_ns = call_frame.f_locals
1458 1460 if global_ns is None:
1459 1461 global_ns = call_frame.f_globals
1460 1462
1461 1463 # Update namespaces and fire up interpreter
1462 1464
1463 1465 # The global one is easy, we can just throw it in
1464 1466 self.user_global_ns = global_ns
1465 1467
1466 1468 # but the user/local one is tricky: ipython needs it to store internal
1467 1469 # data, but we also need the locals. We'll copy locals in the user
1468 1470 # one, but will track what got copied so we can delete them at exit.
1469 1471 # This is so that a later embedded call doesn't see locals from a
1470 1472 # previous call (which most likely existed in a separate scope).
1471 1473 local_varnames = local_ns.keys()
1472 1474 self.user_ns.update(local_ns)
1473 1475
1474 1476 # Patch for global embedding to make sure that things don't overwrite
1475 1477 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1476 1478 # FIXME. Test this a bit more carefully (the if.. is new)
1477 1479 if local_ns is None and global_ns is None:
1478 1480 self.user_global_ns.update(__main__.__dict__)
1479 1481
1480 1482 # make sure the tab-completer has the correct frame information, so it
1481 1483 # actually completes using the frame's locals/globals
1482 1484 self.set_completer_frame()
1483 1485
1484 1486 # before activating the interactive mode, we need to make sure that
1485 1487 # all names in the builtin namespace needed by ipython point to
1486 1488 # ourselves, and not to other instances.
1487 1489 self.add_builtins()
1488 1490
1489 1491 self.interact(header)
1490 1492
1491 1493 # now, purge out the user namespace from anything we might have added
1492 1494 # from the caller's local namespace
1493 1495 delvar = self.user_ns.pop
1494 1496 for var in local_varnames:
1495 1497 delvar(var,None)
1496 1498 # and clean builtins we may have overridden
1497 1499 self.clean_builtins()
1498 1500
1499 1501 def interact(self, banner=None):
1500 1502 """Closely emulate the interactive Python console.
1501 1503
1502 1504 The optional banner argument specify the banner to print
1503 1505 before the first interaction; by default it prints a banner
1504 1506 similar to the one printed by the real Python interpreter,
1505 1507 followed by the current class name in parentheses (so as not
1506 1508 to confuse this with the real interpreter -- since it's so
1507 1509 close!).
1508 1510
1509 1511 """
1510 1512
1511 1513 if self.exit_now:
1512 1514 # batch run -> do not interact
1513 1515 return
1514 1516 cprt = 'Type "copyright", "credits" or "license" for more information.'
1515 1517 if banner is None:
1516 1518 self.write("Python %s on %s\n%s\n(%s)\n" %
1517 1519 (sys.version, sys.platform, cprt,
1518 1520 self.__class__.__name__))
1519 1521 else:
1520 1522 self.write(banner)
1521 1523
1522 1524 more = 0
1523 1525
1524 1526 # Mark activity in the builtins
1525 1527 __builtin__.__dict__['__IPYTHON__active'] += 1
1526 1528
1527 1529 # exit_now is set by a call to %Exit or %Quit
1528 1530 while not self.exit_now:
1529 1531 if more:
1530 1532 prompt = self.hooks.generate_prompt(True)
1531 1533 if self.autoindent:
1532 1534 self.readline_startup_hook(self.pre_readline)
1533 1535 else:
1534 1536 prompt = self.hooks.generate_prompt(False)
1535 1537 try:
1536 1538 line = self.raw_input(prompt,more)
1537 1539 if self.exit_now:
1538 1540 # quick exit on sys.std[in|out] close
1539 1541 break
1540 1542 if self.autoindent:
1541 1543 self.readline_startup_hook(None)
1542 1544 except KeyboardInterrupt:
1543 1545 self.write('\nKeyboardInterrupt\n')
1544 1546 self.resetbuffer()
1545 1547 # keep cache in sync with the prompt counter:
1546 1548 self.outputcache.prompt_count -= 1
1547 1549
1548 1550 if self.autoindent:
1549 1551 self.indent_current_nsp = 0
1550 1552 more = 0
1551 1553 except EOFError:
1552 1554 if self.autoindent:
1553 1555 self.readline_startup_hook(None)
1554 1556 self.write('\n')
1555 1557 self.exit()
1556 1558 except bdb.BdbQuit:
1557 1559 warn('The Python debugger has exited with a BdbQuit exception.\n'
1558 1560 'Because of how pdb handles the stack, it is impossible\n'
1559 1561 'for IPython to properly format this particular exception.\n'
1560 1562 'IPython will resume normal operation.')
1561 1563 except:
1562 1564 # exceptions here are VERY RARE, but they can be triggered
1563 1565 # asynchronously by signal handlers, for example.
1564 1566 self.showtraceback()
1565 1567 else:
1566 1568 more = self.push(line)
1567 1569 if (self.SyntaxTB.last_syntax_error and
1568 1570 self.rc.autoedit_syntax):
1569 1571 self.edit_syntax_error()
1570 1572
1571 1573 # We are off again...
1572 1574 __builtin__.__dict__['__IPYTHON__active'] -= 1
1573 1575
1574 1576 def excepthook(self, etype, value, tb):
1575 1577 """One more defense for GUI apps that call sys.excepthook.
1576 1578
1577 1579 GUI frameworks like wxPython trap exceptions and call
1578 1580 sys.excepthook themselves. I guess this is a feature that
1579 1581 enables them to keep running after exceptions that would
1580 1582 otherwise kill their mainloop. This is a bother for IPython
1581 1583 which excepts to catch all of the program exceptions with a try:
1582 1584 except: statement.
1583 1585
1584 1586 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1585 1587 any app directly invokes sys.excepthook, it will look to the user like
1586 1588 IPython crashed. In order to work around this, we can disable the
1587 1589 CrashHandler and replace it with this excepthook instead, which prints a
1588 1590 regular traceback using our InteractiveTB. In this fashion, apps which
1589 1591 call sys.excepthook will generate a regular-looking exception from
1590 1592 IPython, and the CrashHandler will only be triggered by real IPython
1591 1593 crashes.
1592 1594
1593 1595 This hook should be used sparingly, only in places which are not likely
1594 1596 to be true IPython errors.
1595 1597 """
1596 1598 self.showtraceback((etype,value,tb),tb_offset=0)
1597 1599
1598 1600 def expand_aliases(self,fn,rest):
1599 1601 """ Expand multiple levels of aliases:
1600 1602
1601 1603 if:
1602 1604
1603 1605 alias foo bar /tmp
1604 1606 alias baz foo
1605 1607
1606 1608 then:
1607 1609
1608 1610 baz huhhahhei -> bar /tmp huhhahhei
1609 1611
1610 1612 """
1611 1613 line = fn + " " + rest
1612 1614
1613 1615 done = Set()
1614 1616 while 1:
1615 1617 pre,fn,rest = self.split_user_input(line)
1616 1618 if fn in self.alias_table:
1617 1619 if fn in done:
1618 1620 warn("Cyclic alias definition, repeated '%s'" % fn)
1619 1621 return ""
1620 1622 done.add(fn)
1621 1623
1622 1624 l2 = self.transform_alias(fn,rest)
1623 1625 # dir -> dir
1624 1626 if l2 == line:
1625 1627 break
1626 1628 # ls -> ls -F should not recurse forever
1627 1629 if l2.split(None,1)[0] == line.split(None,1)[0]:
1628 1630 line = l2
1629 1631 break
1630 1632
1631 1633 line=l2
1632 1634
1633 1635
1634 1636 # print "al expand to",line #dbg
1635 1637 else:
1636 1638 break
1637 1639
1638 1640 return line
1639 1641
1640 1642 def transform_alias(self, alias,rest=''):
1641 1643 """ Transform alias to system command string.
1642 1644 """
1643 1645 nargs,cmd = self.alias_table[alias]
1644 1646 if ' ' in cmd and os.path.isfile(cmd):
1645 1647 cmd = '"%s"' % cmd
1646 1648
1647 1649 # Expand the %l special to be the user's input line
1648 1650 if cmd.find('%l') >= 0:
1649 1651 cmd = cmd.replace('%l',rest)
1650 1652 rest = ''
1651 1653 if nargs==0:
1652 1654 # Simple, argument-less aliases
1653 1655 cmd = '%s %s' % (cmd,rest)
1654 1656 else:
1655 1657 # Handle aliases with positional arguments
1656 1658 args = rest.split(None,nargs)
1657 1659 if len(args)< nargs:
1658 1660 error('Alias <%s> requires %s arguments, %s given.' %
1659 1661 (alias,nargs,len(args)))
1660 1662 return None
1661 1663 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1662 1664 # Now call the macro, evaluating in the user's namespace
1663 1665 #print 'new command: <%r>' % cmd # dbg
1664 1666 return cmd
1665 1667
1666 1668 def call_alias(self,alias,rest=''):
1667 1669 """Call an alias given its name and the rest of the line.
1668 1670
1669 1671 This is only used to provide backwards compatibility for users of
1670 1672 ipalias(), use of which is not recommended for anymore."""
1671 1673
1672 1674 # Now call the macro, evaluating in the user's namespace
1673 1675 cmd = self.transform_alias(alias, rest)
1674 1676 try:
1675 1677 self.system(cmd)
1676 1678 except:
1677 1679 self.showtraceback()
1678 1680
1679 1681 def indent_current_str(self):
1680 1682 """return the current level of indentation as a string"""
1681 1683 return self.indent_current_nsp * ' '
1682 1684
1683 1685 def autoindent_update(self,line):
1684 1686 """Keep track of the indent level."""
1685 1687
1686 1688 #debugx('line')
1687 1689 #debugx('self.indent_current_nsp')
1688 1690 if self.autoindent:
1689 1691 if line:
1690 1692 inisp = num_ini_spaces(line)
1691 1693 if inisp < self.indent_current_nsp:
1692 1694 self.indent_current_nsp = inisp
1693 1695
1694 1696 if line[-1] == ':':
1695 1697 self.indent_current_nsp += 4
1696 1698 elif dedent_re.match(line):
1697 1699 self.indent_current_nsp -= 4
1698 1700 else:
1699 1701 self.indent_current_nsp = 0
1700 1702
1701 1703 def runlines(self,lines):
1702 1704 """Run a string of one or more lines of source.
1703 1705
1704 1706 This method is capable of running a string containing multiple source
1705 1707 lines, as if they had been entered at the IPython prompt. Since it
1706 1708 exposes IPython's processing machinery, the given strings can contain
1707 1709 magic calls (%magic), special shell access (!cmd), etc."""
1708 1710
1709 1711 # We must start with a clean buffer, in case this is run from an
1710 1712 # interactive IPython session (via a magic, for example).
1711 1713 self.resetbuffer()
1712 1714 lines = lines.split('\n')
1713 1715 more = 0
1714 1716 for line in lines:
1715 1717 # skip blank lines so we don't mess up the prompt counter, but do
1716 1718 # NOT skip even a blank line if we are in a code block (more is
1717 1719 # true)
1718 1720 if line or more:
1719 1721 more = self.push(self.prefilter(line,more))
1720 1722 # IPython's runsource returns None if there was an error
1721 1723 # compiling the code. This allows us to stop processing right
1722 1724 # away, so the user gets the error message at the right place.
1723 1725 if more is None:
1724 1726 break
1725 1727 # final newline in case the input didn't have it, so that the code
1726 1728 # actually does get executed
1727 1729 if more:
1728 1730 self.push('\n')
1729 1731
1730 1732 def runsource(self, source, filename='<input>', symbol='single'):
1731 1733 """Compile and run some source in the interpreter.
1732 1734
1733 1735 Arguments are as for compile_command().
1734 1736
1735 1737 One several things can happen:
1736 1738
1737 1739 1) The input is incorrect; compile_command() raised an
1738 1740 exception (SyntaxError or OverflowError). A syntax traceback
1739 1741 will be printed by calling the showsyntaxerror() method.
1740 1742
1741 1743 2) The input is incomplete, and more input is required;
1742 1744 compile_command() returned None. Nothing happens.
1743 1745
1744 1746 3) The input is complete; compile_command() returned a code
1745 1747 object. The code is executed by calling self.runcode() (which
1746 1748 also handles run-time exceptions, except for SystemExit).
1747 1749
1748 1750 The return value is:
1749 1751
1750 1752 - True in case 2
1751 1753
1752 1754 - False in the other cases, unless an exception is raised, where
1753 1755 None is returned instead. This can be used by external callers to
1754 1756 know whether to continue feeding input or not.
1755 1757
1756 1758 The return value can be used to decide whether to use sys.ps1 or
1757 1759 sys.ps2 to prompt the next line."""
1758 1760
1759 1761 try:
1760 1762 code = self.compile(source,filename,symbol)
1761 1763 except (OverflowError, SyntaxError, ValueError):
1762 1764 # Case 1
1763 1765 self.showsyntaxerror(filename)
1764 1766 return None
1765 1767
1766 1768 if code is None:
1767 1769 # Case 2
1768 1770 return True
1769 1771
1770 1772 # Case 3
1771 1773 # We store the code object so that threaded shells and
1772 1774 # custom exception handlers can access all this info if needed.
1773 1775 # The source corresponding to this can be obtained from the
1774 1776 # buffer attribute as '\n'.join(self.buffer).
1775 1777 self.code_to_run = code
1776 1778 # now actually execute the code object
1777 1779 if self.runcode(code) == 0:
1778 1780 return False
1779 1781 else:
1780 1782 return None
1781 1783
1782 1784 def runcode(self,code_obj):
1783 1785 """Execute a code object.
1784 1786
1785 1787 When an exception occurs, self.showtraceback() is called to display a
1786 1788 traceback.
1787 1789
1788 1790 Return value: a flag indicating whether the code to be run completed
1789 1791 successfully:
1790 1792
1791 1793 - 0: successful execution.
1792 1794 - 1: an error occurred.
1793 1795 """
1794 1796
1795 1797 # Set our own excepthook in case the user code tries to call it
1796 1798 # directly, so that the IPython crash handler doesn't get triggered
1797 1799 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1798 1800
1799 1801 # we save the original sys.excepthook in the instance, in case config
1800 1802 # code (such as magics) needs access to it.
1801 1803 self.sys_excepthook = old_excepthook
1802 1804 outflag = 1 # happens in more places, so it's easier as default
1803 1805 try:
1804 1806 try:
1805 1807 # Embedded instances require separate global/local namespaces
1806 1808 # so they can see both the surrounding (local) namespace and
1807 1809 # the module-level globals when called inside another function.
1808 1810 if self.embedded:
1809 1811 exec code_obj in self.user_global_ns, self.user_ns
1810 1812 # Normal (non-embedded) instances should only have a single
1811 1813 # namespace for user code execution, otherwise functions won't
1812 1814 # see interactive top-level globals.
1813 1815 else:
1814 1816 exec code_obj in self.user_ns
1815 1817 finally:
1816 1818 # Reset our crash handler in place
1817 1819 sys.excepthook = old_excepthook
1818 1820 except SystemExit:
1819 1821 self.resetbuffer()
1820 1822 self.showtraceback()
1821 1823 warn("Type %exit or %quit to exit IPython "
1822 1824 "(%Exit or %Quit do so unconditionally).",level=1)
1823 1825 except self.custom_exceptions:
1824 1826 etype,value,tb = sys.exc_info()
1825 1827 self.CustomTB(etype,value,tb)
1826 1828 except:
1827 1829 self.showtraceback()
1828 1830 else:
1829 1831 outflag = 0
1830 1832 if softspace(sys.stdout, 0):
1831 1833 print
1832 1834 # Flush out code object which has been run (and source)
1833 1835 self.code_to_run = None
1834 1836 return outflag
1835 1837
1836 1838 def push(self, line):
1837 1839 """Push a line to the interpreter.
1838 1840
1839 1841 The line should not have a trailing newline; it may have
1840 1842 internal newlines. The line is appended to a buffer and the
1841 1843 interpreter's runsource() method is called with the
1842 1844 concatenated contents of the buffer as source. If this
1843 1845 indicates that the command was executed or invalid, the buffer
1844 1846 is reset; otherwise, the command is incomplete, and the buffer
1845 1847 is left as it was after the line was appended. The return
1846 1848 value is 1 if more input is required, 0 if the line was dealt
1847 1849 with in some way (this is the same as runsource()).
1848 1850 """
1849 1851
1850 1852 # autoindent management should be done here, and not in the
1851 1853 # interactive loop, since that one is only seen by keyboard input. We
1852 1854 # need this done correctly even for code run via runlines (which uses
1853 1855 # push).
1854 1856
1855 1857 #print 'push line: <%s>' % line # dbg
1856 1858 for subline in line.splitlines():
1857 1859 self.autoindent_update(subline)
1858 1860 self.buffer.append(line)
1859 1861 more = self.runsource('\n'.join(self.buffer), self.filename)
1860 1862 if not more:
1861 1863 self.resetbuffer()
1862 1864 return more
1863 1865
1864 1866 def resetbuffer(self):
1865 1867 """Reset the input buffer."""
1866 1868 self.buffer[:] = []
1867 1869
1868 1870 def raw_input(self,prompt='',continue_prompt=False):
1869 1871 """Write a prompt and read a line.
1870 1872
1871 1873 The returned line does not include the trailing newline.
1872 1874 When the user enters the EOF key sequence, EOFError is raised.
1873 1875
1874 1876 Optional inputs:
1875 1877
1876 1878 - prompt(''): a string to be printed to prompt the user.
1877 1879
1878 1880 - continue_prompt(False): whether this line is the first one or a
1879 1881 continuation in a sequence of inputs.
1880 1882 """
1881 1883
1882 1884 try:
1883 1885 line = raw_input_original(prompt)
1884 1886 except ValueError:
1885 1887 warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!")
1886 1888 self.exit_now = True
1887 1889 return ""
1888 1890
1889 1891
1890 1892 # Try to be reasonably smart about not re-indenting pasted input more
1891 1893 # than necessary. We do this by trimming out the auto-indent initial
1892 1894 # spaces, if the user's actual input started itself with whitespace.
1893 1895 #debugx('self.buffer[-1]')
1894 1896
1895 1897 if self.autoindent:
1896 1898 if num_ini_spaces(line) > self.indent_current_nsp:
1897 1899 line = line[self.indent_current_nsp:]
1898 1900 self.indent_current_nsp = 0
1899 1901
1900 1902 # store the unfiltered input before the user has any chance to modify
1901 1903 # it.
1902 1904 if line.strip():
1903 1905 if continue_prompt:
1904 1906 self.input_hist_raw[-1] += '%s\n' % line
1905 1907 if self.has_readline: # and some config option is set?
1906 1908 try:
1907 1909 histlen = self.readline.get_current_history_length()
1908 1910 newhist = self.input_hist_raw[-1].rstrip()
1909 1911 self.readline.remove_history_item(histlen-1)
1910 1912 self.readline.replace_history_item(histlen-2,newhist)
1911 1913 except AttributeError:
1912 1914 pass # re{move,place}_history_item are new in 2.4.
1913 1915 else:
1914 1916 self.input_hist_raw.append('%s\n' % line)
1915 1917
1916 1918 try:
1917 1919 lineout = self.prefilter(line,continue_prompt)
1918 1920 except:
1919 1921 # blanket except, in case a user-defined prefilter crashes, so it
1920 1922 # can't take all of ipython with it.
1921 1923 self.showtraceback()
1922 1924 return ''
1923 1925 else:
1924 1926 return lineout
1925 1927
1926 1928 def split_user_input(self,line):
1927 1929 """Split user input into pre-char, function part and rest."""
1928 1930
1929 1931 lsplit = self.line_split.match(line)
1930 1932 if lsplit is None: # no regexp match returns None
1931 1933 try:
1932 1934 iFun,theRest = line.split(None,1)
1933 1935 except ValueError:
1934 1936 iFun,theRest = line,''
1935 1937 pre = re.match('^(\s*)(.*)',line).groups()[0]
1936 1938 else:
1937 1939 pre,iFun,theRest = lsplit.groups()
1938 1940
1939 1941 #print 'line:<%s>' % line # dbg
1940 1942 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1941 1943 return pre,iFun.strip(),theRest
1942 1944
1943 1945 def _prefilter(self, line, continue_prompt):
1944 1946 """Calls different preprocessors, depending on the form of line."""
1945 1947
1946 1948 # All handlers *must* return a value, even if it's blank ('').
1947 1949
1948 1950 # Lines are NOT logged here. Handlers should process the line as
1949 1951 # needed, update the cache AND log it (so that the input cache array
1950 1952 # stays synced).
1951 1953
1952 1954 # This function is _very_ delicate, and since it's also the one which
1953 1955 # determines IPython's response to user input, it must be as efficient
1954 1956 # as possible. For this reason it has _many_ returns in it, trying
1955 1957 # always to exit as quickly as it can figure out what it needs to do.
1956 1958
1957 1959 # This function is the main responsible for maintaining IPython's
1958 1960 # behavior respectful of Python's semantics. So be _very_ careful if
1959 1961 # making changes to anything here.
1960 1962
1961 1963 #.....................................................................
1962 1964 # Code begins
1963 1965
1964 1966 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1965 1967
1966 1968 # save the line away in case we crash, so the post-mortem handler can
1967 1969 # record it
1968 1970 self._last_input_line = line
1969 1971
1970 1972 #print '***line: <%s>' % line # dbg
1971 1973
1972 1974 # the input history needs to track even empty lines
1973 1975 stripped = line.strip()
1974 1976
1975 1977 if not stripped:
1976 1978 if not continue_prompt:
1977 1979 self.outputcache.prompt_count -= 1
1978 1980 return self.handle_normal(line,continue_prompt)
1979 1981 #return self.handle_normal('',continue_prompt)
1980 1982
1981 1983 # print '***cont',continue_prompt # dbg
1982 1984 # special handlers are only allowed for single line statements
1983 1985 if continue_prompt and not self.rc.multi_line_specials:
1984 1986 return self.handle_normal(line,continue_prompt)
1985 1987
1986 1988
1987 1989 # For the rest, we need the structure of the input
1988 1990 pre,iFun,theRest = self.split_user_input(line)
1989 1991
1990 1992 # See whether any pre-existing handler can take care of it
1991 1993
1992 1994 rewritten = self.hooks.input_prefilter(stripped)
1993 1995 if rewritten != stripped: # ok, some prefilter did something
1994 1996 rewritten = pre + rewritten # add indentation
1995 1997 return self.handle_normal(rewritten)
1996 1998
1997 1999 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1998 2000
1999 2001 # First check for explicit escapes in the last/first character
2000 2002 handler = None
2001 2003 if line[-1] == self.ESC_HELP:
2002 2004 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
2003 2005 if handler is None:
2004 2006 # look at the first character of iFun, NOT of line, so we skip
2005 2007 # leading whitespace in multiline input
2006 2008 handler = self.esc_handlers.get(iFun[0:1])
2007 2009 if handler is not None:
2008 2010 return handler(line,continue_prompt,pre,iFun,theRest)
2009 2011 # Emacs ipython-mode tags certain input lines
2010 2012 if line.endswith('# PYTHON-MODE'):
2011 2013 return self.handle_emacs(line,continue_prompt)
2012 2014
2013 2015 # Next, check if we can automatically execute this thing
2014 2016
2015 2017 # Allow ! in multi-line statements if multi_line_specials is on:
2016 2018 if continue_prompt and self.rc.multi_line_specials and \
2017 2019 iFun.startswith(self.ESC_SHELL):
2018 2020 return self.handle_shell_escape(line,continue_prompt,
2019 2021 pre=pre,iFun=iFun,
2020 2022 theRest=theRest)
2021 2023
2022 2024 # Let's try to find if the input line is a magic fn
2023 2025 oinfo = None
2024 2026 if hasattr(self,'magic_'+iFun):
2025 2027 # WARNING: _ofind uses getattr(), so it can consume generators and
2026 2028 # cause other side effects.
2027 2029 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2028 2030 if oinfo['ismagic']:
2029 2031 # Be careful not to call magics when a variable assignment is
2030 2032 # being made (ls='hi', for example)
2031 2033 if self.rc.automagic and \
2032 2034 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
2033 2035 (self.rc.multi_line_specials or not continue_prompt):
2034 2036 return self.handle_magic(line,continue_prompt,
2035 2037 pre,iFun,theRest)
2036 2038 else:
2037 2039 return self.handle_normal(line,continue_prompt)
2038 2040
2039 2041 # If the rest of the line begins with an (in)equality, assginment or
2040 2042 # function call, we should not call _ofind but simply execute it.
2041 2043 # This avoids spurious geattr() accesses on objects upon assignment.
2042 2044 #
2043 2045 # It also allows users to assign to either alias or magic names true
2044 2046 # python variables (the magic/alias systems always take second seat to
2045 2047 # true python code).
2046 2048 if theRest and theRest[0] in '!=()':
2047 2049 return self.handle_normal(line,continue_prompt)
2048 2050
2049 2051 if oinfo is None:
2050 2052 # let's try to ensure that _oinfo is ONLY called when autocall is
2051 2053 # on. Since it has inevitable potential side effects, at least
2052 2054 # having autocall off should be a guarantee to the user that no
2053 2055 # weird things will happen.
2054 2056
2055 2057 if self.rc.autocall:
2056 2058 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2057 2059 else:
2058 2060 # in this case, all that's left is either an alias or
2059 2061 # processing the line normally.
2060 2062 if iFun in self.alias_table:
2061 2063 # if autocall is off, by not running _ofind we won't know
2062 2064 # whether the given name may also exist in one of the
2063 2065 # user's namespace. At this point, it's best to do a
2064 2066 # quick check just to be sure that we don't let aliases
2065 2067 # shadow variables.
2066 2068 head = iFun.split('.',1)[0]
2067 2069 if head in self.user_ns or head in self.internal_ns \
2068 2070 or head in __builtin__.__dict__:
2069 2071 return self.handle_normal(line,continue_prompt)
2070 2072 else:
2071 2073 return self.handle_alias(line,continue_prompt,
2072 2074 pre,iFun,theRest)
2073 2075
2074 2076 else:
2075 2077 return self.handle_normal(line,continue_prompt)
2076 2078
2077 2079 if not oinfo['found']:
2078 2080 return self.handle_normal(line,continue_prompt)
2079 2081 else:
2080 2082 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2081 2083 if oinfo['isalias']:
2082 2084 return self.handle_alias(line,continue_prompt,
2083 2085 pre,iFun,theRest)
2084 2086
2085 2087 if (self.rc.autocall
2086 2088 and
2087 2089 (
2088 2090 #only consider exclusion re if not "," or ";" autoquoting
2089 2091 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
2090 2092 or pre == self.ESC_PAREN) or
2091 2093 (not self.re_exclude_auto.match(theRest)))
2092 2094 and
2093 2095 self.re_fun_name.match(iFun) and
2094 2096 callable(oinfo['obj'])) :
2095 2097 #print 'going auto' # dbg
2096 2098 return self.handle_auto(line,continue_prompt,
2097 2099 pre,iFun,theRest,oinfo['obj'])
2098 2100 else:
2099 2101 #print 'was callable?', callable(oinfo['obj']) # dbg
2100 2102 return self.handle_normal(line,continue_prompt)
2101 2103
2102 2104 # If we get here, we have a normal Python line. Log and return.
2103 2105 return self.handle_normal(line,continue_prompt)
2104 2106
2105 2107 def _prefilter_dumb(self, line, continue_prompt):
2106 2108 """simple prefilter function, for debugging"""
2107 2109 return self.handle_normal(line,continue_prompt)
2108 2110
2109 2111
2110 2112 def multiline_prefilter(self, line, continue_prompt):
2111 2113 """ Run _prefilter for each line of input
2112 2114
2113 2115 Covers cases where there are multiple lines in the user entry,
2114 2116 which is the case when the user goes back to a multiline history
2115 2117 entry and presses enter.
2116 2118
2117 2119 """
2118 2120 out = []
2119 2121 for l in line.rstrip('\n').split('\n'):
2120 2122 out.append(self._prefilter(l, continue_prompt))
2121 2123 return '\n'.join(out)
2122 2124
2123 2125 # Set the default prefilter() function (this can be user-overridden)
2124 2126 prefilter = multiline_prefilter
2125 2127
2126 2128 def handle_normal(self,line,continue_prompt=None,
2127 2129 pre=None,iFun=None,theRest=None):
2128 2130 """Handle normal input lines. Use as a template for handlers."""
2129 2131
2130 2132 # With autoindent on, we need some way to exit the input loop, and I
2131 2133 # don't want to force the user to have to backspace all the way to
2132 2134 # clear the line. The rule will be in this case, that either two
2133 2135 # lines of pure whitespace in a row, or a line of pure whitespace but
2134 2136 # of a size different to the indent level, will exit the input loop.
2135 2137
2136 2138 if (continue_prompt and self.autoindent and line.isspace() and
2137 2139 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2138 2140 (self.buffer[-1]).isspace() )):
2139 2141 line = ''
2140 2142
2141 2143 self.log(line,line,continue_prompt)
2142 2144 return line
2143 2145
2144 2146 def handle_alias(self,line,continue_prompt=None,
2145 2147 pre=None,iFun=None,theRest=None):
2146 2148 """Handle alias input lines. """
2147 2149
2148 2150 # pre is needed, because it carries the leading whitespace. Otherwise
2149 2151 # aliases won't work in indented sections.
2150 2152 transformed = self.expand_aliases(iFun, theRest)
2151 2153 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
2152 2154 self.log(line,line_out,continue_prompt)
2153 2155 #print 'line out:',line_out # dbg
2154 2156 return line_out
2155 2157
2156 2158 def handle_shell_escape(self, line, continue_prompt=None,
2157 2159 pre=None,iFun=None,theRest=None):
2158 2160 """Execute the line in a shell, empty return value"""
2159 2161
2160 2162 #print 'line in :', `line` # dbg
2161 2163 # Example of a special handler. Others follow a similar pattern.
2162 2164 if line.lstrip().startswith('!!'):
2163 2165 # rewrite iFun/theRest to properly hold the call to %sx and
2164 2166 # the actual command to be executed, so handle_magic can work
2165 2167 # correctly
2166 2168 theRest = '%s %s' % (iFun[2:],theRest)
2167 2169 iFun = 'sx'
2168 2170 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
2169 2171 line.lstrip()[2:]),
2170 2172 continue_prompt,pre,iFun,theRest)
2171 2173 else:
2172 2174 cmd=line.lstrip().lstrip('!')
2173 2175 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
2174 2176 # update cache/log and return
2175 2177 self.log(line,line_out,continue_prompt)
2176 2178 return line_out
2177 2179
2178 2180 def handle_magic(self, line, continue_prompt=None,
2179 2181 pre=None,iFun=None,theRest=None):
2180 2182 """Execute magic functions."""
2181 2183
2182 2184
2183 2185 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2184 2186 self.log(line,cmd,continue_prompt)
2185 2187 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2186 2188 return cmd
2187 2189
2188 2190 def handle_auto(self, line, continue_prompt=None,
2189 2191 pre=None,iFun=None,theRest=None,obj=None):
2190 2192 """Hande lines which can be auto-executed, quoting if requested."""
2191 2193
2192 2194 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2193 2195
2194 2196 # This should only be active for single-line input!
2195 2197 if continue_prompt:
2196 2198 self.log(line,line,continue_prompt)
2197 2199 return line
2198 2200
2199 2201 auto_rewrite = True
2200 2202
2201 2203 if pre == self.ESC_QUOTE:
2202 2204 # Auto-quote splitting on whitespace
2203 2205 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2204 2206 elif pre == self.ESC_QUOTE2:
2205 2207 # Auto-quote whole string
2206 2208 newcmd = '%s("%s")' % (iFun,theRest)
2207 2209 elif pre == self.ESC_PAREN:
2208 2210 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2209 2211 else:
2210 2212 # Auto-paren.
2211 2213 # We only apply it to argument-less calls if the autocall
2212 2214 # parameter is set to 2. We only need to check that autocall is <
2213 2215 # 2, since this function isn't called unless it's at least 1.
2214 2216 if not theRest and (self.rc.autocall < 2):
2215 2217 newcmd = '%s %s' % (iFun,theRest)
2216 2218 auto_rewrite = False
2217 2219 else:
2218 2220 if theRest.startswith('['):
2219 2221 if hasattr(obj,'__getitem__'):
2220 2222 # Don't autocall in this case: item access for an object
2221 2223 # which is BOTH callable and implements __getitem__.
2222 2224 newcmd = '%s %s' % (iFun,theRest)
2223 2225 auto_rewrite = False
2224 2226 else:
2225 2227 # if the object doesn't support [] access, go ahead and
2226 2228 # autocall
2227 2229 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2228 2230 elif theRest.endswith(';'):
2229 2231 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2230 2232 else:
2231 2233 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2232 2234
2233 2235 if auto_rewrite:
2234 2236 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2235 2237 # log what is now valid Python, not the actual user input (without the
2236 2238 # final newline)
2237 2239 self.log(line,newcmd,continue_prompt)
2238 2240 return newcmd
2239 2241
2240 2242 def handle_help(self, line, continue_prompt=None,
2241 2243 pre=None,iFun=None,theRest=None):
2242 2244 """Try to get some help for the object.
2243 2245
2244 2246 obj? or ?obj -> basic information.
2245 2247 obj?? or ??obj -> more details.
2246 2248 """
2247 2249
2248 2250 # We need to make sure that we don't process lines which would be
2249 2251 # otherwise valid python, such as "x=1 # what?"
2250 2252 try:
2251 2253 codeop.compile_command(line)
2252 2254 except SyntaxError:
2253 2255 # We should only handle as help stuff which is NOT valid syntax
2254 2256 if line[0]==self.ESC_HELP:
2255 2257 line = line[1:]
2256 2258 elif line[-1]==self.ESC_HELP:
2257 2259 line = line[:-1]
2258 2260 self.log(line,'#?'+line,continue_prompt)
2259 2261 if line:
2260 2262 self.magic_pinfo(line)
2261 2263 else:
2262 2264 page(self.usage,screen_lines=self.rc.screen_length)
2263 2265 return '' # Empty string is needed here!
2264 2266 except:
2265 2267 # Pass any other exceptions through to the normal handler
2266 2268 return self.handle_normal(line,continue_prompt)
2267 2269 else:
2268 2270 # If the code compiles ok, we should handle it normally
2269 2271 return self.handle_normal(line,continue_prompt)
2270 2272
2271 2273 def getapi(self):
2272 2274 """ Get an IPApi object for this shell instance
2273 2275
2274 2276 Getting an IPApi object is always preferable to accessing the shell
2275 2277 directly, but this holds true especially for extensions.
2276 2278
2277 2279 It should always be possible to implement an extension with IPApi
2278 2280 alone. If not, contact maintainer to request an addition.
2279 2281
2280 2282 """
2281 2283 return self.api
2282 2284
2283 2285 def handle_emacs(self,line,continue_prompt=None,
2284 2286 pre=None,iFun=None,theRest=None):
2285 2287 """Handle input lines marked by python-mode."""
2286 2288
2287 2289 # Currently, nothing is done. Later more functionality can be added
2288 2290 # here if needed.
2289 2291
2290 2292 # The input cache shouldn't be updated
2291 2293
2292 2294 return line
2293 2295
2294 2296 def mktempfile(self,data=None):
2295 2297 """Make a new tempfile and return its filename.
2296 2298
2297 2299 This makes a call to tempfile.mktemp, but it registers the created
2298 2300 filename internally so ipython cleans it up at exit time.
2299 2301
2300 2302 Optional inputs:
2301 2303
2302 2304 - data(None): if data is given, it gets written out to the temp file
2303 2305 immediately, and the file is closed again."""
2304 2306
2305 2307 filename = tempfile.mktemp('.py','ipython_edit_')
2306 2308 self.tempfiles.append(filename)
2307 2309
2308 2310 if data:
2309 2311 tmp_file = open(filename,'w')
2310 2312 tmp_file.write(data)
2311 2313 tmp_file.close()
2312 2314 return filename
2313 2315
2314 2316 def write(self,data):
2315 2317 """Write a string to the default output"""
2316 2318 Term.cout.write(data)
2317 2319
2318 2320 def write_err(self,data):
2319 2321 """Write a string to the default error output"""
2320 2322 Term.cerr.write(data)
2321 2323
2322 2324 def exit(self):
2323 2325 """Handle interactive exit.
2324 2326
2325 2327 This method sets the exit_now attribute."""
2326 2328
2327 2329 if self.rc.confirm_exit:
2328 2330 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2329 2331 self.exit_now = True
2330 2332 else:
2331 2333 self.exit_now = True
2332 2334
2333 2335 def safe_execfile(self,fname,*where,**kw):
2334 2336 fname = os.path.expanduser(fname)
2335 2337
2336 2338 # find things also in current directory
2337 2339 dname = os.path.dirname(fname)
2338 2340 if not sys.path.count(dname):
2339 2341 sys.path.append(dname)
2340 2342
2341 2343 try:
2342 2344 xfile = open(fname)
2343 2345 except:
2344 2346 print >> Term.cerr, \
2345 2347 'Could not open file <%s> for safe execution.' % fname
2346 2348 return None
2347 2349
2348 2350 kw.setdefault('islog',0)
2349 2351 kw.setdefault('quiet',1)
2350 2352 kw.setdefault('exit_ignore',0)
2351 2353 first = xfile.readline()
2352 2354 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2353 2355 xfile.close()
2354 2356 # line by line execution
2355 2357 if first.startswith(loghead) or kw['islog']:
2356 2358 print 'Loading log file <%s> one line at a time...' % fname
2357 2359 if kw['quiet']:
2358 2360 stdout_save = sys.stdout
2359 2361 sys.stdout = StringIO.StringIO()
2360 2362 try:
2361 2363 globs,locs = where[0:2]
2362 2364 except:
2363 2365 try:
2364 2366 globs = locs = where[0]
2365 2367 except:
2366 2368 globs = locs = globals()
2367 2369 badblocks = []
2368 2370
2369 2371 # we also need to identify indented blocks of code when replaying
2370 2372 # logs and put them together before passing them to an exec
2371 2373 # statement. This takes a bit of regexp and look-ahead work in the
2372 2374 # file. It's easiest if we swallow the whole thing in memory
2373 2375 # first, and manually walk through the lines list moving the
2374 2376 # counter ourselves.
2375 2377 indent_re = re.compile('\s+\S')
2376 2378 xfile = open(fname)
2377 2379 filelines = xfile.readlines()
2378 2380 xfile.close()
2379 2381 nlines = len(filelines)
2380 2382 lnum = 0
2381 2383 while lnum < nlines:
2382 2384 line = filelines[lnum]
2383 2385 lnum += 1
2384 2386 # don't re-insert logger status info into cache
2385 2387 if line.startswith('#log#'):
2386 2388 continue
2387 2389 else:
2388 2390 # build a block of code (maybe a single line) for execution
2389 2391 block = line
2390 2392 try:
2391 2393 next = filelines[lnum] # lnum has already incremented
2392 2394 except:
2393 2395 next = None
2394 2396 while next and indent_re.match(next):
2395 2397 block += next
2396 2398 lnum += 1
2397 2399 try:
2398 2400 next = filelines[lnum]
2399 2401 except:
2400 2402 next = None
2401 2403 # now execute the block of one or more lines
2402 2404 try:
2403 2405 exec block in globs,locs
2404 2406 except SystemExit:
2405 2407 pass
2406 2408 except:
2407 2409 badblocks.append(block.rstrip())
2408 2410 if kw['quiet']: # restore stdout
2409 2411 sys.stdout.close()
2410 2412 sys.stdout = stdout_save
2411 2413 print 'Finished replaying log file <%s>' % fname
2412 2414 if badblocks:
2413 2415 print >> sys.stderr, ('\nThe following lines/blocks in file '
2414 2416 '<%s> reported errors:' % fname)
2415 2417
2416 2418 for badline in badblocks:
2417 2419 print >> sys.stderr, badline
2418 2420 else: # regular file execution
2419 2421 try:
2420 2422 execfile(fname,*where)
2421 2423 except SyntaxError:
2422 2424 self.showsyntaxerror()
2423 2425 warn('Failure executing file: <%s>' % fname)
2424 2426 except SystemExit,status:
2425 2427 if not kw['exit_ignore']:
2426 2428 self.showtraceback()
2427 2429 warn('Failure executing file: <%s>' % fname)
2428 2430 except:
2429 2431 self.showtraceback()
2430 2432 warn('Failure executing file: <%s>' % fname)
2431 2433
2432 2434 #************************* end of file <iplib.py> *****************************
@@ -1,297 +1,305 b''
1 1 #!/usr/bin/env python
2 2 """Module for interactively running scripts.
3 3
4 4 This module implements classes for interactively running scripts written for
5 5 any system with a prompt which can be matched by a regexp suitable for
6 6 pexpect. It can be used to run as if they had been typed up interactively, an
7 7 arbitrary series of commands for the target system.
8 8
9 9 The module includes classes ready for IPython (with the default prompts),
10 10 plain Python and SAGE, but making a new one is trivial. To see how to use it,
11 11 simply run the module as a script:
12 12
13 13 ./irunner.py --help
14 14
15 15
16 16 This is an extension of Ken Schutte <kschutte-AT-csail.mit.edu>'s script
17 17 contributed on the ipython-user list:
18 18
19 19 http://scipy.net/pipermail/ipython-user/2006-May/001705.html
20 20
21 21
22 22 NOTES:
23 23
24 24 - This module requires pexpect, available in most linux distros, or which can
25 25 be downloaded from
26 26
27 27 http://pexpect.sourceforge.net
28 28
29 29 - Because pexpect only works under Unix or Windows-Cygwin, this has the same
30 30 limitations. This means that it will NOT work under native windows Python.
31 31 """
32 32
33 33 # Stdlib imports
34 34 import optparse
35 35 import os
36 36 import sys
37 37
38 38 # Third-party modules.
39 39 import pexpect
40 40
41 41 # Global usage strings, to avoid indentation issues when typing it below.
42 42 USAGE = """
43 43 Interactive script runner, type: %s
44 44
45 45 runner [opts] script_name
46 46 """
47 47
48 48 # The generic runner class
49 49 class InteractiveRunner(object):
50 50 """Class to run a sequence of commands through an interactive program."""
51 51
52 52 def __init__(self,program,prompts,args=None):
53 53 """Construct a runner.
54 54
55 55 Inputs:
56 56
57 57 - program: command to execute the given program.
58 58
59 59 - prompts: a list of patterns to match as valid prompts, in the
60 60 format used by pexpect. This basically means that it can be either
61 61 a string (to be compiled as a regular expression) or a list of such
62 62 (it must be a true list, as pexpect does type checks).
63 63
64 64 If more than one prompt is given, the first is treated as the main
65 65 program prompt and the others as 'continuation' prompts, like
66 66 python's. This means that blank lines in the input source are
67 67 ommitted when the first prompt is matched, but are NOT ommitted when
68 68 the continuation one matches, since this is how python signals the
69 69 end of multiline input interactively.
70 70
71 71 Optional inputs:
72 72
73 73 - args(None): optional list of strings to pass as arguments to the
74 74 child program.
75 75
76 76 Public members not parameterized in the constructor:
77 77
78 78 - delaybeforesend(0): Newer versions of pexpect have a delay before
79 79 sending each new input. For our purposes here, it's typically best
80 80 to just set this to zero, but if you encounter reliability problems
81 81 or want an interactive run to pause briefly at each prompt, just
82 82 increase this value (it is measured in seconds). Note that this
83 83 variable is not honored at all by older versions of pexpect.
84 84 """
85 85
86 86 self.program = program
87 87 self.prompts = prompts
88 88 if args is None: args = []
89 89 self.args = args
90 90 # Other public members which we don't make as parameters, but which
91 91 # users may occasionally want to tweak
92 92 self.delaybeforesend = 0
93 93
94 94 def run_file(self,fname,interact=False):
95 95 """Run the given file interactively.
96 96
97 97 Inputs:
98 98
99 99 -fname: name of the file to execute.
100 100
101 101 See the run_source docstring for the meaning of the optional
102 102 arguments."""
103 103
104 104 fobj = open(fname,'r')
105 105 try:
106 106 self.run_source(fobj,interact)
107 107 finally:
108 108 fobj.close()
109 109
110 110 def run_source(self,source,interact=False):
111 111 """Run the given source code interactively.
112 112
113 113 Inputs:
114 114
115 115 - source: a string of code to be executed, or an open file object we
116 116 can iterate over.
117 117
118 118 Optional inputs:
119 119
120 120 - interact(False): if true, start to interact with the running
121 121 program at the end of the script. Otherwise, just exit.
122 122 """
123 123
124 124 # if the source is a string, chop it up in lines so we can iterate
125 125 # over it just as if it were an open file.
126 126 if not isinstance(source,file):
127 127 source = source.splitlines(True)
128 128
129 129 # grab the true write method of stdout, in case anything later
130 130 # reassigns sys.stdout, so that we really are writing to the true
131 131 # stdout and not to something else. We also normalize all strings we
132 132 # write to use the native OS line separators.
133 133 linesep = os.linesep
134 134 stdwrite = sys.stdout.write
135 135 write = lambda s: stdwrite(s.replace('\r\n',linesep))
136 136
137 137 c = pexpect.spawn(self.program,self.args,timeout=None)
138 138 c.delaybeforesend = self.delaybeforesend
139
140 # pexpect hard-codes the terminal size as (24,80) (rows,columns).
141 # This causes problems because any line longer than 80 characters gets
142 # completely overwrapped on the printed outptut (even though
143 # internally the code runs fine). We reset this to 99 rows X 200
144 # columns (arbitrarily chosen), which should avoid problems in all
145 # reasonable cases.
146 c.setwinsize(99,200)
139 147
140 148 prompts = c.compile_pattern_list(self.prompts)
141 149
142 150 prompt_idx = c.expect_list(prompts)
143 151 # Flag whether the script ends normally or not, to know whether we can
144 152 # do anything further with the underlying process.
145 153 end_normal = True
146 154 for cmd in source:
147 155 # skip blank lines for all matches to the 'main' prompt, while the
148 156 # secondary prompts do not
149 157 if prompt_idx==0 and \
150 158 (cmd.isspace() or cmd.lstrip().startswith('#')):
151 159 print cmd,
152 160 continue
153 161
154 162 write(c.after)
155 163 c.send(cmd)
156 164 try:
157 165 prompt_idx = c.expect_list(prompts)
158 166 except pexpect.EOF:
159 167 # this will happen if the child dies unexpectedly
160 168 write(c.before)
161 169 end_normal = False
162 170 break
163 171 write(c.before)
164 172
165 173 if end_normal:
166 174 if interact:
167 175 c.send('\n')
168 176 print '<< Starting interactive mode >>',
169 177 try:
170 178 c.interact()
171 179 except OSError:
172 180 # This is what fires when the child stops. Simply print a
173 181 # newline so the system prompt is aligned. The extra
174 182 # space is there to make sure it gets printed, otherwise
175 183 # OS buffering sometimes just suppresses it.
176 184 write(' \n')
177 185 sys.stdout.flush()
178 186 else:
179 187 c.close()
180 188 else:
181 189 if interact:
182 190 e="Further interaction is not possible: child process is dead."
183 191 print >> sys.stderr, e
184 192
185 193 def main(self,argv=None):
186 194 """Run as a command-line script."""
187 195
188 196 parser = optparse.OptionParser(usage=USAGE % self.__class__.__name__)
189 197 newopt = parser.add_option
190 198 newopt('-i','--interact',action='store_true',default=False,
191 199 help='Interact with the program after the script is run.')
192 200
193 201 opts,args = parser.parse_args(argv)
194 202
195 203 if len(args) != 1:
196 204 print >> sys.stderr,"You must supply exactly one file to run."
197 205 sys.exit(1)
198 206
199 207 self.run_file(args[0],opts.interact)
200 208
201 209
202 210 # Specific runners for particular programs
203 211 class IPythonRunner(InteractiveRunner):
204 212 """Interactive IPython runner.
205 213
206 214 This initalizes IPython in 'nocolor' mode for simplicity. This lets us
207 215 avoid having to write a regexp that matches ANSI sequences, though pexpect
208 216 does support them. If anyone contributes patches for ANSI color support,
209 217 they will be welcome.
210 218
211 219 It also sets the prompts manually, since the prompt regexps for
212 220 pexpect need to be matched to the actual prompts, so user-customized
213 221 prompts would break this.
214 222 """
215 223
216 224 def __init__(self,program = 'ipython',args=None):
217 225 """New runner, optionally passing the ipython command to use."""
218 226
219 227 args0 = ['-colors','NoColor',
220 228 '-pi1','In [\\#]: ',
221 229 '-pi2',' .\\D.: ']
222 230 if args is None: args = args0
223 231 else: args = args0 + args
224 232 prompts = [r'In \[\d+\]: ',r' \.*: ']
225 233 InteractiveRunner.__init__(self,program,prompts,args)
226 234
227 235
228 236 class PythonRunner(InteractiveRunner):
229 237 """Interactive Python runner."""
230 238
231 239 def __init__(self,program='python',args=None):
232 240 """New runner, optionally passing the python command to use."""
233 241
234 242 prompts = [r'>>> ',r'\.\.\. ']
235 243 InteractiveRunner.__init__(self,program,prompts,args)
236 244
237 245
238 246 class SAGERunner(InteractiveRunner):
239 247 """Interactive SAGE runner.
240 248
241 249 WARNING: this runner only works if you manually configure your SAGE copy
242 250 to use 'colors NoColor' in the ipythonrc config file, since currently the
243 251 prompt matching regexp does not identify color sequences."""
244 252
245 253 def __init__(self,program='sage',args=None):
246 254 """New runner, optionally passing the sage command to use."""
247 255
248 256 prompts = ['sage: ',r'\s*\.\.\. ']
249 257 InteractiveRunner.__init__(self,program,prompts,args)
250 258
251 259 # Global usage string, to avoid indentation issues if typed in a function def.
252 260 MAIN_USAGE = """
253 261 %prog [options] file_to_run
254 262
255 263 This is an interface to the various interactive runners available in this
256 264 module. If you want to pass specific options to one of the runners, you need
257 265 to first terminate the main options with a '--', and then provide the runner's
258 266 options. For example:
259 267
260 268 irunner.py --python -- --help
261 269
262 270 will pass --help to the python runner. Similarly,
263 271
264 272 irunner.py --ipython -- --interact script.ipy
265 273
266 274 will run the script.ipy file under the IPython runner, and then will start to
267 275 interact with IPython at the end of the script (instead of exiting).
268 276
269 277 The already implemented runners are listed below; adding one for a new program
270 278 is a trivial task, see the source for examples.
271 279
272 280 WARNING: the SAGE runner only works if you manually configure your SAGE copy
273 281 to use 'colors NoColor' in the ipythonrc config file, since currently the
274 282 prompt matching regexp does not identify color sequences.
275 283 """
276 284
277 285 def main():
278 286 """Run as a command-line script."""
279 287
280 288 parser = optparse.OptionParser(usage=MAIN_USAGE)
281 289 newopt = parser.add_option
282 290 parser.set_defaults(mode='ipython')
283 291 newopt('--ipython',action='store_const',dest='mode',const='ipython',
284 292 help='IPython interactive runner (default).')
285 293 newopt('--python',action='store_const',dest='mode',const='python',
286 294 help='Python interactive runner.')
287 295 newopt('--sage',action='store_const',dest='mode',const='sage',
288 296 help='SAGE interactive runner.')
289 297
290 298 opts,args = parser.parse_args()
291 299 runners = dict(ipython=IPythonRunner,
292 300 python=PythonRunner,
293 301 sage=SAGERunner)
294 302 runners[opts.mode]().main(args)
295 303
296 304 if __name__ == '__main__':
297 305 main()
@@ -1,5815 +1,5827 b''
1 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/genutils.py (arg_split): moved to genutils, since it's a
4 pretty generic function and useful for other things.
5
6 * IPython/OInspect.py (getsource): Add customizable source
7 extractor. After a request/patch form W. Stein (SAGE).
8
9 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
10 window size to a more reasonable value from what pexpect does,
11 since their choice causes wrapping bugs with long input lines.
12
1 13 2006-10-28 Ville Vainio <vivainio@gmail.com>
2 14
3 15 * Magic.py (%run): Save and restore the readline history from
4 16 file around %run commands to prevent side effects from
5 17 %runned programs that might use readline (e.g. pydb).
6 18
7 19 * extensions/pydb_ipy.py: Adds %pydb magic when imported, for
8 20 invoking the pydb enhanced debugger.
9 21
10 22 2006-10-23 Walter Doerwald <walter@livinglogic.de>
11 23
12 24 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
13 25 call the base class method and propagate the return value to
14 26 ifile. This is now done by path itself.
15 27
16 28 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
17 29
18 30 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
19 31 api: set_crash_handler(), to expose the ability to change the
20 32 internal crash handler.
21 33
22 34 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
23 35 the various parameters of the crash handler so that apps using
24 36 IPython as their engine can customize crash handling. Ipmlemented
25 37 at the request of SAGE.
26 38
27 39 2006-10-14 Ville Vainio <vivainio@gmail.com>
28 40
29 41 * Magic.py, ipython.el: applied first "safe" part of Rocky
30 42 Bernstein's patch set for pydb integration.
31 43
32 44 * Magic.py (%unalias, %alias): %store'd aliases can now be
33 45 removed with '%unalias'. %alias w/o args now shows most
34 46 interesting (stored / manually defined) aliases last
35 47 where they catch the eye w/o scrolling.
36 48
37 49 * Magic.py (%rehashx), ext_rehashdir.py: files with
38 50 'py' extension are always considered executable, even
39 51 when not in PATHEXT environment variable.
40 52
41 53 2006-10-12 Ville Vainio <vivainio@gmail.com>
42 54
43 55 * jobctrl.py: Add new "jobctrl" extension for spawning background
44 56 processes with "&find /". 'import jobctrl' to try it out. Requires
45 57 'subprocess' module, standard in python 2.4+.
46 58
47 59 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
48 60 so if foo -> bar and bar -> baz, then foo -> baz.
49 61
50 62 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
51 63
52 64 * IPython/Magic.py (Magic.parse_options): add a new posix option
53 65 to allow parsing of input args in magics that doesn't strip quotes
54 66 (if posix=False). This also closes %timeit bug reported by
55 67 Stefan.
56 68
57 69 2006-10-03 Ville Vainio <vivainio@gmail.com>
58 70
59 71 * iplib.py (raw_input, interact): Return ValueError catching for
60 72 raw_input. Fixes infinite loop for sys.stdin.close() or
61 73 sys.stdout.close().
62 74
63 75 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
64 76
65 77 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
66 78 to help in handling doctests. irunner is now pretty useful for
67 79 running standalone scripts and simulate a full interactive session
68 80 in a format that can be then pasted as a doctest.
69 81
70 82 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
71 83 on top of the default (useless) ones. This also fixes the nasty
72 84 way in which 2.5's Quitter() exits (reverted [1785]).
73 85
74 86 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
75 87 2.5.
76 88
77 89 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
78 90 color scheme is updated as well when color scheme is changed
79 91 interactively.
80 92
81 93 2006-09-27 Ville Vainio <vivainio@gmail.com>
82 94
83 95 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
84 96 infinite loop and just exit. It's a hack, but will do for a while.
85 97
86 98 2006-08-25 Walter Doerwald <walter@livinglogic.de>
87 99
88 100 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
89 101 the constructor, this makes it possible to get a list of only directories
90 102 or only files.
91 103
92 104 2006-08-12 Ville Vainio <vivainio@gmail.com>
93 105
94 106 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
95 107 they broke unittest
96 108
97 109 2006-08-11 Ville Vainio <vivainio@gmail.com>
98 110
99 111 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
100 112 by resolving issue properly, i.e. by inheriting FakeModule
101 113 from types.ModuleType. Pickling ipython interactive data
102 114 should still work as usual (testing appreciated).
103 115
104 116 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
105 117
106 118 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
107 119 running under python 2.3 with code from 2.4 to fix a bug with
108 120 help(). Reported by the Debian maintainers, Norbert Tretkowski
109 121 <norbert-AT-tretkowski.de> and Alexandre Fayolle
110 122 <afayolle-AT-debian.org>.
111 123
112 124 2006-08-04 Walter Doerwald <walter@livinglogic.de>
113 125
114 126 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
115 127 (which was displaying "quit" twice).
116 128
117 129 2006-07-28 Walter Doerwald <walter@livinglogic.de>
118 130
119 131 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
120 132 the mode argument).
121 133
122 134 2006-07-27 Walter Doerwald <walter@livinglogic.de>
123 135
124 136 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
125 137 not running under IPython.
126 138
127 139 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
128 140 and make it iterable (iterating over the attribute itself). Add two new
129 141 magic strings for __xattrs__(): If the string starts with "-", the attribute
130 142 will not be displayed in ibrowse's detail view (but it can still be
131 143 iterated over). This makes it possible to add attributes that are large
132 144 lists or generator methods to the detail view. Replace magic attribute names
133 145 and _attrname() and _getattr() with "descriptors": For each type of magic
134 146 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
135 147 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
136 148 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
137 149 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
138 150 are still supported.
139 151
140 152 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
141 153 fails in ibrowse.fetch(), the exception object is added as the last item
142 154 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
143 155 a generator throws an exception midway through execution.
144 156
145 157 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
146 158 encoding into methods.
147 159
148 160 2006-07-26 Ville Vainio <vivainio@gmail.com>
149 161
150 162 * iplib.py: history now stores multiline input as single
151 163 history entries. Patch by Jorgen Cederlof.
152 164
153 165 2006-07-18 Walter Doerwald <walter@livinglogic.de>
154 166
155 167 * IPython/Extensions/ibrowse.py: Make cursor visible over
156 168 non existing attributes.
157 169
158 170 2006-07-14 Walter Doerwald <walter@livinglogic.de>
159 171
160 172 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
161 173 error output of the running command doesn't mess up the screen.
162 174
163 175 2006-07-13 Walter Doerwald <walter@livinglogic.de>
164 176
165 177 * IPython/Extensions/ipipe.py (isort): Make isort usable without
166 178 argument. This sorts the items themselves.
167 179
168 180 2006-07-12 Walter Doerwald <walter@livinglogic.de>
169 181
170 182 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
171 183 Compile expression strings into code objects. This should speed
172 184 up ifilter and friends somewhat.
173 185
174 186 2006-07-08 Ville Vainio <vivainio@gmail.com>
175 187
176 188 * Magic.py: %cpaste now strips > from the beginning of lines
177 189 to ease pasting quoted code from emails. Contributed by
178 190 Stefan van der Walt.
179 191
180 192 2006-06-29 Ville Vainio <vivainio@gmail.com>
181 193
182 194 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
183 195 mode, patch contributed by Darren Dale. NEEDS TESTING!
184 196
185 197 2006-06-28 Walter Doerwald <walter@livinglogic.de>
186 198
187 199 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
188 200 a blue background. Fix fetching new display rows when the browser
189 201 scrolls more than a screenful (e.g. by using the goto command).
190 202
191 203 2006-06-27 Ville Vainio <vivainio@gmail.com>
192 204
193 205 * Magic.py (_inspect, _ofind) Apply David Huard's
194 206 patch for displaying the correct docstring for 'property'
195 207 attributes.
196 208
197 209 2006-06-23 Walter Doerwald <walter@livinglogic.de>
198 210
199 211 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
200 212 commands into the methods implementing them.
201 213
202 214 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
203 215
204 216 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
205 217 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
206 218 autoindent support was authored by Jin Liu.
207 219
208 220 2006-06-22 Walter Doerwald <walter@livinglogic.de>
209 221
210 222 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
211 223 for keymaps with a custom class that simplifies handling.
212 224
213 225 2006-06-19 Walter Doerwald <walter@livinglogic.de>
214 226
215 227 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
216 228 resizing. This requires Python 2.5 to work.
217 229
218 230 2006-06-16 Walter Doerwald <walter@livinglogic.de>
219 231
220 232 * IPython/Extensions/ibrowse.py: Add two new commands to
221 233 ibrowse: "hideattr" (mapped to "h") hides the attribute under
222 234 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
223 235 attributes again. Remapped the help command to "?". Display
224 236 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
225 237 as keys for the "home" and "end" commands. Add three new commands
226 238 to the input mode for "find" and friends: "delend" (CTRL-K)
227 239 deletes to the end of line. "incsearchup" searches upwards in the
228 240 command history for an input that starts with the text before the cursor.
229 241 "incsearchdown" does the same downwards. Removed a bogus mapping of
230 242 the x key to "delete".
231 243
232 244 2006-06-15 Ville Vainio <vivainio@gmail.com>
233 245
234 246 * iplib.py, hooks.py: Added new generate_prompt hook that can be
235 247 used to create prompts dynamically, instead of the "old" way of
236 248 assigning "magic" strings to prompt_in1 and prompt_in2. The old
237 249 way still works (it's invoked by the default hook), of course.
238 250
239 251 * Prompts.py: added generate_output_prompt hook for altering output
240 252 prompt
241 253
242 254 * Release.py: Changed version string to 0.7.3.svn.
243 255
244 256 2006-06-15 Walter Doerwald <walter@livinglogic.de>
245 257
246 258 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
247 259 the call to fetch() always tries to fetch enough data for at least one
248 260 full screen. This makes it possible to simply call moveto(0,0,True) in
249 261 the constructor. Fix typos and removed the obsolete goto attribute.
250 262
251 263 2006-06-12 Ville Vainio <vivainio@gmail.com>
252 264
253 265 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
254 266 allowing $variable interpolation within multiline statements,
255 267 though so far only with "sh" profile for a testing period.
256 268 The patch also enables splitting long commands with \ but it
257 269 doesn't work properly yet.
258 270
259 271 2006-06-12 Walter Doerwald <walter@livinglogic.de>
260 272
261 273 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
262 274 input history and the position of the cursor in the input history for
263 275 the find, findbackwards and goto command.
264 276
265 277 2006-06-10 Walter Doerwald <walter@livinglogic.de>
266 278
267 279 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
268 280 implements the basic functionality of browser commands that require
269 281 input. Reimplement the goto, find and findbackwards commands as
270 282 subclasses of _CommandInput. Add an input history and keymaps to those
271 283 commands. Add "\r" as a keyboard shortcut for the enterdefault and
272 284 execute commands.
273 285
274 286 2006-06-07 Ville Vainio <vivainio@gmail.com>
275 287
276 288 * iplib.py: ipython mybatch.ipy exits ipython immediately after
277 289 running the batch files instead of leaving the session open.
278 290
279 291 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
280 292
281 293 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
282 294 the original fix was incomplete. Patch submitted by W. Maier.
283 295
284 296 2006-06-07 Ville Vainio <vivainio@gmail.com>
285 297
286 298 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
287 299 Confirmation prompts can be supressed by 'quiet' option.
288 300 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
289 301
290 302 2006-06-06 *** Released version 0.7.2
291 303
292 304 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
293 305
294 306 * IPython/Release.py (version): Made 0.7.2 final for release.
295 307 Repo tagged and release cut.
296 308
297 309 2006-06-05 Ville Vainio <vivainio@gmail.com>
298 310
299 311 * Magic.py (magic_rehashx): Honor no_alias list earlier in
300 312 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
301 313
302 314 * upgrade_dir.py: try import 'path' module a bit harder
303 315 (for %upgrade)
304 316
305 317 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
306 318
307 319 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
308 320 instead of looping 20 times.
309 321
310 322 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
311 323 correctly at initialization time. Bug reported by Krishna Mohan
312 324 Gundu <gkmohan-AT-gmail.com> on the user list.
313 325
314 326 * IPython/Release.py (version): Mark 0.7.2 version to start
315 327 testing for release on 06/06.
316 328
317 329 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
318 330
319 331 * scripts/irunner: thin script interface so users don't have to
320 332 find the module and call it as an executable, since modules rarely
321 333 live in people's PATH.
322 334
323 335 * IPython/irunner.py (InteractiveRunner.__init__): added
324 336 delaybeforesend attribute to control delays with newer versions of
325 337 pexpect. Thanks to detailed help from pexpect's author, Noah
326 338 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
327 339 correctly (it works in NoColor mode).
328 340
329 341 * IPython/iplib.py (handle_normal): fix nasty crash reported on
330 342 SAGE list, from improper log() calls.
331 343
332 344 2006-05-31 Ville Vainio <vivainio@gmail.com>
333 345
334 346 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
335 347 with args in parens to work correctly with dirs that have spaces.
336 348
337 349 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
338 350
339 351 * IPython/Logger.py (Logger.logstart): add option to log raw input
340 352 instead of the processed one. A -r flag was added to the
341 353 %logstart magic used for controlling logging.
342 354
343 355 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
344 356
345 357 * IPython/iplib.py (InteractiveShell.__init__): add check for the
346 358 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
347 359 recognize the option. After a bug report by Will Maier. This
348 360 closes #64 (will do it after confirmation from W. Maier).
349 361
350 362 * IPython/irunner.py: New module to run scripts as if manually
351 363 typed into an interactive environment, based on pexpect. After a
352 364 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
353 365 ipython-user list. Simple unittests in the tests/ directory.
354 366
355 367 * tools/release: add Will Maier, OpenBSD port maintainer, to
356 368 recepients list. We are now officially part of the OpenBSD ports:
357 369 http://www.openbsd.org/ports.html ! Many thanks to Will for the
358 370 work.
359 371
360 372 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
361 373
362 374 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
363 375 so that it doesn't break tkinter apps.
364 376
365 377 * IPython/iplib.py (_prefilter): fix bug where aliases would
366 378 shadow variables when autocall was fully off. Reported by SAGE
367 379 author William Stein.
368 380
369 381 * IPython/OInspect.py (Inspector.__init__): add a flag to control
370 382 at what detail level strings are computed when foo? is requested.
371 383 This allows users to ask for example that the string form of an
372 384 object is only computed when foo?? is called, or even never, by
373 385 setting the object_info_string_level >= 2 in the configuration
374 386 file. This new option has been added and documented. After a
375 387 request by SAGE to be able to control the printing of very large
376 388 objects more easily.
377 389
378 390 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
379 391
380 392 * IPython/ipmaker.py (make_IPython): remove the ipython call path
381 393 from sys.argv, to be 100% consistent with how Python itself works
382 394 (as seen for example with python -i file.py). After a bug report
383 395 by Jeffrey Collins.
384 396
385 397 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
386 398 nasty bug which was preventing custom namespaces with -pylab,
387 399 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
388 400 compatibility (long gone from mpl).
389 401
390 402 * IPython/ipapi.py (make_session): name change: create->make. We
391 403 use make in other places (ipmaker,...), it's shorter and easier to
392 404 type and say, etc. I'm trying to clean things before 0.7.2 so
393 405 that I can keep things stable wrt to ipapi in the chainsaw branch.
394 406
395 407 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
396 408 python-mode recognizes our debugger mode. Add support for
397 409 autoindent inside (X)emacs. After a patch sent in by Jin Liu
398 410 <m.liu.jin-AT-gmail.com> originally written by
399 411 doxgen-AT-newsmth.net (with minor modifications for xemacs
400 412 compatibility)
401 413
402 414 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
403 415 tracebacks when walking the stack so that the stack tracking system
404 416 in emacs' python-mode can identify the frames correctly.
405 417
406 418 * IPython/ipmaker.py (make_IPython): make the internal (and
407 419 default config) autoedit_syntax value false by default. Too many
408 420 users have complained to me (both on and off-list) about problems
409 421 with this option being on by default, so I'm making it default to
410 422 off. It can still be enabled by anyone via the usual mechanisms.
411 423
412 424 * IPython/completer.py (Completer.attr_matches): add support for
413 425 PyCrust-style _getAttributeNames magic method. Patch contributed
414 426 by <mscott-AT-goldenspud.com>. Closes #50.
415 427
416 428 * IPython/iplib.py (InteractiveShell.__init__): remove the
417 429 deletion of exit/quit from __builtin__, which can break
418 430 third-party tools like the Zope debugging console. The
419 431 %exit/%quit magics remain. In general, it's probably a good idea
420 432 not to delete anything from __builtin__, since we never know what
421 433 that will break. In any case, python now (for 2.5) will support
422 434 'real' exit/quit, so this issue is moot. Closes #55.
423 435
424 436 * IPython/genutils.py (with_obj): rename the 'with' function to
425 437 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
426 438 becomes a language keyword. Closes #53.
427 439
428 440 * IPython/FakeModule.py (FakeModule.__init__): add a proper
429 441 __file__ attribute to this so it fools more things into thinking
430 442 it is a real module. Closes #59.
431 443
432 444 * IPython/Magic.py (magic_edit): add -n option to open the editor
433 445 at a specific line number. After a patch by Stefan van der Walt.
434 446
435 447 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
436 448
437 449 * IPython/iplib.py (edit_syntax_error): fix crash when for some
438 450 reason the file could not be opened. After automatic crash
439 451 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
440 452 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
441 453 (_should_recompile): Don't fire editor if using %bg, since there
442 454 is no file in the first place. From the same report as above.
443 455 (raw_input): protect against faulty third-party prefilters. After
444 456 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
445 457 while running under SAGE.
446 458
447 459 2006-05-23 Ville Vainio <vivainio@gmail.com>
448 460
449 461 * ipapi.py: Stripped down ip.to_user_ns() to work only as
450 462 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
451 463 now returns None (again), unless dummy is specifically allowed by
452 464 ipapi.get(allow_dummy=True).
453 465
454 466 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
455 467
456 468 * IPython: remove all 2.2-compatibility objects and hacks from
457 469 everywhere, since we only support 2.3 at this point. Docs
458 470 updated.
459 471
460 472 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
461 473 Anything requiring extra validation can be turned into a Python
462 474 property in the future. I used a property for the db one b/c
463 475 there was a nasty circularity problem with the initialization
464 476 order, which right now I don't have time to clean up.
465 477
466 478 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
467 479 another locking bug reported by Jorgen. I'm not 100% sure though,
468 480 so more testing is needed...
469 481
470 482 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
471 483
472 484 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
473 485 local variables from any routine in user code (typically executed
474 486 with %run) directly into the interactive namespace. Very useful
475 487 when doing complex debugging.
476 488 (IPythonNotRunning): Changed the default None object to a dummy
477 489 whose attributes can be queried as well as called without
478 490 exploding, to ease writing code which works transparently both in
479 491 and out of ipython and uses some of this API.
480 492
481 493 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
482 494
483 495 * IPython/hooks.py (result_display): Fix the fact that our display
484 496 hook was using str() instead of repr(), as the default python
485 497 console does. This had gone unnoticed b/c it only happened if
486 498 %Pprint was off, but the inconsistency was there.
487 499
488 500 2006-05-15 Ville Vainio <vivainio@gmail.com>
489 501
490 502 * Oinspect.py: Only show docstring for nonexisting/binary files
491 503 when doing object??, closing ticket #62
492 504
493 505 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
494 506
495 507 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
496 508 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
497 509 was being released in a routine which hadn't checked if it had
498 510 been the one to acquire it.
499 511
500 512 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
501 513
502 514 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
503 515
504 516 2006-04-11 Ville Vainio <vivainio@gmail.com>
505 517
506 518 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
507 519 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
508 520 prefilters, allowing stuff like magics and aliases in the file.
509 521
510 522 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
511 523 added. Supported now are "%clear in" and "%clear out" (clear input and
512 524 output history, respectively). Also fixed CachedOutput.flush to
513 525 properly flush the output cache.
514 526
515 527 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
516 528 half-success (and fail explicitly).
517 529
518 530 2006-03-28 Ville Vainio <vivainio@gmail.com>
519 531
520 532 * iplib.py: Fix quoting of aliases so that only argless ones
521 533 are quoted
522 534
523 535 2006-03-28 Ville Vainio <vivainio@gmail.com>
524 536
525 537 * iplib.py: Quote aliases with spaces in the name.
526 538 "c:\program files\blah\bin" is now legal alias target.
527 539
528 540 * ext_rehashdir.py: Space no longer allowed as arg
529 541 separator, since space is legal in path names.
530 542
531 543 2006-03-16 Ville Vainio <vivainio@gmail.com>
532 544
533 545 * upgrade_dir.py: Take path.py from Extensions, correcting
534 546 %upgrade magic
535 547
536 548 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
537 549
538 550 * hooks.py: Only enclose editor binary in quotes if legal and
539 551 necessary (space in the name, and is an existing file). Fixes a bug
540 552 reported by Zachary Pincus.
541 553
542 554 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
543 555
544 556 * Manual: thanks to a tip on proper color handling for Emacs, by
545 557 Eric J Haywiser <ejh1-AT-MIT.EDU>.
546 558
547 559 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
548 560 by applying the provided patch. Thanks to Liu Jin
549 561 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
550 562 XEmacs/Linux, I'm trusting the submitter that it actually helps
551 563 under win32/GNU Emacs. Will revisit if any problems are reported.
552 564
553 565 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
554 566
555 567 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
556 568 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
557 569
558 570 2006-03-12 Ville Vainio <vivainio@gmail.com>
559 571
560 572 * Magic.py (magic_timeit): Added %timeit magic, contributed by
561 573 Torsten Marek.
562 574
563 575 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
564 576
565 577 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
566 578 line ranges works again.
567 579
568 580 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
569 581
570 582 * IPython/iplib.py (showtraceback): add back sys.last_traceback
571 583 and friends, after a discussion with Zach Pincus on ipython-user.
572 584 I'm not 100% sure, but after thinking about it quite a bit, it may
573 585 be OK. Testing with the multithreaded shells didn't reveal any
574 586 problems, but let's keep an eye out.
575 587
576 588 In the process, I fixed a few things which were calling
577 589 self.InteractiveTB() directly (like safe_execfile), which is a
578 590 mistake: ALL exception reporting should be done by calling
579 591 self.showtraceback(), which handles state and tab-completion and
580 592 more.
581 593
582 594 2006-03-01 Ville Vainio <vivainio@gmail.com>
583 595
584 596 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
585 597 To use, do "from ipipe import *".
586 598
587 599 2006-02-24 Ville Vainio <vivainio@gmail.com>
588 600
589 601 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
590 602 "cleanly" and safely than the older upgrade mechanism.
591 603
592 604 2006-02-21 Ville Vainio <vivainio@gmail.com>
593 605
594 606 * Magic.py: %save works again.
595 607
596 608 2006-02-15 Ville Vainio <vivainio@gmail.com>
597 609
598 610 * Magic.py: %Pprint works again
599 611
600 612 * Extensions/ipy_sane_defaults.py: Provide everything provided
601 613 in default ipythonrc, to make it possible to have a completely empty
602 614 ipythonrc (and thus completely rc-file free configuration)
603 615
604 616 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
605 617
606 618 * IPython/hooks.py (editor): quote the call to the editor command,
607 619 to allow commands with spaces in them. Problem noted by watching
608 620 Ian Oswald's video about textpad under win32 at
609 621 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
610 622
611 623 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
612 624 describing magics (we haven't used @ for a loong time).
613 625
614 626 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
615 627 contributed by marienz to close
616 628 http://www.scipy.net/roundup/ipython/issue53.
617 629
618 630 2006-02-10 Ville Vainio <vivainio@gmail.com>
619 631
620 632 * genutils.py: getoutput now works in win32 too
621 633
622 634 * completer.py: alias and magic completion only invoked
623 635 at the first "item" in the line, to avoid "cd %store"
624 636 nonsense.
625 637
626 638 2006-02-09 Ville Vainio <vivainio@gmail.com>
627 639
628 640 * test/*: Added a unit testing framework (finally).
629 641 '%run runtests.py' to run test_*.
630 642
631 643 * ipapi.py: Exposed runlines and set_custom_exc
632 644
633 645 2006-02-07 Ville Vainio <vivainio@gmail.com>
634 646
635 647 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
636 648 instead use "f(1 2)" as before.
637 649
638 650 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
639 651
640 652 * IPython/demo.py (IPythonDemo): Add new classes to the demo
641 653 facilities, for demos processed by the IPython input filter
642 654 (IPythonDemo), and for running a script one-line-at-a-time as a
643 655 demo, both for pure Python (LineDemo) and for IPython-processed
644 656 input (IPythonLineDemo). After a request by Dave Kohel, from the
645 657 SAGE team.
646 658 (Demo.edit): added an edit() method to the demo objects, to edit
647 659 the in-memory copy of the last executed block.
648 660
649 661 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
650 662 processing to %edit, %macro and %save. These commands can now be
651 663 invoked on the unprocessed input as it was typed by the user
652 664 (without any prefilters applied). After requests by the SAGE team
653 665 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
654 666
655 667 2006-02-01 Ville Vainio <vivainio@gmail.com>
656 668
657 669 * setup.py, eggsetup.py: easy_install ipython==dev works
658 670 correctly now (on Linux)
659 671
660 672 * ipy_user_conf,ipmaker: user config changes, removed spurious
661 673 warnings
662 674
663 675 * iplib: if rc.banner is string, use it as is.
664 676
665 677 * Magic: %pycat accepts a string argument and pages it's contents.
666 678
667 679
668 680 2006-01-30 Ville Vainio <vivainio@gmail.com>
669 681
670 682 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
671 683 Now %store and bookmarks work through PickleShare, meaning that
672 684 concurrent access is possible and all ipython sessions see the
673 685 same database situation all the time, instead of snapshot of
674 686 the situation when the session was started. Hence, %bookmark
675 687 results are immediately accessible from othes sessions. The database
676 688 is also available for use by user extensions. See:
677 689 http://www.python.org/pypi/pickleshare
678 690
679 691 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
680 692
681 693 * aliases can now be %store'd
682 694
683 695 * path.py moved to Extensions so that pickleshare does not need
684 696 IPython-specific import. Extensions added to pythonpath right
685 697 at __init__.
686 698
687 699 * iplib.py: ipalias deprecated/redundant; aliases are converted and
688 700 called with _ip.system and the pre-transformed command string.
689 701
690 702 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
691 703
692 704 * IPython/iplib.py (interact): Fix that we were not catching
693 705 KeyboardInterrupt exceptions properly. I'm not quite sure why the
694 706 logic here had to change, but it's fixed now.
695 707
696 708 2006-01-29 Ville Vainio <vivainio@gmail.com>
697 709
698 710 * iplib.py: Try to import pyreadline on Windows.
699 711
700 712 2006-01-27 Ville Vainio <vivainio@gmail.com>
701 713
702 714 * iplib.py: Expose ipapi as _ip in builtin namespace.
703 715 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
704 716 and ip_set_hook (-> _ip.set_hook) redundant. % and !
705 717 syntax now produce _ip.* variant of the commands.
706 718
707 719 * "_ip.options().autoedit_syntax = 2" automatically throws
708 720 user to editor for syntax error correction without prompting.
709 721
710 722 2006-01-27 Ville Vainio <vivainio@gmail.com>
711 723
712 724 * ipmaker.py: Give "realistic" sys.argv for scripts (without
713 725 'ipython' at argv[0]) executed through command line.
714 726 NOTE: this DEPRECATES calling ipython with multiple scripts
715 727 ("ipython a.py b.py c.py")
716 728
717 729 * iplib.py, hooks.py: Added configurable input prefilter,
718 730 named 'input_prefilter'. See ext_rescapture.py for example
719 731 usage.
720 732
721 733 * ext_rescapture.py, Magic.py: Better system command output capture
722 734 through 'var = !ls' (deprecates user-visible %sc). Same notation
723 735 applies for magics, 'var = %alias' assigns alias list to var.
724 736
725 737 * ipapi.py: added meta() for accessing extension-usable data store.
726 738
727 739 * iplib.py: added InteractiveShell.getapi(). New magics should be
728 740 written doing self.getapi() instead of using the shell directly.
729 741
730 742 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
731 743 %store foo >> ~/myfoo.txt to store variables to files (in clean
732 744 textual form, not a restorable pickle).
733 745
734 746 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
735 747
736 748 * usage.py, Magic.py: added %quickref
737 749
738 750 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
739 751
740 752 * GetoptErrors when invoking magics etc. with wrong args
741 753 are now more helpful:
742 754 GetoptError: option -l not recognized (allowed: "qb" )
743 755
744 756 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
745 757
746 758 * IPython/demo.py (Demo.show): Flush stdout after each block, so
747 759 computationally intensive blocks don't appear to stall the demo.
748 760
749 761 2006-01-24 Ville Vainio <vivainio@gmail.com>
750 762
751 763 * iplib.py, hooks.py: 'result_display' hook can return a non-None
752 764 value to manipulate resulting history entry.
753 765
754 766 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
755 767 to instance methods of IPApi class, to make extending an embedded
756 768 IPython feasible. See ext_rehashdir.py for example usage.
757 769
758 770 * Merged 1071-1076 from branches/0.7.1
759 771
760 772
761 773 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
762 774
763 775 * tools/release (daystamp): Fix build tools to use the new
764 776 eggsetup.py script to build lightweight eggs.
765 777
766 778 * Applied changesets 1062 and 1064 before 0.7.1 release.
767 779
768 780 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
769 781 see the raw input history (without conversions like %ls ->
770 782 ipmagic("ls")). After a request from W. Stein, SAGE
771 783 (http://modular.ucsd.edu/sage) developer. This information is
772 784 stored in the input_hist_raw attribute of the IPython instance, so
773 785 developers can access it if needed (it's an InputList instance).
774 786
775 787 * Versionstring = 0.7.2.svn
776 788
777 789 * eggsetup.py: A separate script for constructing eggs, creates
778 790 proper launch scripts even on Windows (an .exe file in
779 791 \python24\scripts).
780 792
781 793 * ipapi.py: launch_new_instance, launch entry point needed for the
782 794 egg.
783 795
784 796 2006-01-23 Ville Vainio <vivainio@gmail.com>
785 797
786 798 * Added %cpaste magic for pasting python code
787 799
788 800 2006-01-22 Ville Vainio <vivainio@gmail.com>
789 801
790 802 * Merge from branches/0.7.1 into trunk, revs 1052-1057
791 803
792 804 * Versionstring = 0.7.2.svn
793 805
794 806 * eggsetup.py: A separate script for constructing eggs, creates
795 807 proper launch scripts even on Windows (an .exe file in
796 808 \python24\scripts).
797 809
798 810 * ipapi.py: launch_new_instance, launch entry point needed for the
799 811 egg.
800 812
801 813 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
802 814
803 815 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
804 816 %pfile foo would print the file for foo even if it was a binary.
805 817 Now, extensions '.so' and '.dll' are skipped.
806 818
807 819 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
808 820 bug, where macros would fail in all threaded modes. I'm not 100%
809 821 sure, so I'm going to put out an rc instead of making a release
810 822 today, and wait for feedback for at least a few days.
811 823
812 824 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
813 825 it...) the handling of pasting external code with autoindent on.
814 826 To get out of a multiline input, the rule will appear for most
815 827 users unchanged: two blank lines or change the indent level
816 828 proposed by IPython. But there is a twist now: you can
817 829 add/subtract only *one or two spaces*. If you add/subtract three
818 830 or more (unless you completely delete the line), IPython will
819 831 accept that line, and you'll need to enter a second one of pure
820 832 whitespace. I know it sounds complicated, but I can't find a
821 833 different solution that covers all the cases, with the right
822 834 heuristics. Hopefully in actual use, nobody will really notice
823 835 all these strange rules and things will 'just work'.
824 836
825 837 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
826 838
827 839 * IPython/iplib.py (interact): catch exceptions which can be
828 840 triggered asynchronously by signal handlers. Thanks to an
829 841 automatic crash report, submitted by Colin Kingsley
830 842 <tercel-AT-gentoo.org>.
831 843
832 844 2006-01-20 Ville Vainio <vivainio@gmail.com>
833 845
834 846 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
835 847 (%rehashdir, very useful, try it out) of how to extend ipython
836 848 with new magics. Also added Extensions dir to pythonpath to make
837 849 importing extensions easy.
838 850
839 851 * %store now complains when trying to store interactively declared
840 852 classes / instances of those classes.
841 853
842 854 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
843 855 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
844 856 if they exist, and ipy_user_conf.py with some defaults is created for
845 857 the user.
846 858
847 859 * Startup rehashing done by the config file, not InterpreterExec.
848 860 This means system commands are available even without selecting the
849 861 pysh profile. It's the sensible default after all.
850 862
851 863 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
852 864
853 865 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
854 866 multiline code with autoindent on working. But I am really not
855 867 sure, so this needs more testing. Will commit a debug-enabled
856 868 version for now, while I test it some more, so that Ville and
857 869 others may also catch any problems. Also made
858 870 self.indent_current_str() a method, to ensure that there's no
859 871 chance of the indent space count and the corresponding string
860 872 falling out of sync. All code needing the string should just call
861 873 the method.
862 874
863 875 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
864 876
865 877 * IPython/Magic.py (magic_edit): fix check for when users don't
866 878 save their output files, the try/except was in the wrong section.
867 879
868 880 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
869 881
870 882 * IPython/Magic.py (magic_run): fix __file__ global missing from
871 883 script's namespace when executed via %run. After a report by
872 884 Vivian.
873 885
874 886 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
875 887 when using python 2.4. The parent constructor changed in 2.4, and
876 888 we need to track it directly (we can't call it, as it messes up
877 889 readline and tab-completion inside our pdb would stop working).
878 890 After a bug report by R. Bernstein <rocky-AT-panix.com>.
879 891
880 892 2006-01-16 Ville Vainio <vivainio@gmail.com>
881 893
882 894 * Ipython/magic.py: Reverted back to old %edit functionality
883 895 that returns file contents on exit.
884 896
885 897 * IPython/path.py: Added Jason Orendorff's "path" module to
886 898 IPython tree, http://www.jorendorff.com/articles/python/path/.
887 899 You can get path objects conveniently through %sc, and !!, e.g.:
888 900 sc files=ls
889 901 for p in files.paths: # or files.p
890 902 print p,p.mtime
891 903
892 904 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
893 905 now work again without considering the exclusion regexp -
894 906 hence, things like ',foo my/path' turn to 'foo("my/path")'
895 907 instead of syntax error.
896 908
897 909
898 910 2006-01-14 Ville Vainio <vivainio@gmail.com>
899 911
900 912 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
901 913 ipapi decorators for python 2.4 users, options() provides access to rc
902 914 data.
903 915
904 916 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
905 917 as path separators (even on Linux ;-). Space character after
906 918 backslash (as yielded by tab completer) is still space;
907 919 "%cd long\ name" works as expected.
908 920
909 921 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
910 922 as "chain of command", with priority. API stays the same,
911 923 TryNext exception raised by a hook function signals that
912 924 current hook failed and next hook should try handling it, as
913 925 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
914 926 requested configurable display hook, which is now implemented.
915 927
916 928 2006-01-13 Ville Vainio <vivainio@gmail.com>
917 929
918 930 * IPython/platutils*.py: platform specific utility functions,
919 931 so far only set_term_title is implemented (change terminal
920 932 label in windowing systems). %cd now changes the title to
921 933 current dir.
922 934
923 935 * IPython/Release.py: Added myself to "authors" list,
924 936 had to create new files.
925 937
926 938 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
927 939 shell escape; not a known bug but had potential to be one in the
928 940 future.
929 941
930 942 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
931 943 extension API for IPython! See the module for usage example. Fix
932 944 OInspect for docstring-less magic functions.
933 945
934 946
935 947 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
936 948
937 949 * IPython/iplib.py (raw_input): temporarily deactivate all
938 950 attempts at allowing pasting of code with autoindent on. It
939 951 introduced bugs (reported by Prabhu) and I can't seem to find a
940 952 robust combination which works in all cases. Will have to revisit
941 953 later.
942 954
943 955 * IPython/genutils.py: remove isspace() function. We've dropped
944 956 2.2 compatibility, so it's OK to use the string method.
945 957
946 958 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
947 959
948 960 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
949 961 matching what NOT to autocall on, to include all python binary
950 962 operators (including things like 'and', 'or', 'is' and 'in').
951 963 Prompted by a bug report on 'foo & bar', but I realized we had
952 964 many more potential bug cases with other operators. The regexp is
953 965 self.re_exclude_auto, it's fairly commented.
954 966
955 967 2006-01-12 Ville Vainio <vivainio@gmail.com>
956 968
957 969 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
958 970 Prettified and hardened string/backslash quoting with ipsystem(),
959 971 ipalias() and ipmagic(). Now even \ characters are passed to
960 972 %magics, !shell escapes and aliases exactly as they are in the
961 973 ipython command line. Should improve backslash experience,
962 974 particularly in Windows (path delimiter for some commands that
963 975 won't understand '/'), but Unix benefits as well (regexps). %cd
964 976 magic still doesn't support backslash path delimiters, though. Also
965 977 deleted all pretense of supporting multiline command strings in
966 978 !system or %magic commands. Thanks to Jerry McRae for suggestions.
967 979
968 980 * doc/build_doc_instructions.txt added. Documentation on how to
969 981 use doc/update_manual.py, added yesterday. Both files contributed
970 982 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
971 983 doc/*.sh for deprecation at a later date.
972 984
973 985 * /ipython.py Added ipython.py to root directory for
974 986 zero-installation (tar xzvf ipython.tgz; cd ipython; python
975 987 ipython.py) and development convenience (no need to keep doing
976 988 "setup.py install" between changes).
977 989
978 990 * Made ! and !! shell escapes work (again) in multiline expressions:
979 991 if 1:
980 992 !ls
981 993 !!ls
982 994
983 995 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
984 996
985 997 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
986 998 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
987 999 module in case-insensitive installation. Was causing crashes
988 1000 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
989 1001
990 1002 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
991 1003 <marienz-AT-gentoo.org>, closes
992 1004 http://www.scipy.net/roundup/ipython/issue51.
993 1005
994 1006 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
995 1007
996 1008 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
997 1009 problem of excessive CPU usage under *nix and keyboard lag under
998 1010 win32.
999 1011
1000 1012 2006-01-10 *** Released version 0.7.0
1001 1013
1002 1014 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1003 1015
1004 1016 * IPython/Release.py (revision): tag version number to 0.7.0,
1005 1017 ready for release.
1006 1018
1007 1019 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1008 1020 it informs the user of the name of the temp. file used. This can
1009 1021 help if you decide later to reuse that same file, so you know
1010 1022 where to copy the info from.
1011 1023
1012 1024 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1013 1025
1014 1026 * setup_bdist_egg.py: little script to build an egg. Added
1015 1027 support in the release tools as well.
1016 1028
1017 1029 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1018 1030
1019 1031 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1020 1032 version selection (new -wxversion command line and ipythonrc
1021 1033 parameter). Patch contributed by Arnd Baecker
1022 1034 <arnd.baecker-AT-web.de>.
1023 1035
1024 1036 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1025 1037 embedded instances, for variables defined at the interactive
1026 1038 prompt of the embedded ipython. Reported by Arnd.
1027 1039
1028 1040 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1029 1041 it can be used as a (stateful) toggle, or with a direct parameter.
1030 1042
1031 1043 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1032 1044 could be triggered in certain cases and cause the traceback
1033 1045 printer not to work.
1034 1046
1035 1047 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1036 1048
1037 1049 * IPython/iplib.py (_should_recompile): Small fix, closes
1038 1050 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1039 1051
1040 1052 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1041 1053
1042 1054 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1043 1055 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1044 1056 Moad for help with tracking it down.
1045 1057
1046 1058 * IPython/iplib.py (handle_auto): fix autocall handling for
1047 1059 objects which support BOTH __getitem__ and __call__ (so that f [x]
1048 1060 is left alone, instead of becoming f([x]) automatically).
1049 1061
1050 1062 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1051 1063 Ville's patch.
1052 1064
1053 1065 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1054 1066
1055 1067 * IPython/iplib.py (handle_auto): changed autocall semantics to
1056 1068 include 'smart' mode, where the autocall transformation is NOT
1057 1069 applied if there are no arguments on the line. This allows you to
1058 1070 just type 'foo' if foo is a callable to see its internal form,
1059 1071 instead of having it called with no arguments (typically a
1060 1072 mistake). The old 'full' autocall still exists: for that, you
1061 1073 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1062 1074
1063 1075 * IPython/completer.py (Completer.attr_matches): add
1064 1076 tab-completion support for Enthoughts' traits. After a report by
1065 1077 Arnd and a patch by Prabhu.
1066 1078
1067 1079 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1068 1080
1069 1081 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1070 1082 Schmolck's patch to fix inspect.getinnerframes().
1071 1083
1072 1084 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1073 1085 for embedded instances, regarding handling of namespaces and items
1074 1086 added to the __builtin__ one. Multiple embedded instances and
1075 1087 recursive embeddings should work better now (though I'm not sure
1076 1088 I've got all the corner cases fixed, that code is a bit of a brain
1077 1089 twister).
1078 1090
1079 1091 * IPython/Magic.py (magic_edit): added support to edit in-memory
1080 1092 macros (automatically creates the necessary temp files). %edit
1081 1093 also doesn't return the file contents anymore, it's just noise.
1082 1094
1083 1095 * IPython/completer.py (Completer.attr_matches): revert change to
1084 1096 complete only on attributes listed in __all__. I realized it
1085 1097 cripples the tab-completion system as a tool for exploring the
1086 1098 internals of unknown libraries (it renders any non-__all__
1087 1099 attribute off-limits). I got bit by this when trying to see
1088 1100 something inside the dis module.
1089 1101
1090 1102 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1091 1103
1092 1104 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1093 1105 namespace for users and extension writers to hold data in. This
1094 1106 follows the discussion in
1095 1107 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1096 1108
1097 1109 * IPython/completer.py (IPCompleter.complete): small patch to help
1098 1110 tab-completion under Emacs, after a suggestion by John Barnard
1099 1111 <barnarj-AT-ccf.org>.
1100 1112
1101 1113 * IPython/Magic.py (Magic.extract_input_slices): added support for
1102 1114 the slice notation in magics to use N-M to represent numbers N...M
1103 1115 (closed endpoints). This is used by %macro and %save.
1104 1116
1105 1117 * IPython/completer.py (Completer.attr_matches): for modules which
1106 1118 define __all__, complete only on those. After a patch by Jeffrey
1107 1119 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1108 1120 speed up this routine.
1109 1121
1110 1122 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1111 1123 don't know if this is the end of it, but the behavior now is
1112 1124 certainly much more correct. Note that coupled with macros,
1113 1125 slightly surprising (at first) behavior may occur: a macro will in
1114 1126 general expand to multiple lines of input, so upon exiting, the
1115 1127 in/out counters will both be bumped by the corresponding amount
1116 1128 (as if the macro's contents had been typed interactively). Typing
1117 1129 %hist will reveal the intermediate (silently processed) lines.
1118 1130
1119 1131 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1120 1132 pickle to fail (%run was overwriting __main__ and not restoring
1121 1133 it, but pickle relies on __main__ to operate).
1122 1134
1123 1135 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1124 1136 using properties, but forgot to make the main InteractiveShell
1125 1137 class a new-style class. Properties fail silently, and
1126 1138 mysteriously, with old-style class (getters work, but
1127 1139 setters don't do anything).
1128 1140
1129 1141 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1130 1142
1131 1143 * IPython/Magic.py (magic_history): fix history reporting bug (I
1132 1144 know some nasties are still there, I just can't seem to find a
1133 1145 reproducible test case to track them down; the input history is
1134 1146 falling out of sync...)
1135 1147
1136 1148 * IPython/iplib.py (handle_shell_escape): fix bug where both
1137 1149 aliases and system accesses where broken for indented code (such
1138 1150 as loops).
1139 1151
1140 1152 * IPython/genutils.py (shell): fix small but critical bug for
1141 1153 win32 system access.
1142 1154
1143 1155 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1144 1156
1145 1157 * IPython/iplib.py (showtraceback): remove use of the
1146 1158 sys.last_{type/value/traceback} structures, which are non
1147 1159 thread-safe.
1148 1160 (_prefilter): change control flow to ensure that we NEVER
1149 1161 introspect objects when autocall is off. This will guarantee that
1150 1162 having an input line of the form 'x.y', where access to attribute
1151 1163 'y' has side effects, doesn't trigger the side effect TWICE. It
1152 1164 is important to note that, with autocall on, these side effects
1153 1165 can still happen.
1154 1166 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1155 1167 trio. IPython offers these three kinds of special calls which are
1156 1168 not python code, and it's a good thing to have their call method
1157 1169 be accessible as pure python functions (not just special syntax at
1158 1170 the command line). It gives us a better internal implementation
1159 1171 structure, as well as exposing these for user scripting more
1160 1172 cleanly.
1161 1173
1162 1174 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1163 1175 file. Now that they'll be more likely to be used with the
1164 1176 persistance system (%store), I want to make sure their module path
1165 1177 doesn't change in the future, so that we don't break things for
1166 1178 users' persisted data.
1167 1179
1168 1180 * IPython/iplib.py (autoindent_update): move indentation
1169 1181 management into the _text_ processing loop, not the keyboard
1170 1182 interactive one. This is necessary to correctly process non-typed
1171 1183 multiline input (such as macros).
1172 1184
1173 1185 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1174 1186 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1175 1187 which was producing problems in the resulting manual.
1176 1188 (magic_whos): improve reporting of instances (show their class,
1177 1189 instead of simply printing 'instance' which isn't terribly
1178 1190 informative).
1179 1191
1180 1192 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1181 1193 (minor mods) to support network shares under win32.
1182 1194
1183 1195 * IPython/winconsole.py (get_console_size): add new winconsole
1184 1196 module and fixes to page_dumb() to improve its behavior under
1185 1197 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1186 1198
1187 1199 * IPython/Magic.py (Macro): simplified Macro class to just
1188 1200 subclass list. We've had only 2.2 compatibility for a very long
1189 1201 time, yet I was still avoiding subclassing the builtin types. No
1190 1202 more (I'm also starting to use properties, though I won't shift to
1191 1203 2.3-specific features quite yet).
1192 1204 (magic_store): added Ville's patch for lightweight variable
1193 1205 persistence, after a request on the user list by Matt Wilkie
1194 1206 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1195 1207 details.
1196 1208
1197 1209 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1198 1210 changed the default logfile name from 'ipython.log' to
1199 1211 'ipython_log.py'. These logs are real python files, and now that
1200 1212 we have much better multiline support, people are more likely to
1201 1213 want to use them as such. Might as well name them correctly.
1202 1214
1203 1215 * IPython/Magic.py: substantial cleanup. While we can't stop
1204 1216 using magics as mixins, due to the existing customizations 'out
1205 1217 there' which rely on the mixin naming conventions, at least I
1206 1218 cleaned out all cross-class name usage. So once we are OK with
1207 1219 breaking compatibility, the two systems can be separated.
1208 1220
1209 1221 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1210 1222 anymore, and the class is a fair bit less hideous as well. New
1211 1223 features were also introduced: timestamping of input, and logging
1212 1224 of output results. These are user-visible with the -t and -o
1213 1225 options to %logstart. Closes
1214 1226 http://www.scipy.net/roundup/ipython/issue11 and a request by
1215 1227 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1216 1228
1217 1229 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1218 1230
1219 1231 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1220 1232 better handle backslashes in paths. See the thread 'More Windows
1221 1233 questions part 2 - \/ characters revisited' on the iypthon user
1222 1234 list:
1223 1235 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1224 1236
1225 1237 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1226 1238
1227 1239 (InteractiveShell.__init__): change threaded shells to not use the
1228 1240 ipython crash handler. This was causing more problems than not,
1229 1241 as exceptions in the main thread (GUI code, typically) would
1230 1242 always show up as a 'crash', when they really weren't.
1231 1243
1232 1244 The colors and exception mode commands (%colors/%xmode) have been
1233 1245 synchronized to also take this into account, so users can get
1234 1246 verbose exceptions for their threaded code as well. I also added
1235 1247 support for activating pdb inside this exception handler as well,
1236 1248 so now GUI authors can use IPython's enhanced pdb at runtime.
1237 1249
1238 1250 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1239 1251 true by default, and add it to the shipped ipythonrc file. Since
1240 1252 this asks the user before proceeding, I think it's OK to make it
1241 1253 true by default.
1242 1254
1243 1255 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1244 1256 of the previous special-casing of input in the eval loop. I think
1245 1257 this is cleaner, as they really are commands and shouldn't have
1246 1258 a special role in the middle of the core code.
1247 1259
1248 1260 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1249 1261
1250 1262 * IPython/iplib.py (edit_syntax_error): added support for
1251 1263 automatically reopening the editor if the file had a syntax error
1252 1264 in it. Thanks to scottt who provided the patch at:
1253 1265 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1254 1266 version committed).
1255 1267
1256 1268 * IPython/iplib.py (handle_normal): add suport for multi-line
1257 1269 input with emtpy lines. This fixes
1258 1270 http://www.scipy.net/roundup/ipython/issue43 and a similar
1259 1271 discussion on the user list.
1260 1272
1261 1273 WARNING: a behavior change is necessarily introduced to support
1262 1274 blank lines: now a single blank line with whitespace does NOT
1263 1275 break the input loop, which means that when autoindent is on, by
1264 1276 default hitting return on the next (indented) line does NOT exit.
1265 1277
1266 1278 Instead, to exit a multiline input you can either have:
1267 1279
1268 1280 - TWO whitespace lines (just hit return again), or
1269 1281 - a single whitespace line of a different length than provided
1270 1282 by the autoindent (add or remove a space).
1271 1283
1272 1284 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1273 1285 module to better organize all readline-related functionality.
1274 1286 I've deleted FlexCompleter and put all completion clases here.
1275 1287
1276 1288 * IPython/iplib.py (raw_input): improve indentation management.
1277 1289 It is now possible to paste indented code with autoindent on, and
1278 1290 the code is interpreted correctly (though it still looks bad on
1279 1291 screen, due to the line-oriented nature of ipython).
1280 1292 (MagicCompleter.complete): change behavior so that a TAB key on an
1281 1293 otherwise empty line actually inserts a tab, instead of completing
1282 1294 on the entire global namespace. This makes it easier to use the
1283 1295 TAB key for indentation. After a request by Hans Meine
1284 1296 <hans_meine-AT-gmx.net>
1285 1297 (_prefilter): add support so that typing plain 'exit' or 'quit'
1286 1298 does a sensible thing. Originally I tried to deviate as little as
1287 1299 possible from the default python behavior, but even that one may
1288 1300 change in this direction (thread on python-dev to that effect).
1289 1301 Regardless, ipython should do the right thing even if CPython's
1290 1302 '>>>' prompt doesn't.
1291 1303 (InteractiveShell): removed subclassing code.InteractiveConsole
1292 1304 class. By now we'd overridden just about all of its methods: I've
1293 1305 copied the remaining two over, and now ipython is a standalone
1294 1306 class. This will provide a clearer picture for the chainsaw
1295 1307 branch refactoring.
1296 1308
1297 1309 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1298 1310
1299 1311 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1300 1312 failures for objects which break when dir() is called on them.
1301 1313
1302 1314 * IPython/FlexCompleter.py (Completer.__init__): Added support for
1303 1315 distinct local and global namespaces in the completer API. This
1304 1316 change allows us to properly handle completion with distinct
1305 1317 scopes, including in embedded instances (this had never really
1306 1318 worked correctly).
1307 1319
1308 1320 Note: this introduces a change in the constructor for
1309 1321 MagicCompleter, as a new global_namespace parameter is now the
1310 1322 second argument (the others were bumped one position).
1311 1323
1312 1324 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
1313 1325
1314 1326 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1315 1327 embedded instances (which can be done now thanks to Vivian's
1316 1328 frame-handling fixes for pdb).
1317 1329 (InteractiveShell.__init__): Fix namespace handling problem in
1318 1330 embedded instances. We were overwriting __main__ unconditionally,
1319 1331 and this should only be done for 'full' (non-embedded) IPython;
1320 1332 embedded instances must respect the caller's __main__. Thanks to
1321 1333 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
1322 1334
1323 1335 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
1324 1336
1325 1337 * setup.py: added download_url to setup(). This registers the
1326 1338 download address at PyPI, which is not only useful to humans
1327 1339 browsing the site, but is also picked up by setuptools (the Eggs
1328 1340 machinery). Thanks to Ville and R. Kern for the info/discussion
1329 1341 on this.
1330 1342
1331 1343 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
1332 1344
1333 1345 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
1334 1346 This brings a lot of nice functionality to the pdb mode, which now
1335 1347 has tab-completion, syntax highlighting, and better stack handling
1336 1348 than before. Many thanks to Vivian De Smedt
1337 1349 <vivian-AT-vdesmedt.com> for the original patches.
1338 1350
1339 1351 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
1340 1352
1341 1353 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
1342 1354 sequence to consistently accept the banner argument. The
1343 1355 inconsistency was tripping SAGE, thanks to Gary Zablackis
1344 1356 <gzabl-AT-yahoo.com> for the report.
1345 1357
1346 1358 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1347 1359
1348 1360 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1349 1361 Fix bug where a naked 'alias' call in the ipythonrc file would
1350 1362 cause a crash. Bug reported by Jorgen Stenarson.
1351 1363
1352 1364 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1353 1365
1354 1366 * IPython/ipmaker.py (make_IPython): cleanups which should improve
1355 1367 startup time.
1356 1368
1357 1369 * IPython/iplib.py (runcode): my globals 'fix' for embedded
1358 1370 instances had introduced a bug with globals in normal code. Now
1359 1371 it's working in all cases.
1360 1372
1361 1373 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
1362 1374 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
1363 1375 has been introduced to set the default case sensitivity of the
1364 1376 searches. Users can still select either mode at runtime on a
1365 1377 per-search basis.
1366 1378
1367 1379 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
1368 1380
1369 1381 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
1370 1382 attributes in wildcard searches for subclasses. Modified version
1371 1383 of a patch by Jorgen.
1372 1384
1373 1385 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
1374 1386
1375 1387 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
1376 1388 embedded instances. I added a user_global_ns attribute to the
1377 1389 InteractiveShell class to handle this.
1378 1390
1379 1391 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
1380 1392
1381 1393 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
1382 1394 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
1383 1395 (reported under win32, but may happen also in other platforms).
1384 1396 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
1385 1397
1386 1398 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1387 1399
1388 1400 * IPython/Magic.py (magic_psearch): new support for wildcard
1389 1401 patterns. Now, typing ?a*b will list all names which begin with a
1390 1402 and end in b, for example. The %psearch magic has full
1391 1403 docstrings. Many thanks to JΓΆrgen Stenarson
1392 1404 <jorgen.stenarson-AT-bostream.nu>, author of the patches
1393 1405 implementing this functionality.
1394 1406
1395 1407 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1396 1408
1397 1409 * Manual: fixed long-standing annoyance of double-dashes (as in
1398 1410 --prefix=~, for example) being stripped in the HTML version. This
1399 1411 is a latex2html bug, but a workaround was provided. Many thanks
1400 1412 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
1401 1413 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
1402 1414 rolling. This seemingly small issue had tripped a number of users
1403 1415 when first installing, so I'm glad to see it gone.
1404 1416
1405 1417 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1406 1418
1407 1419 * IPython/Extensions/numeric_formats.py: fix missing import,
1408 1420 reported by Stephen Walton.
1409 1421
1410 1422 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
1411 1423
1412 1424 * IPython/demo.py: finish demo module, fully documented now.
1413 1425
1414 1426 * IPython/genutils.py (file_read): simple little utility to read a
1415 1427 file and ensure it's closed afterwards.
1416 1428
1417 1429 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
1418 1430
1419 1431 * IPython/demo.py (Demo.__init__): added support for individually
1420 1432 tagging blocks for automatic execution.
1421 1433
1422 1434 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
1423 1435 syntax-highlighted python sources, requested by John.
1424 1436
1425 1437 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
1426 1438
1427 1439 * IPython/demo.py (Demo.again): fix bug where again() blocks after
1428 1440 finishing.
1429 1441
1430 1442 * IPython/genutils.py (shlex_split): moved from Magic to here,
1431 1443 where all 2.2 compatibility stuff lives. I needed it for demo.py.
1432 1444
1433 1445 * IPython/demo.py (Demo.__init__): added support for silent
1434 1446 blocks, improved marks as regexps, docstrings written.
1435 1447 (Demo.__init__): better docstring, added support for sys.argv.
1436 1448
1437 1449 * IPython/genutils.py (marquee): little utility used by the demo
1438 1450 code, handy in general.
1439 1451
1440 1452 * IPython/demo.py (Demo.__init__): new class for interactive
1441 1453 demos. Not documented yet, I just wrote it in a hurry for
1442 1454 scipy'05. Will docstring later.
1443 1455
1444 1456 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
1445 1457
1446 1458 * IPython/Shell.py (sigint_handler): Drastic simplification which
1447 1459 also seems to make Ctrl-C work correctly across threads! This is
1448 1460 so simple, that I can't beleive I'd missed it before. Needs more
1449 1461 testing, though.
1450 1462 (KBINT): Never mind, revert changes. I'm sure I'd tried something
1451 1463 like this before...
1452 1464
1453 1465 * IPython/genutils.py (get_home_dir): add protection against
1454 1466 non-dirs in win32 registry.
1455 1467
1456 1468 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
1457 1469 bug where dict was mutated while iterating (pysh crash).
1458 1470
1459 1471 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
1460 1472
1461 1473 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
1462 1474 spurious newlines added by this routine. After a report by
1463 1475 F. Mantegazza.
1464 1476
1465 1477 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
1466 1478
1467 1479 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
1468 1480 calls. These were a leftover from the GTK 1.x days, and can cause
1469 1481 problems in certain cases (after a report by John Hunter).
1470 1482
1471 1483 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
1472 1484 os.getcwd() fails at init time. Thanks to patch from David Remahl
1473 1485 <chmod007-AT-mac.com>.
1474 1486 (InteractiveShell.__init__): prevent certain special magics from
1475 1487 being shadowed by aliases. Closes
1476 1488 http://www.scipy.net/roundup/ipython/issue41.
1477 1489
1478 1490 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
1479 1491
1480 1492 * IPython/iplib.py (InteractiveShell.complete): Added new
1481 1493 top-level completion method to expose the completion mechanism
1482 1494 beyond readline-based environments.
1483 1495
1484 1496 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
1485 1497
1486 1498 * tools/ipsvnc (svnversion): fix svnversion capture.
1487 1499
1488 1500 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
1489 1501 attribute to self, which was missing. Before, it was set by a
1490 1502 routine which in certain cases wasn't being called, so the
1491 1503 instance could end up missing the attribute. This caused a crash.
1492 1504 Closes http://www.scipy.net/roundup/ipython/issue40.
1493 1505
1494 1506 2005-08-16 Fernando Perez <fperez@colorado.edu>
1495 1507
1496 1508 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
1497 1509 contains non-string attribute. Closes
1498 1510 http://www.scipy.net/roundup/ipython/issue38.
1499 1511
1500 1512 2005-08-14 Fernando Perez <fperez@colorado.edu>
1501 1513
1502 1514 * tools/ipsvnc: Minor improvements, to add changeset info.
1503 1515
1504 1516 2005-08-12 Fernando Perez <fperez@colorado.edu>
1505 1517
1506 1518 * IPython/iplib.py (runsource): remove self.code_to_run_src
1507 1519 attribute. I realized this is nothing more than
1508 1520 '\n'.join(self.buffer), and having the same data in two different
1509 1521 places is just asking for synchronization bugs. This may impact
1510 1522 people who have custom exception handlers, so I need to warn
1511 1523 ipython-dev about it (F. Mantegazza may use them).
1512 1524
1513 1525 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
1514 1526
1515 1527 * IPython/genutils.py: fix 2.2 compatibility (generators)
1516 1528
1517 1529 2005-07-18 Fernando Perez <fperez@colorado.edu>
1518 1530
1519 1531 * IPython/genutils.py (get_home_dir): fix to help users with
1520 1532 invalid $HOME under win32.
1521 1533
1522 1534 2005-07-17 Fernando Perez <fperez@colorado.edu>
1523 1535
1524 1536 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
1525 1537 some old hacks and clean up a bit other routines; code should be
1526 1538 simpler and a bit faster.
1527 1539
1528 1540 * IPython/iplib.py (interact): removed some last-resort attempts
1529 1541 to survive broken stdout/stderr. That code was only making it
1530 1542 harder to abstract out the i/o (necessary for gui integration),
1531 1543 and the crashes it could prevent were extremely rare in practice
1532 1544 (besides being fully user-induced in a pretty violent manner).
1533 1545
1534 1546 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
1535 1547 Nothing major yet, but the code is simpler to read; this should
1536 1548 make it easier to do more serious modifications in the future.
1537 1549
1538 1550 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
1539 1551 which broke in .15 (thanks to a report by Ville).
1540 1552
1541 1553 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
1542 1554 be quite correct, I know next to nothing about unicode). This
1543 1555 will allow unicode strings to be used in prompts, amongst other
1544 1556 cases. It also will prevent ipython from crashing when unicode
1545 1557 shows up unexpectedly in many places. If ascii encoding fails, we
1546 1558 assume utf_8. Currently the encoding is not a user-visible
1547 1559 setting, though it could be made so if there is demand for it.
1548 1560
1549 1561 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
1550 1562
1551 1563 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
1552 1564
1553 1565 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
1554 1566
1555 1567 * IPython/genutils.py: Add 2.2 compatibility here, so all other
1556 1568 code can work transparently for 2.2/2.3.
1557 1569
1558 1570 2005-07-16 Fernando Perez <fperez@colorado.edu>
1559 1571
1560 1572 * IPython/ultraTB.py (ExceptionColors): Make a global variable
1561 1573 out of the color scheme table used for coloring exception
1562 1574 tracebacks. This allows user code to add new schemes at runtime.
1563 1575 This is a minimally modified version of the patch at
1564 1576 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
1565 1577 for the contribution.
1566 1578
1567 1579 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
1568 1580 slightly modified version of the patch in
1569 1581 http://www.scipy.net/roundup/ipython/issue34, which also allows me
1570 1582 to remove the previous try/except solution (which was costlier).
1571 1583 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
1572 1584
1573 1585 2005-06-08 Fernando Perez <fperez@colorado.edu>
1574 1586
1575 1587 * IPython/iplib.py (write/write_err): Add methods to abstract all
1576 1588 I/O a bit more.
1577 1589
1578 1590 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
1579 1591 warning, reported by Aric Hagberg, fix by JD Hunter.
1580 1592
1581 1593 2005-06-02 *** Released version 0.6.15
1582 1594
1583 1595 2005-06-01 Fernando Perez <fperez@colorado.edu>
1584 1596
1585 1597 * IPython/iplib.py (MagicCompleter.file_matches): Fix
1586 1598 tab-completion of filenames within open-quoted strings. Note that
1587 1599 this requires that in ~/.ipython/ipythonrc, users change the
1588 1600 readline delimiters configuration to read:
1589 1601
1590 1602 readline_remove_delims -/~
1591 1603
1592 1604
1593 1605 2005-05-31 *** Released version 0.6.14
1594 1606
1595 1607 2005-05-29 Fernando Perez <fperez@colorado.edu>
1596 1608
1597 1609 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
1598 1610 with files not on the filesystem. Reported by Eliyahu Sandler
1599 1611 <eli@gondolin.net>
1600 1612
1601 1613 2005-05-22 Fernando Perez <fperez@colorado.edu>
1602 1614
1603 1615 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
1604 1616 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
1605 1617
1606 1618 2005-05-19 Fernando Perez <fperez@colorado.edu>
1607 1619
1608 1620 * IPython/iplib.py (safe_execfile): close a file which could be
1609 1621 left open (causing problems in win32, which locks open files).
1610 1622 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
1611 1623
1612 1624 2005-05-18 Fernando Perez <fperez@colorado.edu>
1613 1625
1614 1626 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
1615 1627 keyword arguments correctly to safe_execfile().
1616 1628
1617 1629 2005-05-13 Fernando Perez <fperez@colorado.edu>
1618 1630
1619 1631 * ipython.1: Added info about Qt to manpage, and threads warning
1620 1632 to usage page (invoked with --help).
1621 1633
1622 1634 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
1623 1635 new matcher (it goes at the end of the priority list) to do
1624 1636 tab-completion on named function arguments. Submitted by George
1625 1637 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
1626 1638 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
1627 1639 for more details.
1628 1640
1629 1641 * IPython/Magic.py (magic_run): Added new -e flag to ignore
1630 1642 SystemExit exceptions in the script being run. Thanks to a report
1631 1643 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
1632 1644 producing very annoying behavior when running unit tests.
1633 1645
1634 1646 2005-05-12 Fernando Perez <fperez@colorado.edu>
1635 1647
1636 1648 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
1637 1649 which I'd broken (again) due to a changed regexp. In the process,
1638 1650 added ';' as an escape to auto-quote the whole line without
1639 1651 splitting its arguments. Thanks to a report by Jerry McRae
1640 1652 <qrs0xyc02-AT-sneakemail.com>.
1641 1653
1642 1654 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
1643 1655 possible crashes caused by a TokenError. Reported by Ed Schofield
1644 1656 <schofield-AT-ftw.at>.
1645 1657
1646 1658 2005-05-06 Fernando Perez <fperez@colorado.edu>
1647 1659
1648 1660 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
1649 1661
1650 1662 2005-04-29 Fernando Perez <fperez@colorado.edu>
1651 1663
1652 1664 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
1653 1665 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
1654 1666 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
1655 1667 which provides support for Qt interactive usage (similar to the
1656 1668 existing one for WX and GTK). This had been often requested.
1657 1669
1658 1670 2005-04-14 *** Released version 0.6.13
1659 1671
1660 1672 2005-04-08 Fernando Perez <fperez@colorado.edu>
1661 1673
1662 1674 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
1663 1675 from _ofind, which gets called on almost every input line. Now,
1664 1676 we only try to get docstrings if they are actually going to be
1665 1677 used (the overhead of fetching unnecessary docstrings can be
1666 1678 noticeable for certain objects, such as Pyro proxies).
1667 1679
1668 1680 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
1669 1681 for completers. For some reason I had been passing them the state
1670 1682 variable, which completers never actually need, and was in
1671 1683 conflict with the rlcompleter API. Custom completers ONLY need to
1672 1684 take the text parameter.
1673 1685
1674 1686 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
1675 1687 work correctly in pysh. I've also moved all the logic which used
1676 1688 to be in pysh.py here, which will prevent problems with future
1677 1689 upgrades. However, this time I must warn users to update their
1678 1690 pysh profile to include the line
1679 1691
1680 1692 import_all IPython.Extensions.InterpreterExec
1681 1693
1682 1694 because otherwise things won't work for them. They MUST also
1683 1695 delete pysh.py and the line
1684 1696
1685 1697 execfile pysh.py
1686 1698
1687 1699 from their ipythonrc-pysh.
1688 1700
1689 1701 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
1690 1702 robust in the face of objects whose dir() returns non-strings
1691 1703 (which it shouldn't, but some broken libs like ITK do). Thanks to
1692 1704 a patch by John Hunter (implemented differently, though). Also
1693 1705 minor improvements by using .extend instead of + on lists.
1694 1706
1695 1707 * pysh.py:
1696 1708
1697 1709 2005-04-06 Fernando Perez <fperez@colorado.edu>
1698 1710
1699 1711 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
1700 1712 by default, so that all users benefit from it. Those who don't
1701 1713 want it can still turn it off.
1702 1714
1703 1715 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
1704 1716 config file, I'd forgotten about this, so users were getting it
1705 1717 off by default.
1706 1718
1707 1719 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
1708 1720 consistency. Now magics can be called in multiline statements,
1709 1721 and python variables can be expanded in magic calls via $var.
1710 1722 This makes the magic system behave just like aliases or !system
1711 1723 calls.
1712 1724
1713 1725 2005-03-28 Fernando Perez <fperez@colorado.edu>
1714 1726
1715 1727 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
1716 1728 expensive string additions for building command. Add support for
1717 1729 trailing ';' when autocall is used.
1718 1730
1719 1731 2005-03-26 Fernando Perez <fperez@colorado.edu>
1720 1732
1721 1733 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
1722 1734 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
1723 1735 ipython.el robust against prompts with any number of spaces
1724 1736 (including 0) after the ':' character.
1725 1737
1726 1738 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
1727 1739 continuation prompt, which misled users to think the line was
1728 1740 already indented. Closes debian Bug#300847, reported to me by
1729 1741 Norbert Tretkowski <tretkowski-AT-inittab.de>.
1730 1742
1731 1743 2005-03-23 Fernando Perez <fperez@colorado.edu>
1732 1744
1733 1745 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
1734 1746 properly aligned if they have embedded newlines.
1735 1747
1736 1748 * IPython/iplib.py (runlines): Add a public method to expose
1737 1749 IPython's code execution machinery, so that users can run strings
1738 1750 as if they had been typed at the prompt interactively.
1739 1751 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
1740 1752 methods which can call the system shell, but with python variable
1741 1753 expansion. The three such methods are: __IPYTHON__.system,
1742 1754 .getoutput and .getoutputerror. These need to be documented in a
1743 1755 'public API' section (to be written) of the manual.
1744 1756
1745 1757 2005-03-20 Fernando Perez <fperez@colorado.edu>
1746 1758
1747 1759 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
1748 1760 for custom exception handling. This is quite powerful, and it
1749 1761 allows for user-installable exception handlers which can trap
1750 1762 custom exceptions at runtime and treat them separately from
1751 1763 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
1752 1764 Mantegazza <mantegazza-AT-ill.fr>.
1753 1765 (InteractiveShell.set_custom_completer): public API function to
1754 1766 add new completers at runtime.
1755 1767
1756 1768 2005-03-19 Fernando Perez <fperez@colorado.edu>
1757 1769
1758 1770 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
1759 1771 allow objects which provide their docstrings via non-standard
1760 1772 mechanisms (like Pyro proxies) to still be inspected by ipython's
1761 1773 ? system.
1762 1774
1763 1775 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
1764 1776 automatic capture system. I tried quite hard to make it work
1765 1777 reliably, and simply failed. I tried many combinations with the
1766 1778 subprocess module, but eventually nothing worked in all needed
1767 1779 cases (not blocking stdin for the child, duplicating stdout
1768 1780 without blocking, etc). The new %sc/%sx still do capture to these
1769 1781 magical list/string objects which make shell use much more
1770 1782 conveninent, so not all is lost.
1771 1783
1772 1784 XXX - FIX MANUAL for the change above!
1773 1785
1774 1786 (runsource): I copied code.py's runsource() into ipython to modify
1775 1787 it a bit. Now the code object and source to be executed are
1776 1788 stored in ipython. This makes this info accessible to third-party
1777 1789 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
1778 1790 Mantegazza <mantegazza-AT-ill.fr>.
1779 1791
1780 1792 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
1781 1793 history-search via readline (like C-p/C-n). I'd wanted this for a
1782 1794 long time, but only recently found out how to do it. For users
1783 1795 who already have their ipythonrc files made and want this, just
1784 1796 add:
1785 1797
1786 1798 readline_parse_and_bind "\e[A": history-search-backward
1787 1799 readline_parse_and_bind "\e[B": history-search-forward
1788 1800
1789 1801 2005-03-18 Fernando Perez <fperez@colorado.edu>
1790 1802
1791 1803 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
1792 1804 LSString and SList classes which allow transparent conversions
1793 1805 between list mode and whitespace-separated string.
1794 1806 (magic_r): Fix recursion problem in %r.
1795 1807
1796 1808 * IPython/genutils.py (LSString): New class to be used for
1797 1809 automatic storage of the results of all alias/system calls in _o
1798 1810 and _e (stdout/err). These provide a .l/.list attribute which
1799 1811 does automatic splitting on newlines. This means that for most
1800 1812 uses, you'll never need to do capturing of output with %sc/%sx
1801 1813 anymore, since ipython keeps this always done for you. Note that
1802 1814 only the LAST results are stored, the _o/e variables are
1803 1815 overwritten on each call. If you need to save their contents
1804 1816 further, simply bind them to any other name.
1805 1817
1806 1818 2005-03-17 Fernando Perez <fperez@colorado.edu>
1807 1819
1808 1820 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
1809 1821 prompt namespace handling.
1810 1822
1811 1823 2005-03-16 Fernando Perez <fperez@colorado.edu>
1812 1824
1813 1825 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
1814 1826 classic prompts to be '>>> ' (final space was missing, and it
1815 1827 trips the emacs python mode).
1816 1828 (BasePrompt.__str__): Added safe support for dynamic prompt
1817 1829 strings. Now you can set your prompt string to be '$x', and the
1818 1830 value of x will be printed from your interactive namespace. The
1819 1831 interpolation syntax includes the full Itpl support, so
1820 1832 ${foo()+x+bar()} is a valid prompt string now, and the function
1821 1833 calls will be made at runtime.
1822 1834
1823 1835 2005-03-15 Fernando Perez <fperez@colorado.edu>
1824 1836
1825 1837 * IPython/Magic.py (magic_history): renamed %hist to %history, to
1826 1838 avoid name clashes in pylab. %hist still works, it just forwards
1827 1839 the call to %history.
1828 1840
1829 1841 2005-03-02 *** Released version 0.6.12
1830 1842
1831 1843 2005-03-02 Fernando Perez <fperez@colorado.edu>
1832 1844
1833 1845 * IPython/iplib.py (handle_magic): log magic calls properly as
1834 1846 ipmagic() function calls.
1835 1847
1836 1848 * IPython/Magic.py (magic_time): Improved %time to support
1837 1849 statements and provide wall-clock as well as CPU time.
1838 1850
1839 1851 2005-02-27 Fernando Perez <fperez@colorado.edu>
1840 1852
1841 1853 * IPython/hooks.py: New hooks module, to expose user-modifiable
1842 1854 IPython functionality in a clean manner. For now only the editor
1843 1855 hook is actually written, and other thigns which I intend to turn
1844 1856 into proper hooks aren't yet there. The display and prefilter
1845 1857 stuff, for example, should be hooks. But at least now the
1846 1858 framework is in place, and the rest can be moved here with more
1847 1859 time later. IPython had had a .hooks variable for a long time for
1848 1860 this purpose, but I'd never actually used it for anything.
1849 1861
1850 1862 2005-02-26 Fernando Perez <fperez@colorado.edu>
1851 1863
1852 1864 * IPython/ipmaker.py (make_IPython): make the default ipython
1853 1865 directory be called _ipython under win32, to follow more the
1854 1866 naming peculiarities of that platform (where buggy software like
1855 1867 Visual Sourcesafe breaks with .named directories). Reported by
1856 1868 Ville Vainio.
1857 1869
1858 1870 2005-02-23 Fernando Perez <fperez@colorado.edu>
1859 1871
1860 1872 * IPython/iplib.py (InteractiveShell.__init__): removed a few
1861 1873 auto_aliases for win32 which were causing problems. Users can
1862 1874 define the ones they personally like.
1863 1875
1864 1876 2005-02-21 Fernando Perez <fperez@colorado.edu>
1865 1877
1866 1878 * IPython/Magic.py (magic_time): new magic to time execution of
1867 1879 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
1868 1880
1869 1881 2005-02-19 Fernando Perez <fperez@colorado.edu>
1870 1882
1871 1883 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
1872 1884 into keys (for prompts, for example).
1873 1885
1874 1886 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
1875 1887 prompts in case users want them. This introduces a small behavior
1876 1888 change: ipython does not automatically add a space to all prompts
1877 1889 anymore. To get the old prompts with a space, users should add it
1878 1890 manually to their ipythonrc file, so for example prompt_in1 should
1879 1891 now read 'In [\#]: ' instead of 'In [\#]:'.
1880 1892 (BasePrompt.__init__): New option prompts_pad_left (only in rc
1881 1893 file) to control left-padding of secondary prompts.
1882 1894
1883 1895 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
1884 1896 the profiler can't be imported. Fix for Debian, which removed
1885 1897 profile.py because of License issues. I applied a slightly
1886 1898 modified version of the original Debian patch at
1887 1899 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
1888 1900
1889 1901 2005-02-17 Fernando Perez <fperez@colorado.edu>
1890 1902
1891 1903 * IPython/genutils.py (native_line_ends): Fix bug which would
1892 1904 cause improper line-ends under win32 b/c I was not opening files
1893 1905 in binary mode. Bug report and fix thanks to Ville.
1894 1906
1895 1907 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
1896 1908 trying to catch spurious foo[1] autocalls. My fix actually broke
1897 1909 ',/' autoquote/call with explicit escape (bad regexp).
1898 1910
1899 1911 2005-02-15 *** Released version 0.6.11
1900 1912
1901 1913 2005-02-14 Fernando Perez <fperez@colorado.edu>
1902 1914
1903 1915 * IPython/background_jobs.py: New background job management
1904 1916 subsystem. This is implemented via a new set of classes, and
1905 1917 IPython now provides a builtin 'jobs' object for background job
1906 1918 execution. A convenience %bg magic serves as a lightweight
1907 1919 frontend for starting the more common type of calls. This was
1908 1920 inspired by discussions with B. Granger and the BackgroundCommand
1909 1921 class described in the book Python Scripting for Computational
1910 1922 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
1911 1923 (although ultimately no code from this text was used, as IPython's
1912 1924 system is a separate implementation).
1913 1925
1914 1926 * IPython/iplib.py (MagicCompleter.python_matches): add new option
1915 1927 to control the completion of single/double underscore names
1916 1928 separately. As documented in the example ipytonrc file, the
1917 1929 readline_omit__names variable can now be set to 2, to omit even
1918 1930 single underscore names. Thanks to a patch by Brian Wong
1919 1931 <BrianWong-AT-AirgoNetworks.Com>.
1920 1932 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
1921 1933 be autocalled as foo([1]) if foo were callable. A problem for
1922 1934 things which are both callable and implement __getitem__.
1923 1935 (init_readline): Fix autoindentation for win32. Thanks to a patch
1924 1936 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
1925 1937
1926 1938 2005-02-12 Fernando Perez <fperez@colorado.edu>
1927 1939
1928 1940 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
1929 1941 which I had written long ago to sort out user error messages which
1930 1942 may occur during startup. This seemed like a good idea initially,
1931 1943 but it has proven a disaster in retrospect. I don't want to
1932 1944 change much code for now, so my fix is to set the internal 'debug'
1933 1945 flag to true everywhere, whose only job was precisely to control
1934 1946 this subsystem. This closes issue 28 (as well as avoiding all
1935 1947 sorts of strange hangups which occur from time to time).
1936 1948
1937 1949 2005-02-07 Fernando Perez <fperez@colorado.edu>
1938 1950
1939 1951 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
1940 1952 previous call produced a syntax error.
1941 1953
1942 1954 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1943 1955 classes without constructor.
1944 1956
1945 1957 2005-02-06 Fernando Perez <fperez@colorado.edu>
1946 1958
1947 1959 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
1948 1960 completions with the results of each matcher, so we return results
1949 1961 to the user from all namespaces. This breaks with ipython
1950 1962 tradition, but I think it's a nicer behavior. Now you get all
1951 1963 possible completions listed, from all possible namespaces (python,
1952 1964 filesystem, magics...) After a request by John Hunter
1953 1965 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1954 1966
1955 1967 2005-02-05 Fernando Perez <fperez@colorado.edu>
1956 1968
1957 1969 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
1958 1970 the call had quote characters in it (the quotes were stripped).
1959 1971
1960 1972 2005-01-31 Fernando Perez <fperez@colorado.edu>
1961 1973
1962 1974 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
1963 1975 Itpl.itpl() to make the code more robust against psyco
1964 1976 optimizations.
1965 1977
1966 1978 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
1967 1979 of causing an exception. Quicker, cleaner.
1968 1980
1969 1981 2005-01-28 Fernando Perez <fperez@colorado.edu>
1970 1982
1971 1983 * scripts/ipython_win_post_install.py (install): hardcode
1972 1984 sys.prefix+'python.exe' as the executable path. It turns out that
1973 1985 during the post-installation run, sys.executable resolves to the
1974 1986 name of the binary installer! I should report this as a distutils
1975 1987 bug, I think. I updated the .10 release with this tiny fix, to
1976 1988 avoid annoying the lists further.
1977 1989
1978 1990 2005-01-27 *** Released version 0.6.10
1979 1991
1980 1992 2005-01-27 Fernando Perez <fperez@colorado.edu>
1981 1993
1982 1994 * IPython/numutils.py (norm): Added 'inf' as optional name for
1983 1995 L-infinity norm, included references to mathworld.com for vector
1984 1996 norm definitions.
1985 1997 (amin/amax): added amin/amax for array min/max. Similar to what
1986 1998 pylab ships with after the recent reorganization of names.
1987 1999 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1988 2000
1989 2001 * ipython.el: committed Alex's recent fixes and improvements.
1990 2002 Tested with python-mode from CVS, and it looks excellent. Since
1991 2003 python-mode hasn't released anything in a while, I'm temporarily
1992 2004 putting a copy of today's CVS (v 4.70) of python-mode in:
1993 2005 http://ipython.scipy.org/tmp/python-mode.el
1994 2006
1995 2007 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1996 2008 sys.executable for the executable name, instead of assuming it's
1997 2009 called 'python.exe' (the post-installer would have produced broken
1998 2010 setups on systems with a differently named python binary).
1999 2011
2000 2012 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2001 2013 references to os.linesep, to make the code more
2002 2014 platform-independent. This is also part of the win32 coloring
2003 2015 fixes.
2004 2016
2005 2017 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2006 2018 lines, which actually cause coloring bugs because the length of
2007 2019 the line is very difficult to correctly compute with embedded
2008 2020 escapes. This was the source of all the coloring problems under
2009 2021 Win32. I think that _finally_, Win32 users have a properly
2010 2022 working ipython in all respects. This would never have happened
2011 2023 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2012 2024
2013 2025 2005-01-26 *** Released version 0.6.9
2014 2026
2015 2027 2005-01-25 Fernando Perez <fperez@colorado.edu>
2016 2028
2017 2029 * setup.py: finally, we have a true Windows installer, thanks to
2018 2030 the excellent work of Viktor Ransmayr
2019 2031 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2020 2032 Windows users. The setup routine is quite a bit cleaner thanks to
2021 2033 this, and the post-install script uses the proper functions to
2022 2034 allow a clean de-installation using the standard Windows Control
2023 2035 Panel.
2024 2036
2025 2037 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2026 2038 environment variable under all OSes (including win32) if
2027 2039 available. This will give consistency to win32 users who have set
2028 2040 this variable for any reason. If os.environ['HOME'] fails, the
2029 2041 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2030 2042
2031 2043 2005-01-24 Fernando Perez <fperez@colorado.edu>
2032 2044
2033 2045 * IPython/numutils.py (empty_like): add empty_like(), similar to
2034 2046 zeros_like() but taking advantage of the new empty() Numeric routine.
2035 2047
2036 2048 2005-01-23 *** Released version 0.6.8
2037 2049
2038 2050 2005-01-22 Fernando Perez <fperez@colorado.edu>
2039 2051
2040 2052 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2041 2053 automatic show() calls. After discussing things with JDH, it
2042 2054 turns out there are too many corner cases where this can go wrong.
2043 2055 It's best not to try to be 'too smart', and simply have ipython
2044 2056 reproduce as much as possible the default behavior of a normal
2045 2057 python shell.
2046 2058
2047 2059 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2048 2060 line-splitting regexp and _prefilter() to avoid calling getattr()
2049 2061 on assignments. This closes
2050 2062 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2051 2063 readline uses getattr(), so a simple <TAB> keypress is still
2052 2064 enough to trigger getattr() calls on an object.
2053 2065
2054 2066 2005-01-21 Fernando Perez <fperez@colorado.edu>
2055 2067
2056 2068 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2057 2069 docstring under pylab so it doesn't mask the original.
2058 2070
2059 2071 2005-01-21 *** Released version 0.6.7
2060 2072
2061 2073 2005-01-21 Fernando Perez <fperez@colorado.edu>
2062 2074
2063 2075 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2064 2076 signal handling for win32 users in multithreaded mode.
2065 2077
2066 2078 2005-01-17 Fernando Perez <fperez@colorado.edu>
2067 2079
2068 2080 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2069 2081 instances with no __init__. After a crash report by Norbert Nemec
2070 2082 <Norbert-AT-nemec-online.de>.
2071 2083
2072 2084 2005-01-14 Fernando Perez <fperez@colorado.edu>
2073 2085
2074 2086 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2075 2087 names for verbose exceptions, when multiple dotted names and the
2076 2088 'parent' object were present on the same line.
2077 2089
2078 2090 2005-01-11 Fernando Perez <fperez@colorado.edu>
2079 2091
2080 2092 * IPython/genutils.py (flag_calls): new utility to trap and flag
2081 2093 calls in functions. I need it to clean up matplotlib support.
2082 2094 Also removed some deprecated code in genutils.
2083 2095
2084 2096 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2085 2097 that matplotlib scripts called with %run, which don't call show()
2086 2098 themselves, still have their plotting windows open.
2087 2099
2088 2100 2005-01-05 Fernando Perez <fperez@colorado.edu>
2089 2101
2090 2102 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2091 2103 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2092 2104
2093 2105 2004-12-19 Fernando Perez <fperez@colorado.edu>
2094 2106
2095 2107 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2096 2108 parent_runcode, which was an eyesore. The same result can be
2097 2109 obtained with Python's regular superclass mechanisms.
2098 2110
2099 2111 2004-12-17 Fernando Perez <fperez@colorado.edu>
2100 2112
2101 2113 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2102 2114 reported by Prabhu.
2103 2115 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2104 2116 sys.stderr) instead of explicitly calling sys.stderr. This helps
2105 2117 maintain our I/O abstractions clean, for future GUI embeddings.
2106 2118
2107 2119 * IPython/genutils.py (info): added new utility for sys.stderr
2108 2120 unified info message handling (thin wrapper around warn()).
2109 2121
2110 2122 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2111 2123 composite (dotted) names on verbose exceptions.
2112 2124 (VerboseTB.nullrepr): harden against another kind of errors which
2113 2125 Python's inspect module can trigger, and which were crashing
2114 2126 IPython. Thanks to a report by Marco Lombardi
2115 2127 <mlombard-AT-ma010192.hq.eso.org>.
2116 2128
2117 2129 2004-12-13 *** Released version 0.6.6
2118 2130
2119 2131 2004-12-12 Fernando Perez <fperez@colorado.edu>
2120 2132
2121 2133 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2122 2134 generated by pygtk upon initialization if it was built without
2123 2135 threads (for matplotlib users). After a crash reported by
2124 2136 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2125 2137
2126 2138 * IPython/ipmaker.py (make_IPython): fix small bug in the
2127 2139 import_some parameter for multiple imports.
2128 2140
2129 2141 * IPython/iplib.py (ipmagic): simplified the interface of
2130 2142 ipmagic() to take a single string argument, just as it would be
2131 2143 typed at the IPython cmd line.
2132 2144 (ipalias): Added new ipalias() with an interface identical to
2133 2145 ipmagic(). This completes exposing a pure python interface to the
2134 2146 alias and magic system, which can be used in loops or more complex
2135 2147 code where IPython's automatic line mangling is not active.
2136 2148
2137 2149 * IPython/genutils.py (timing): changed interface of timing to
2138 2150 simply run code once, which is the most common case. timings()
2139 2151 remains unchanged, for the cases where you want multiple runs.
2140 2152
2141 2153 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2142 2154 bug where Python2.2 crashes with exec'ing code which does not end
2143 2155 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2144 2156 before.
2145 2157
2146 2158 2004-12-10 Fernando Perez <fperez@colorado.edu>
2147 2159
2148 2160 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2149 2161 -t to -T, to accomodate the new -t flag in %run (the %run and
2150 2162 %prun options are kind of intermixed, and it's not easy to change
2151 2163 this with the limitations of python's getopt).
2152 2164
2153 2165 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2154 2166 the execution of scripts. It's not as fine-tuned as timeit.py,
2155 2167 but it works from inside ipython (and under 2.2, which lacks
2156 2168 timeit.py). Optionally a number of runs > 1 can be given for
2157 2169 timing very short-running code.
2158 2170
2159 2171 * IPython/genutils.py (uniq_stable): new routine which returns a
2160 2172 list of unique elements in any iterable, but in stable order of
2161 2173 appearance. I needed this for the ultraTB fixes, and it's a handy
2162 2174 utility.
2163 2175
2164 2176 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2165 2177 dotted names in Verbose exceptions. This had been broken since
2166 2178 the very start, now x.y will properly be printed in a Verbose
2167 2179 traceback, instead of x being shown and y appearing always as an
2168 2180 'undefined global'. Getting this to work was a bit tricky,
2169 2181 because by default python tokenizers are stateless. Saved by
2170 2182 python's ability to easily add a bit of state to an arbitrary
2171 2183 function (without needing to build a full-blown callable object).
2172 2184
2173 2185 Also big cleanup of this code, which had horrendous runtime
2174 2186 lookups of zillions of attributes for colorization. Moved all
2175 2187 this code into a few templates, which make it cleaner and quicker.
2176 2188
2177 2189 Printout quality was also improved for Verbose exceptions: one
2178 2190 variable per line, and memory addresses are printed (this can be
2179 2191 quite handy in nasty debugging situations, which is what Verbose
2180 2192 is for).
2181 2193
2182 2194 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2183 2195 the command line as scripts to be loaded by embedded instances.
2184 2196 Doing so has the potential for an infinite recursion if there are
2185 2197 exceptions thrown in the process. This fixes a strange crash
2186 2198 reported by Philippe MULLER <muller-AT-irit.fr>.
2187 2199
2188 2200 2004-12-09 Fernando Perez <fperez@colorado.edu>
2189 2201
2190 2202 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2191 2203 to reflect new names in matplotlib, which now expose the
2192 2204 matlab-compatible interface via a pylab module instead of the
2193 2205 'matlab' name. The new code is backwards compatible, so users of
2194 2206 all matplotlib versions are OK. Patch by J. Hunter.
2195 2207
2196 2208 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2197 2209 of __init__ docstrings for instances (class docstrings are already
2198 2210 automatically printed). Instances with customized docstrings
2199 2211 (indep. of the class) are also recognized and all 3 separate
2200 2212 docstrings are printed (instance, class, constructor). After some
2201 2213 comments/suggestions by J. Hunter.
2202 2214
2203 2215 2004-12-05 Fernando Perez <fperez@colorado.edu>
2204 2216
2205 2217 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2206 2218 warnings when tab-completion fails and triggers an exception.
2207 2219
2208 2220 2004-12-03 Fernando Perez <fperez@colorado.edu>
2209 2221
2210 2222 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2211 2223 be triggered when using 'run -p'. An incorrect option flag was
2212 2224 being set ('d' instead of 'D').
2213 2225 (manpage): fix missing escaped \- sign.
2214 2226
2215 2227 2004-11-30 *** Released version 0.6.5
2216 2228
2217 2229 2004-11-30 Fernando Perez <fperez@colorado.edu>
2218 2230
2219 2231 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2220 2232 setting with -d option.
2221 2233
2222 2234 * setup.py (docfiles): Fix problem where the doc glob I was using
2223 2235 was COMPLETELY BROKEN. It was giving the right files by pure
2224 2236 accident, but failed once I tried to include ipython.el. Note:
2225 2237 glob() does NOT allow you to do exclusion on multiple endings!
2226 2238
2227 2239 2004-11-29 Fernando Perez <fperez@colorado.edu>
2228 2240
2229 2241 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2230 2242 the manpage as the source. Better formatting & consistency.
2231 2243
2232 2244 * IPython/Magic.py (magic_run): Added new -d option, to run
2233 2245 scripts under the control of the python pdb debugger. Note that
2234 2246 this required changing the %prun option -d to -D, to avoid a clash
2235 2247 (since %run must pass options to %prun, and getopt is too dumb to
2236 2248 handle options with string values with embedded spaces). Thanks
2237 2249 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2238 2250 (magic_who_ls): added type matching to %who and %whos, so that one
2239 2251 can filter their output to only include variables of certain
2240 2252 types. Another suggestion by Matthew.
2241 2253 (magic_whos): Added memory summaries in kb and Mb for arrays.
2242 2254 (magic_who): Improve formatting (break lines every 9 vars).
2243 2255
2244 2256 2004-11-28 Fernando Perez <fperez@colorado.edu>
2245 2257
2246 2258 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2247 2259 cache when empty lines were present.
2248 2260
2249 2261 2004-11-24 Fernando Perez <fperez@colorado.edu>
2250 2262
2251 2263 * IPython/usage.py (__doc__): document the re-activated threading
2252 2264 options for WX and GTK.
2253 2265
2254 2266 2004-11-23 Fernando Perez <fperez@colorado.edu>
2255 2267
2256 2268 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2257 2269 the -wthread and -gthread options, along with a new -tk one to try
2258 2270 and coordinate Tk threading with wx/gtk. The tk support is very
2259 2271 platform dependent, since it seems to require Tcl and Tk to be
2260 2272 built with threads (Fedora1/2 appears NOT to have it, but in
2261 2273 Prabhu's Debian boxes it works OK). But even with some Tk
2262 2274 limitations, this is a great improvement.
2263 2275
2264 2276 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2265 2277 info in user prompts. Patch by Prabhu.
2266 2278
2267 2279 2004-11-18 Fernando Perez <fperez@colorado.edu>
2268 2280
2269 2281 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2270 2282 EOFErrors and bail, to avoid infinite loops if a non-terminating
2271 2283 file is fed into ipython. Patch submitted in issue 19 by user,
2272 2284 many thanks.
2273 2285
2274 2286 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2275 2287 autoquote/parens in continuation prompts, which can cause lots of
2276 2288 problems. Closes roundup issue 20.
2277 2289
2278 2290 2004-11-17 Fernando Perez <fperez@colorado.edu>
2279 2291
2280 2292 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2281 2293 reported as debian bug #280505. I'm not sure my local changelog
2282 2294 entry has the proper debian format (Jack?).
2283 2295
2284 2296 2004-11-08 *** Released version 0.6.4
2285 2297
2286 2298 2004-11-08 Fernando Perez <fperez@colorado.edu>
2287 2299
2288 2300 * IPython/iplib.py (init_readline): Fix exit message for Windows
2289 2301 when readline is active. Thanks to a report by Eric Jones
2290 2302 <eric-AT-enthought.com>.
2291 2303
2292 2304 2004-11-07 Fernando Perez <fperez@colorado.edu>
2293 2305
2294 2306 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2295 2307 sometimes seen by win2k/cygwin users.
2296 2308
2297 2309 2004-11-06 Fernando Perez <fperez@colorado.edu>
2298 2310
2299 2311 * IPython/iplib.py (interact): Change the handling of %Exit from
2300 2312 trying to propagate a SystemExit to an internal ipython flag.
2301 2313 This is less elegant than using Python's exception mechanism, but
2302 2314 I can't get that to work reliably with threads, so under -pylab
2303 2315 %Exit was hanging IPython. Cross-thread exception handling is
2304 2316 really a bitch. Thaks to a bug report by Stephen Walton
2305 2317 <stephen.walton-AT-csun.edu>.
2306 2318
2307 2319 2004-11-04 Fernando Perez <fperez@colorado.edu>
2308 2320
2309 2321 * IPython/iplib.py (raw_input_original): store a pointer to the
2310 2322 true raw_input to harden against code which can modify it
2311 2323 (wx.py.PyShell does this and would otherwise crash ipython).
2312 2324 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
2313 2325
2314 2326 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
2315 2327 Ctrl-C problem, which does not mess up the input line.
2316 2328
2317 2329 2004-11-03 Fernando Perez <fperez@colorado.edu>
2318 2330
2319 2331 * IPython/Release.py: Changed licensing to BSD, in all files.
2320 2332 (name): lowercase name for tarball/RPM release.
2321 2333
2322 2334 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
2323 2335 use throughout ipython.
2324 2336
2325 2337 * IPython/Magic.py (Magic._ofind): Switch to using the new
2326 2338 OInspect.getdoc() function.
2327 2339
2328 2340 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
2329 2341 of the line currently being canceled via Ctrl-C. It's extremely
2330 2342 ugly, but I don't know how to do it better (the problem is one of
2331 2343 handling cross-thread exceptions).
2332 2344
2333 2345 2004-10-28 Fernando Perez <fperez@colorado.edu>
2334 2346
2335 2347 * IPython/Shell.py (signal_handler): add signal handlers to trap
2336 2348 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
2337 2349 report by Francesc Alted.
2338 2350
2339 2351 2004-10-21 Fernando Perez <fperez@colorado.edu>
2340 2352
2341 2353 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
2342 2354 to % for pysh syntax extensions.
2343 2355
2344 2356 2004-10-09 Fernando Perez <fperez@colorado.edu>
2345 2357
2346 2358 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
2347 2359 arrays to print a more useful summary, without calling str(arr).
2348 2360 This avoids the problem of extremely lengthy computations which
2349 2361 occur if arr is large, and appear to the user as a system lockup
2350 2362 with 100% cpu activity. After a suggestion by Kristian Sandberg
2351 2363 <Kristian.Sandberg@colorado.edu>.
2352 2364 (Magic.__init__): fix bug in global magic escapes not being
2353 2365 correctly set.
2354 2366
2355 2367 2004-10-08 Fernando Perez <fperez@colorado.edu>
2356 2368
2357 2369 * IPython/Magic.py (__license__): change to absolute imports of
2358 2370 ipython's own internal packages, to start adapting to the absolute
2359 2371 import requirement of PEP-328.
2360 2372
2361 2373 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
2362 2374 files, and standardize author/license marks through the Release
2363 2375 module instead of having per/file stuff (except for files with
2364 2376 particular licenses, like the MIT/PSF-licensed codes).
2365 2377
2366 2378 * IPython/Debugger.py: remove dead code for python 2.1
2367 2379
2368 2380 2004-10-04 Fernando Perez <fperez@colorado.edu>
2369 2381
2370 2382 * IPython/iplib.py (ipmagic): New function for accessing magics
2371 2383 via a normal python function call.
2372 2384
2373 2385 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
2374 2386 from '@' to '%', to accomodate the new @decorator syntax of python
2375 2387 2.4.
2376 2388
2377 2389 2004-09-29 Fernando Perez <fperez@colorado.edu>
2378 2390
2379 2391 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
2380 2392 matplotlib.use to prevent running scripts which try to switch
2381 2393 interactive backends from within ipython. This will just crash
2382 2394 the python interpreter, so we can't allow it (but a detailed error
2383 2395 is given to the user).
2384 2396
2385 2397 2004-09-28 Fernando Perez <fperez@colorado.edu>
2386 2398
2387 2399 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
2388 2400 matplotlib-related fixes so that using @run with non-matplotlib
2389 2401 scripts doesn't pop up spurious plot windows. This requires
2390 2402 matplotlib >= 0.63, where I had to make some changes as well.
2391 2403
2392 2404 * IPython/ipmaker.py (make_IPython): update version requirement to
2393 2405 python 2.2.
2394 2406
2395 2407 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
2396 2408 banner arg for embedded customization.
2397 2409
2398 2410 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
2399 2411 explicit uses of __IP as the IPython's instance name. Now things
2400 2412 are properly handled via the shell.name value. The actual code
2401 2413 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
2402 2414 is much better than before. I'll clean things completely when the
2403 2415 magic stuff gets a real overhaul.
2404 2416
2405 2417 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
2406 2418 minor changes to debian dir.
2407 2419
2408 2420 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
2409 2421 pointer to the shell itself in the interactive namespace even when
2410 2422 a user-supplied dict is provided. This is needed for embedding
2411 2423 purposes (found by tests with Michel Sanner).
2412 2424
2413 2425 2004-09-27 Fernando Perez <fperez@colorado.edu>
2414 2426
2415 2427 * IPython/UserConfig/ipythonrc: remove []{} from
2416 2428 readline_remove_delims, so that things like [modname.<TAB> do
2417 2429 proper completion. This disables [].TAB, but that's a less common
2418 2430 case than module names in list comprehensions, for example.
2419 2431 Thanks to a report by Andrea Riciputi.
2420 2432
2421 2433 2004-09-09 Fernando Perez <fperez@colorado.edu>
2422 2434
2423 2435 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
2424 2436 blocking problems in win32 and osx. Fix by John.
2425 2437
2426 2438 2004-09-08 Fernando Perez <fperez@colorado.edu>
2427 2439
2428 2440 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
2429 2441 for Win32 and OSX. Fix by John Hunter.
2430 2442
2431 2443 2004-08-30 *** Released version 0.6.3
2432 2444
2433 2445 2004-08-30 Fernando Perez <fperez@colorado.edu>
2434 2446
2435 2447 * setup.py (isfile): Add manpages to list of dependent files to be
2436 2448 updated.
2437 2449
2438 2450 2004-08-27 Fernando Perez <fperez@colorado.edu>
2439 2451
2440 2452 * IPython/Shell.py (start): I've disabled -wthread and -gthread
2441 2453 for now. They don't really work with standalone WX/GTK code
2442 2454 (though matplotlib IS working fine with both of those backends).
2443 2455 This will neeed much more testing. I disabled most things with
2444 2456 comments, so turning it back on later should be pretty easy.
2445 2457
2446 2458 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
2447 2459 autocalling of expressions like r'foo', by modifying the line
2448 2460 split regexp. Closes
2449 2461 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
2450 2462 Riley <ipythonbugs-AT-sabi.net>.
2451 2463 (InteractiveShell.mainloop): honor --nobanner with banner
2452 2464 extensions.
2453 2465
2454 2466 * IPython/Shell.py: Significant refactoring of all classes, so
2455 2467 that we can really support ALL matplotlib backends and threading
2456 2468 models (John spotted a bug with Tk which required this). Now we
2457 2469 should support single-threaded, WX-threads and GTK-threads, both
2458 2470 for generic code and for matplotlib.
2459 2471
2460 2472 * IPython/ipmaker.py (__call__): Changed -mpthread option to
2461 2473 -pylab, to simplify things for users. Will also remove the pylab
2462 2474 profile, since now all of matplotlib configuration is directly
2463 2475 handled here. This also reduces startup time.
2464 2476
2465 2477 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
2466 2478 shell wasn't being correctly called. Also in IPShellWX.
2467 2479
2468 2480 * IPython/iplib.py (InteractiveShell.__init__): Added option to
2469 2481 fine-tune banner.
2470 2482
2471 2483 * IPython/numutils.py (spike): Deprecate these spike functions,
2472 2484 delete (long deprecated) gnuplot_exec handler.
2473 2485
2474 2486 2004-08-26 Fernando Perez <fperez@colorado.edu>
2475 2487
2476 2488 * ipython.1: Update for threading options, plus some others which
2477 2489 were missing.
2478 2490
2479 2491 * IPython/ipmaker.py (__call__): Added -wthread option for
2480 2492 wxpython thread handling. Make sure threading options are only
2481 2493 valid at the command line.
2482 2494
2483 2495 * scripts/ipython: moved shell selection into a factory function
2484 2496 in Shell.py, to keep the starter script to a minimum.
2485 2497
2486 2498 2004-08-25 Fernando Perez <fperez@colorado.edu>
2487 2499
2488 2500 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
2489 2501 John. Along with some recent changes he made to matplotlib, the
2490 2502 next versions of both systems should work very well together.
2491 2503
2492 2504 2004-08-24 Fernando Perez <fperez@colorado.edu>
2493 2505
2494 2506 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
2495 2507 tried to switch the profiling to using hotshot, but I'm getting
2496 2508 strange errors from prof.runctx() there. I may be misreading the
2497 2509 docs, but it looks weird. For now the profiling code will
2498 2510 continue to use the standard profiler.
2499 2511
2500 2512 2004-08-23 Fernando Perez <fperez@colorado.edu>
2501 2513
2502 2514 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
2503 2515 threaded shell, by John Hunter. It's not quite ready yet, but
2504 2516 close.
2505 2517
2506 2518 2004-08-22 Fernando Perez <fperez@colorado.edu>
2507 2519
2508 2520 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
2509 2521 in Magic and ultraTB.
2510 2522
2511 2523 * ipython.1: document threading options in manpage.
2512 2524
2513 2525 * scripts/ipython: Changed name of -thread option to -gthread,
2514 2526 since this is GTK specific. I want to leave the door open for a
2515 2527 -wthread option for WX, which will most likely be necessary. This
2516 2528 change affects usage and ipmaker as well.
2517 2529
2518 2530 * IPython/Shell.py (matplotlib_shell): Add a factory function to
2519 2531 handle the matplotlib shell issues. Code by John Hunter
2520 2532 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2521 2533 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
2522 2534 broken (and disabled for end users) for now, but it puts the
2523 2535 infrastructure in place.
2524 2536
2525 2537 2004-08-21 Fernando Perez <fperez@colorado.edu>
2526 2538
2527 2539 * ipythonrc-pylab: Add matplotlib support.
2528 2540
2529 2541 * matplotlib_config.py: new files for matplotlib support, part of
2530 2542 the pylab profile.
2531 2543
2532 2544 * IPython/usage.py (__doc__): documented the threading options.
2533 2545
2534 2546 2004-08-20 Fernando Perez <fperez@colorado.edu>
2535 2547
2536 2548 * ipython: Modified the main calling routine to handle the -thread
2537 2549 and -mpthread options. This needs to be done as a top-level hack,
2538 2550 because it determines which class to instantiate for IPython
2539 2551 itself.
2540 2552
2541 2553 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
2542 2554 classes to support multithreaded GTK operation without blocking,
2543 2555 and matplotlib with all backends. This is a lot of still very
2544 2556 experimental code, and threads are tricky. So it may still have a
2545 2557 few rough edges... This code owes a lot to
2546 2558 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
2547 2559 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
2548 2560 to John Hunter for all the matplotlib work.
2549 2561
2550 2562 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
2551 2563 options for gtk thread and matplotlib support.
2552 2564
2553 2565 2004-08-16 Fernando Perez <fperez@colorado.edu>
2554 2566
2555 2567 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
2556 2568 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
2557 2569 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
2558 2570
2559 2571 2004-08-11 Fernando Perez <fperez@colorado.edu>
2560 2572
2561 2573 * setup.py (isfile): Fix build so documentation gets updated for
2562 2574 rpms (it was only done for .tgz builds).
2563 2575
2564 2576 2004-08-10 Fernando Perez <fperez@colorado.edu>
2565 2577
2566 2578 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
2567 2579
2568 2580 * iplib.py : Silence syntax error exceptions in tab-completion.
2569 2581
2570 2582 2004-08-05 Fernando Perez <fperez@colorado.edu>
2571 2583
2572 2584 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
2573 2585 'color off' mark for continuation prompts. This was causing long
2574 2586 continuation lines to mis-wrap.
2575 2587
2576 2588 2004-08-01 Fernando Perez <fperez@colorado.edu>
2577 2589
2578 2590 * IPython/ipmaker.py (make_IPython): Allow the shell class used
2579 2591 for building ipython to be a parameter. All this is necessary
2580 2592 right now to have a multithreaded version, but this insane
2581 2593 non-design will be cleaned up soon. For now, it's a hack that
2582 2594 works.
2583 2595
2584 2596 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
2585 2597 args in various places. No bugs so far, but it's a dangerous
2586 2598 practice.
2587 2599
2588 2600 2004-07-31 Fernando Perez <fperez@colorado.edu>
2589 2601
2590 2602 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
2591 2603 fix completion of files with dots in their names under most
2592 2604 profiles (pysh was OK because the completion order is different).
2593 2605
2594 2606 2004-07-27 Fernando Perez <fperez@colorado.edu>
2595 2607
2596 2608 * IPython/iplib.py (InteractiveShell.__init__): build dict of
2597 2609 keywords manually, b/c the one in keyword.py was removed in python
2598 2610 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
2599 2611 This is NOT a bug under python 2.3 and earlier.
2600 2612
2601 2613 2004-07-26 Fernando Perez <fperez@colorado.edu>
2602 2614
2603 2615 * IPython/ultraTB.py (VerboseTB.text): Add another
2604 2616 linecache.checkcache() call to try to prevent inspect.py from
2605 2617 crashing under python 2.3. I think this fixes
2606 2618 http://www.scipy.net/roundup/ipython/issue17.
2607 2619
2608 2620 2004-07-26 *** Released version 0.6.2
2609 2621
2610 2622 2004-07-26 Fernando Perez <fperez@colorado.edu>
2611 2623
2612 2624 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
2613 2625 fail for any number.
2614 2626 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
2615 2627 empty bookmarks.
2616 2628
2617 2629 2004-07-26 *** Released version 0.6.1
2618 2630
2619 2631 2004-07-26 Fernando Perez <fperez@colorado.edu>
2620 2632
2621 2633 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
2622 2634
2623 2635 * IPython/iplib.py (protect_filename): Applied Ville's patch for
2624 2636 escaping '()[]{}' in filenames.
2625 2637
2626 2638 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
2627 2639 Python 2.2 users who lack a proper shlex.split.
2628 2640
2629 2641 2004-07-19 Fernando Perez <fperez@colorado.edu>
2630 2642
2631 2643 * IPython/iplib.py (InteractiveShell.init_readline): Add support
2632 2644 for reading readline's init file. I follow the normal chain:
2633 2645 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
2634 2646 report by Mike Heeter. This closes
2635 2647 http://www.scipy.net/roundup/ipython/issue16.
2636 2648
2637 2649 2004-07-18 Fernando Perez <fperez@colorado.edu>
2638 2650
2639 2651 * IPython/iplib.py (__init__): Add better handling of '\' under
2640 2652 Win32 for filenames. After a patch by Ville.
2641 2653
2642 2654 2004-07-17 Fernando Perez <fperez@colorado.edu>
2643 2655
2644 2656 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2645 2657 autocalling would be triggered for 'foo is bar' if foo is
2646 2658 callable. I also cleaned up the autocall detection code to use a
2647 2659 regexp, which is faster. Bug reported by Alexander Schmolck.
2648 2660
2649 2661 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
2650 2662 '?' in them would confuse the help system. Reported by Alex
2651 2663 Schmolck.
2652 2664
2653 2665 2004-07-16 Fernando Perez <fperez@colorado.edu>
2654 2666
2655 2667 * IPython/GnuplotInteractive.py (__all__): added plot2.
2656 2668
2657 2669 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
2658 2670 plotting dictionaries, lists or tuples of 1d arrays.
2659 2671
2660 2672 * IPython/Magic.py (Magic.magic_hist): small clenaups and
2661 2673 optimizations.
2662 2674
2663 2675 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
2664 2676 the information which was there from Janko's original IPP code:
2665 2677
2666 2678 03.05.99 20:53 porto.ifm.uni-kiel.de
2667 2679 --Started changelog.
2668 2680 --make clear do what it say it does
2669 2681 --added pretty output of lines from inputcache
2670 2682 --Made Logger a mixin class, simplifies handling of switches
2671 2683 --Added own completer class. .string<TAB> expands to last history
2672 2684 line which starts with string. The new expansion is also present
2673 2685 with Ctrl-r from the readline library. But this shows, who this
2674 2686 can be done for other cases.
2675 2687 --Added convention that all shell functions should accept a
2676 2688 parameter_string This opens the door for different behaviour for
2677 2689 each function. @cd is a good example of this.
2678 2690
2679 2691 04.05.99 12:12 porto.ifm.uni-kiel.de
2680 2692 --added logfile rotation
2681 2693 --added new mainloop method which freezes first the namespace
2682 2694
2683 2695 07.05.99 21:24 porto.ifm.uni-kiel.de
2684 2696 --added the docreader classes. Now there is a help system.
2685 2697 -This is only a first try. Currently it's not easy to put new
2686 2698 stuff in the indices. But this is the way to go. Info would be
2687 2699 better, but HTML is every where and not everybody has an info
2688 2700 system installed and it's not so easy to change html-docs to info.
2689 2701 --added global logfile option
2690 2702 --there is now a hook for object inspection method pinfo needs to
2691 2703 be provided for this. Can be reached by two '??'.
2692 2704
2693 2705 08.05.99 20:51 porto.ifm.uni-kiel.de
2694 2706 --added a README
2695 2707 --bug in rc file. Something has changed so functions in the rc
2696 2708 file need to reference the shell and not self. Not clear if it's a
2697 2709 bug or feature.
2698 2710 --changed rc file for new behavior
2699 2711
2700 2712 2004-07-15 Fernando Perez <fperez@colorado.edu>
2701 2713
2702 2714 * IPython/Logger.py (Logger.log): fixed recent bug where the input
2703 2715 cache was falling out of sync in bizarre manners when multi-line
2704 2716 input was present. Minor optimizations and cleanup.
2705 2717
2706 2718 (Logger): Remove old Changelog info for cleanup. This is the
2707 2719 information which was there from Janko's original code:
2708 2720
2709 2721 Changes to Logger: - made the default log filename a parameter
2710 2722
2711 2723 - put a check for lines beginning with !@? in log(). Needed
2712 2724 (even if the handlers properly log their lines) for mid-session
2713 2725 logging activation to work properly. Without this, lines logged
2714 2726 in mid session, which get read from the cache, would end up
2715 2727 'bare' (with !@? in the open) in the log. Now they are caught
2716 2728 and prepended with a #.
2717 2729
2718 2730 * IPython/iplib.py (InteractiveShell.init_readline): added check
2719 2731 in case MagicCompleter fails to be defined, so we don't crash.
2720 2732
2721 2733 2004-07-13 Fernando Perez <fperez@colorado.edu>
2722 2734
2723 2735 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
2724 2736 of EPS if the requested filename ends in '.eps'.
2725 2737
2726 2738 2004-07-04 Fernando Perez <fperez@colorado.edu>
2727 2739
2728 2740 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
2729 2741 escaping of quotes when calling the shell.
2730 2742
2731 2743 2004-07-02 Fernando Perez <fperez@colorado.edu>
2732 2744
2733 2745 * IPython/Prompts.py (CachedOutput.update): Fix problem with
2734 2746 gettext not working because we were clobbering '_'. Fixes
2735 2747 http://www.scipy.net/roundup/ipython/issue6.
2736 2748
2737 2749 2004-07-01 Fernando Perez <fperez@colorado.edu>
2738 2750
2739 2751 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
2740 2752 into @cd. Patch by Ville.
2741 2753
2742 2754 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2743 2755 new function to store things after ipmaker runs. Patch by Ville.
2744 2756 Eventually this will go away once ipmaker is removed and the class
2745 2757 gets cleaned up, but for now it's ok. Key functionality here is
2746 2758 the addition of the persistent storage mechanism, a dict for
2747 2759 keeping data across sessions (for now just bookmarks, but more can
2748 2760 be implemented later).
2749 2761
2750 2762 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
2751 2763 persistent across sections. Patch by Ville, I modified it
2752 2764 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
2753 2765 added a '-l' option to list all bookmarks.
2754 2766
2755 2767 * IPython/iplib.py (InteractiveShell.atexit_operations): new
2756 2768 center for cleanup. Registered with atexit.register(). I moved
2757 2769 here the old exit_cleanup(). After a patch by Ville.
2758 2770
2759 2771 * IPython/Magic.py (get_py_filename): added '~' to the accepted
2760 2772 characters in the hacked shlex_split for python 2.2.
2761 2773
2762 2774 * IPython/iplib.py (file_matches): more fixes to filenames with
2763 2775 whitespace in them. It's not perfect, but limitations in python's
2764 2776 readline make it impossible to go further.
2765 2777
2766 2778 2004-06-29 Fernando Perez <fperez@colorado.edu>
2767 2779
2768 2780 * IPython/iplib.py (file_matches): escape whitespace correctly in
2769 2781 filename completions. Bug reported by Ville.
2770 2782
2771 2783 2004-06-28 Fernando Perez <fperez@colorado.edu>
2772 2784
2773 2785 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
2774 2786 the history file will be called 'history-PROFNAME' (or just
2775 2787 'history' if no profile is loaded). I was getting annoyed at
2776 2788 getting my Numerical work history clobbered by pysh sessions.
2777 2789
2778 2790 * IPython/iplib.py (InteractiveShell.__init__): Internal
2779 2791 getoutputerror() function so that we can honor the system_verbose
2780 2792 flag for _all_ system calls. I also added escaping of #
2781 2793 characters here to avoid confusing Itpl.
2782 2794
2783 2795 * IPython/Magic.py (shlex_split): removed call to shell in
2784 2796 parse_options and replaced it with shlex.split(). The annoying
2785 2797 part was that in Python 2.2, shlex.split() doesn't exist, so I had
2786 2798 to backport it from 2.3, with several frail hacks (the shlex
2787 2799 module is rather limited in 2.2). Thanks to a suggestion by Ville
2788 2800 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
2789 2801 problem.
2790 2802
2791 2803 (Magic.magic_system_verbose): new toggle to print the actual
2792 2804 system calls made by ipython. Mainly for debugging purposes.
2793 2805
2794 2806 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
2795 2807 doesn't support persistence. Reported (and fix suggested) by
2796 2808 Travis Caldwell <travis_caldwell2000@yahoo.com>.
2797 2809
2798 2810 2004-06-26 Fernando Perez <fperez@colorado.edu>
2799 2811
2800 2812 * IPython/Logger.py (Logger.log): fix to handle correctly empty
2801 2813 continue prompts.
2802 2814
2803 2815 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
2804 2816 function (basically a big docstring) and a few more things here to
2805 2817 speedup startup. pysh.py is now very lightweight. We want because
2806 2818 it gets execfile'd, while InterpreterExec gets imported, so
2807 2819 byte-compilation saves time.
2808 2820
2809 2821 2004-06-25 Fernando Perez <fperez@colorado.edu>
2810 2822
2811 2823 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
2812 2824 -NUM', which was recently broken.
2813 2825
2814 2826 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
2815 2827 in multi-line input (but not !!, which doesn't make sense there).
2816 2828
2817 2829 * IPython/UserConfig/ipythonrc: made autoindent on by default.
2818 2830 It's just too useful, and people can turn it off in the less
2819 2831 common cases where it's a problem.
2820 2832
2821 2833 2004-06-24 Fernando Perez <fperez@colorado.edu>
2822 2834
2823 2835 * IPython/iplib.py (InteractiveShell._prefilter): big change -
2824 2836 special syntaxes (like alias calling) is now allied in multi-line
2825 2837 input. This is still _very_ experimental, but it's necessary for
2826 2838 efficient shell usage combining python looping syntax with system
2827 2839 calls. For now it's restricted to aliases, I don't think it
2828 2840 really even makes sense to have this for magics.
2829 2841
2830 2842 2004-06-23 Fernando Perez <fperez@colorado.edu>
2831 2843
2832 2844 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
2833 2845 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
2834 2846
2835 2847 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
2836 2848 extensions under Windows (after code sent by Gary Bishop). The
2837 2849 extensions considered 'executable' are stored in IPython's rc
2838 2850 structure as win_exec_ext.
2839 2851
2840 2852 * IPython/genutils.py (shell): new function, like system() but
2841 2853 without return value. Very useful for interactive shell work.
2842 2854
2843 2855 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
2844 2856 delete aliases.
2845 2857
2846 2858 * IPython/iplib.py (InteractiveShell.alias_table_update): make
2847 2859 sure that the alias table doesn't contain python keywords.
2848 2860
2849 2861 2004-06-21 Fernando Perez <fperez@colorado.edu>
2850 2862
2851 2863 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
2852 2864 non-existent items are found in $PATH. Reported by Thorsten.
2853 2865
2854 2866 2004-06-20 Fernando Perez <fperez@colorado.edu>
2855 2867
2856 2868 * IPython/iplib.py (complete): modified the completer so that the
2857 2869 order of priorities can be easily changed at runtime.
2858 2870
2859 2871 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
2860 2872 Modified to auto-execute all lines beginning with '~', '/' or '.'.
2861 2873
2862 2874 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
2863 2875 expand Python variables prepended with $ in all system calls. The
2864 2876 same was done to InteractiveShell.handle_shell_escape. Now all
2865 2877 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
2866 2878 expansion of python variables and expressions according to the
2867 2879 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
2868 2880
2869 2881 Though PEP-215 has been rejected, a similar (but simpler) one
2870 2882 seems like it will go into Python 2.4, PEP-292 -
2871 2883 http://www.python.org/peps/pep-0292.html.
2872 2884
2873 2885 I'll keep the full syntax of PEP-215, since IPython has since the
2874 2886 start used Ka-Ping Yee's reference implementation discussed there
2875 2887 (Itpl), and I actually like the powerful semantics it offers.
2876 2888
2877 2889 In order to access normal shell variables, the $ has to be escaped
2878 2890 via an extra $. For example:
2879 2891
2880 2892 In [7]: PATH='a python variable'
2881 2893
2882 2894 In [8]: !echo $PATH
2883 2895 a python variable
2884 2896
2885 2897 In [9]: !echo $$PATH
2886 2898 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2887 2899
2888 2900 (Magic.parse_options): escape $ so the shell doesn't evaluate
2889 2901 things prematurely.
2890 2902
2891 2903 * IPython/iplib.py (InteractiveShell.call_alias): added the
2892 2904 ability for aliases to expand python variables via $.
2893 2905
2894 2906 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
2895 2907 system, now there's a @rehash/@rehashx pair of magics. These work
2896 2908 like the csh rehash command, and can be invoked at any time. They
2897 2909 build a table of aliases to everything in the user's $PATH
2898 2910 (@rehash uses everything, @rehashx is slower but only adds
2899 2911 executable files). With this, the pysh.py-based shell profile can
2900 2912 now simply call rehash upon startup, and full access to all
2901 2913 programs in the user's path is obtained.
2902 2914
2903 2915 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
2904 2916 functionality is now fully in place. I removed the old dynamic
2905 2917 code generation based approach, in favor of a much lighter one
2906 2918 based on a simple dict. The advantage is that this allows me to
2907 2919 now have thousands of aliases with negligible cost (unthinkable
2908 2920 with the old system).
2909 2921
2910 2922 2004-06-19 Fernando Perez <fperez@colorado.edu>
2911 2923
2912 2924 * IPython/iplib.py (__init__): extended MagicCompleter class to
2913 2925 also complete (last in priority) on user aliases.
2914 2926
2915 2927 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
2916 2928 call to eval.
2917 2929 (ItplNS.__init__): Added a new class which functions like Itpl,
2918 2930 but allows configuring the namespace for the evaluation to occur
2919 2931 in.
2920 2932
2921 2933 2004-06-18 Fernando Perez <fperez@colorado.edu>
2922 2934
2923 2935 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
2924 2936 better message when 'exit' or 'quit' are typed (a common newbie
2925 2937 confusion).
2926 2938
2927 2939 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
2928 2940 check for Windows users.
2929 2941
2930 2942 * IPython/iplib.py (InteractiveShell.user_setup): removed
2931 2943 disabling of colors for Windows. I'll test at runtime and issue a
2932 2944 warning if Gary's readline isn't found, as to nudge users to
2933 2945 download it.
2934 2946
2935 2947 2004-06-16 Fernando Perez <fperez@colorado.edu>
2936 2948
2937 2949 * IPython/genutils.py (Stream.__init__): changed to print errors
2938 2950 to sys.stderr. I had a circular dependency here. Now it's
2939 2951 possible to run ipython as IDLE's shell (consider this pre-alpha,
2940 2952 since true stdout things end up in the starting terminal instead
2941 2953 of IDLE's out).
2942 2954
2943 2955 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
2944 2956 users who haven't # updated their prompt_in2 definitions. Remove
2945 2957 eventually.
2946 2958 (multiple_replace): added credit to original ASPN recipe.
2947 2959
2948 2960 2004-06-15 Fernando Perez <fperez@colorado.edu>
2949 2961
2950 2962 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
2951 2963 list of auto-defined aliases.
2952 2964
2953 2965 2004-06-13 Fernando Perez <fperez@colorado.edu>
2954 2966
2955 2967 * setup.py (scriptfiles): Don't trigger win_post_install unless an
2956 2968 install was really requested (so setup.py can be used for other
2957 2969 things under Windows).
2958 2970
2959 2971 2004-06-10 Fernando Perez <fperez@colorado.edu>
2960 2972
2961 2973 * IPython/Logger.py (Logger.create_log): Manually remove any old
2962 2974 backup, since os.remove may fail under Windows. Fixes bug
2963 2975 reported by Thorsten.
2964 2976
2965 2977 2004-06-09 Fernando Perez <fperez@colorado.edu>
2966 2978
2967 2979 * examples/example-embed.py: fixed all references to %n (replaced
2968 2980 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
2969 2981 for all examples and the manual as well.
2970 2982
2971 2983 2004-06-08 Fernando Perez <fperez@colorado.edu>
2972 2984
2973 2985 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2974 2986 alignment and color management. All 3 prompt subsystems now
2975 2987 inherit from BasePrompt.
2976 2988
2977 2989 * tools/release: updates for windows installer build and tag rpms
2978 2990 with python version (since paths are fixed).
2979 2991
2980 2992 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2981 2993 which will become eventually obsolete. Also fixed the default
2982 2994 prompt_in2 to use \D, so at least new users start with the correct
2983 2995 defaults.
2984 2996 WARNING: Users with existing ipythonrc files will need to apply
2985 2997 this fix manually!
2986 2998
2987 2999 * setup.py: make windows installer (.exe). This is finally the
2988 3000 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2989 3001 which I hadn't included because it required Python 2.3 (or recent
2990 3002 distutils).
2991 3003
2992 3004 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2993 3005 usage of new '\D' escape.
2994 3006
2995 3007 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2996 3008 lacks os.getuid())
2997 3009 (CachedOutput.set_colors): Added the ability to turn coloring
2998 3010 on/off with @colors even for manually defined prompt colors. It
2999 3011 uses a nasty global, but it works safely and via the generic color
3000 3012 handling mechanism.
3001 3013 (Prompt2.__init__): Introduced new escape '\D' for continuation
3002 3014 prompts. It represents the counter ('\#') as dots.
3003 3015 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3004 3016 need to update their ipythonrc files and replace '%n' with '\D' in
3005 3017 their prompt_in2 settings everywhere. Sorry, but there's
3006 3018 otherwise no clean way to get all prompts to properly align. The
3007 3019 ipythonrc shipped with IPython has been updated.
3008 3020
3009 3021 2004-06-07 Fernando Perez <fperez@colorado.edu>
3010 3022
3011 3023 * setup.py (isfile): Pass local_icons option to latex2html, so the
3012 3024 resulting HTML file is self-contained. Thanks to
3013 3025 dryice-AT-liu.com.cn for the tip.
3014 3026
3015 3027 * pysh.py: I created a new profile 'shell', which implements a
3016 3028 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3017 3029 system shell, nor will it become one anytime soon. It's mainly
3018 3030 meant to illustrate the use of the new flexible bash-like prompts.
3019 3031 I guess it could be used by hardy souls for true shell management,
3020 3032 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3021 3033 profile. This uses the InterpreterExec extension provided by
3022 3034 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3023 3035
3024 3036 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3025 3037 auto-align itself with the length of the previous input prompt
3026 3038 (taking into account the invisible color escapes).
3027 3039 (CachedOutput.__init__): Large restructuring of this class. Now
3028 3040 all three prompts (primary1, primary2, output) are proper objects,
3029 3041 managed by the 'parent' CachedOutput class. The code is still a
3030 3042 bit hackish (all prompts share state via a pointer to the cache),
3031 3043 but it's overall far cleaner than before.
3032 3044
3033 3045 * IPython/genutils.py (getoutputerror): modified to add verbose,
3034 3046 debug and header options. This makes the interface of all getout*
3035 3047 functions uniform.
3036 3048 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3037 3049
3038 3050 * IPython/Magic.py (Magic.default_option): added a function to
3039 3051 allow registering default options for any magic command. This
3040 3052 makes it easy to have profiles which customize the magics globally
3041 3053 for a certain use. The values set through this function are
3042 3054 picked up by the parse_options() method, which all magics should
3043 3055 use to parse their options.
3044 3056
3045 3057 * IPython/genutils.py (warn): modified the warnings framework to
3046 3058 use the Term I/O class. I'm trying to slowly unify all of
3047 3059 IPython's I/O operations to pass through Term.
3048 3060
3049 3061 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3050 3062 the secondary prompt to correctly match the length of the primary
3051 3063 one for any prompt. Now multi-line code will properly line up
3052 3064 even for path dependent prompts, such as the new ones available
3053 3065 via the prompt_specials.
3054 3066
3055 3067 2004-06-06 Fernando Perez <fperez@colorado.edu>
3056 3068
3057 3069 * IPython/Prompts.py (prompt_specials): Added the ability to have
3058 3070 bash-like special sequences in the prompts, which get
3059 3071 automatically expanded. Things like hostname, current working
3060 3072 directory and username are implemented already, but it's easy to
3061 3073 add more in the future. Thanks to a patch by W.J. van der Laan
3062 3074 <gnufnork-AT-hetdigitalegat.nl>
3063 3075 (prompt_specials): Added color support for prompt strings, so
3064 3076 users can define arbitrary color setups for their prompts.
3065 3077
3066 3078 2004-06-05 Fernando Perez <fperez@colorado.edu>
3067 3079
3068 3080 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3069 3081 code to load Gary Bishop's readline and configure it
3070 3082 automatically. Thanks to Gary for help on this.
3071 3083
3072 3084 2004-06-01 Fernando Perez <fperez@colorado.edu>
3073 3085
3074 3086 * IPython/Logger.py (Logger.create_log): fix bug for logging
3075 3087 with no filename (previous fix was incomplete).
3076 3088
3077 3089 2004-05-25 Fernando Perez <fperez@colorado.edu>
3078 3090
3079 3091 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3080 3092 parens would get passed to the shell.
3081 3093
3082 3094 2004-05-20 Fernando Perez <fperez@colorado.edu>
3083 3095
3084 3096 * IPython/Magic.py (Magic.magic_prun): changed default profile
3085 3097 sort order to 'time' (the more common profiling need).
3086 3098
3087 3099 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3088 3100 so that source code shown is guaranteed in sync with the file on
3089 3101 disk (also changed in psource). Similar fix to the one for
3090 3102 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3091 3103 <yann.ledu-AT-noos.fr>.
3092 3104
3093 3105 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3094 3106 with a single option would not be correctly parsed. Closes
3095 3107 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3096 3108 introduced in 0.6.0 (on 2004-05-06).
3097 3109
3098 3110 2004-05-13 *** Released version 0.6.0
3099 3111
3100 3112 2004-05-13 Fernando Perez <fperez@colorado.edu>
3101 3113
3102 3114 * debian/: Added debian/ directory to CVS, so that debian support
3103 3115 is publicly accessible. The debian package is maintained by Jack
3104 3116 Moffit <jack-AT-xiph.org>.
3105 3117
3106 3118 * Documentation: included the notes about an ipython-based system
3107 3119 shell (the hypothetical 'pysh') into the new_design.pdf document,
3108 3120 so that these ideas get distributed to users along with the
3109 3121 official documentation.
3110 3122
3111 3123 2004-05-10 Fernando Perez <fperez@colorado.edu>
3112 3124
3113 3125 * IPython/Logger.py (Logger.create_log): fix recently introduced
3114 3126 bug (misindented line) where logstart would fail when not given an
3115 3127 explicit filename.
3116 3128
3117 3129 2004-05-09 Fernando Perez <fperez@colorado.edu>
3118 3130
3119 3131 * IPython/Magic.py (Magic.parse_options): skip system call when
3120 3132 there are no options to look for. Faster, cleaner for the common
3121 3133 case.
3122 3134
3123 3135 * Documentation: many updates to the manual: describing Windows
3124 3136 support better, Gnuplot updates, credits, misc small stuff. Also
3125 3137 updated the new_design doc a bit.
3126 3138
3127 3139 2004-05-06 *** Released version 0.6.0.rc1
3128 3140
3129 3141 2004-05-06 Fernando Perez <fperez@colorado.edu>
3130 3142
3131 3143 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3132 3144 operations to use the vastly more efficient list/''.join() method.
3133 3145 (FormattedTB.text): Fix
3134 3146 http://www.scipy.net/roundup/ipython/issue12 - exception source
3135 3147 extract not updated after reload. Thanks to Mike Salib
3136 3148 <msalib-AT-mit.edu> for pinning the source of the problem.
3137 3149 Fortunately, the solution works inside ipython and doesn't require
3138 3150 any changes to python proper.
3139 3151
3140 3152 * IPython/Magic.py (Magic.parse_options): Improved to process the
3141 3153 argument list as a true shell would (by actually using the
3142 3154 underlying system shell). This way, all @magics automatically get
3143 3155 shell expansion for variables. Thanks to a comment by Alex
3144 3156 Schmolck.
3145 3157
3146 3158 2004-04-04 Fernando Perez <fperez@colorado.edu>
3147 3159
3148 3160 * IPython/iplib.py (InteractiveShell.interact): Added a special
3149 3161 trap for a debugger quit exception, which is basically impossible
3150 3162 to handle by normal mechanisms, given what pdb does to the stack.
3151 3163 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3152 3164
3153 3165 2004-04-03 Fernando Perez <fperez@colorado.edu>
3154 3166
3155 3167 * IPython/genutils.py (Term): Standardized the names of the Term
3156 3168 class streams to cin/cout/cerr, following C++ naming conventions
3157 3169 (I can't use in/out/err because 'in' is not a valid attribute
3158 3170 name).
3159 3171
3160 3172 * IPython/iplib.py (InteractiveShell.interact): don't increment
3161 3173 the prompt if there's no user input. By Daniel 'Dang' Griffith
3162 3174 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3163 3175 Francois Pinard.
3164 3176
3165 3177 2004-04-02 Fernando Perez <fperez@colorado.edu>
3166 3178
3167 3179 * IPython/genutils.py (Stream.__init__): Modified to survive at
3168 3180 least importing in contexts where stdin/out/err aren't true file
3169 3181 objects, such as PyCrust (they lack fileno() and mode). However,
3170 3182 the recovery facilities which rely on these things existing will
3171 3183 not work.
3172 3184
3173 3185 2004-04-01 Fernando Perez <fperez@colorado.edu>
3174 3186
3175 3187 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3176 3188 use the new getoutputerror() function, so it properly
3177 3189 distinguishes stdout/err.
3178 3190
3179 3191 * IPython/genutils.py (getoutputerror): added a function to
3180 3192 capture separately the standard output and error of a command.
3181 3193 After a comment from dang on the mailing lists. This code is
3182 3194 basically a modified version of commands.getstatusoutput(), from
3183 3195 the standard library.
3184 3196
3185 3197 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3186 3198 '!!' as a special syntax (shorthand) to access @sx.
3187 3199
3188 3200 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3189 3201 command and return its output as a list split on '\n'.
3190 3202
3191 3203 2004-03-31 Fernando Perez <fperez@colorado.edu>
3192 3204
3193 3205 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3194 3206 method to dictionaries used as FakeModule instances if they lack
3195 3207 it. At least pydoc in python2.3 breaks for runtime-defined
3196 3208 functions without this hack. At some point I need to _really_
3197 3209 understand what FakeModule is doing, because it's a gross hack.
3198 3210 But it solves Arnd's problem for now...
3199 3211
3200 3212 2004-02-27 Fernando Perez <fperez@colorado.edu>
3201 3213
3202 3214 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3203 3215 mode would behave erratically. Also increased the number of
3204 3216 possible logs in rotate mod to 999. Thanks to Rod Holland
3205 3217 <rhh@StructureLABS.com> for the report and fixes.
3206 3218
3207 3219 2004-02-26 Fernando Perez <fperez@colorado.edu>
3208 3220
3209 3221 * IPython/genutils.py (page): Check that the curses module really
3210 3222 has the initscr attribute before trying to use it. For some
3211 3223 reason, the Solaris curses module is missing this. I think this
3212 3224 should be considered a Solaris python bug, but I'm not sure.
3213 3225
3214 3226 2004-01-17 Fernando Perez <fperez@colorado.edu>
3215 3227
3216 3228 * IPython/genutils.py (Stream.__init__): Changes to try to make
3217 3229 ipython robust against stdin/out/err being closed by the user.
3218 3230 This is 'user error' (and blocks a normal python session, at least
3219 3231 the stdout case). However, Ipython should be able to survive such
3220 3232 instances of abuse as gracefully as possible. To simplify the
3221 3233 coding and maintain compatibility with Gary Bishop's Term
3222 3234 contributions, I've made use of classmethods for this. I think
3223 3235 this introduces a dependency on python 2.2.
3224 3236
3225 3237 2004-01-13 Fernando Perez <fperez@colorado.edu>
3226 3238
3227 3239 * IPython/numutils.py (exp_safe): simplified the code a bit and
3228 3240 removed the need for importing the kinds module altogether.
3229 3241
3230 3242 2004-01-06 Fernando Perez <fperez@colorado.edu>
3231 3243
3232 3244 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3233 3245 a magic function instead, after some community feedback. No
3234 3246 special syntax will exist for it, but its name is deliberately
3235 3247 very short.
3236 3248
3237 3249 2003-12-20 Fernando Perez <fperez@colorado.edu>
3238 3250
3239 3251 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3240 3252 new functionality, to automagically assign the result of a shell
3241 3253 command to a variable. I'll solicit some community feedback on
3242 3254 this before making it permanent.
3243 3255
3244 3256 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3245 3257 requested about callables for which inspect couldn't obtain a
3246 3258 proper argspec. Thanks to a crash report sent by Etienne
3247 3259 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3248 3260
3249 3261 2003-12-09 Fernando Perez <fperez@colorado.edu>
3250 3262
3251 3263 * IPython/genutils.py (page): patch for the pager to work across
3252 3264 various versions of Windows. By Gary Bishop.
3253 3265
3254 3266 2003-12-04 Fernando Perez <fperez@colorado.edu>
3255 3267
3256 3268 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3257 3269 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3258 3270 While I tested this and it looks ok, there may still be corner
3259 3271 cases I've missed.
3260 3272
3261 3273 2003-12-01 Fernando Perez <fperez@colorado.edu>
3262 3274
3263 3275 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3264 3276 where a line like 'p,q=1,2' would fail because the automagic
3265 3277 system would be triggered for @p.
3266 3278
3267 3279 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3268 3280 cleanups, code unmodified.
3269 3281
3270 3282 * IPython/genutils.py (Term): added a class for IPython to handle
3271 3283 output. In most cases it will just be a proxy for stdout/err, but
3272 3284 having this allows modifications to be made for some platforms,
3273 3285 such as handling color escapes under Windows. All of this code
3274 3286 was contributed by Gary Bishop, with minor modifications by me.
3275 3287 The actual changes affect many files.
3276 3288
3277 3289 2003-11-30 Fernando Perez <fperez@colorado.edu>
3278 3290
3279 3291 * IPython/iplib.py (file_matches): new completion code, courtesy
3280 3292 of Jeff Collins. This enables filename completion again under
3281 3293 python 2.3, which disabled it at the C level.
3282 3294
3283 3295 2003-11-11 Fernando Perez <fperez@colorado.edu>
3284 3296
3285 3297 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3286 3298 for Numeric.array(map(...)), but often convenient.
3287 3299
3288 3300 2003-11-05 Fernando Perez <fperez@colorado.edu>
3289 3301
3290 3302 * IPython/numutils.py (frange): Changed a call from int() to
3291 3303 int(round()) to prevent a problem reported with arange() in the
3292 3304 numpy list.
3293 3305
3294 3306 2003-10-06 Fernando Perez <fperez@colorado.edu>
3295 3307
3296 3308 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3297 3309 prevent crashes if sys lacks an argv attribute (it happens with
3298 3310 embedded interpreters which build a bare-bones sys module).
3299 3311 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3300 3312
3301 3313 2003-09-24 Fernando Perez <fperez@colorado.edu>
3302 3314
3303 3315 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
3304 3316 to protect against poorly written user objects where __getattr__
3305 3317 raises exceptions other than AttributeError. Thanks to a bug
3306 3318 report by Oliver Sander <osander-AT-gmx.de>.
3307 3319
3308 3320 * IPython/FakeModule.py (FakeModule.__repr__): this method was
3309 3321 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
3310 3322
3311 3323 2003-09-09 Fernando Perez <fperez@colorado.edu>
3312 3324
3313 3325 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3314 3326 unpacking a list whith a callable as first element would
3315 3327 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
3316 3328 Collins.
3317 3329
3318 3330 2003-08-25 *** Released version 0.5.0
3319 3331
3320 3332 2003-08-22 Fernando Perez <fperez@colorado.edu>
3321 3333
3322 3334 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
3323 3335 improperly defined user exceptions. Thanks to feedback from Mark
3324 3336 Russell <mrussell-AT-verio.net>.
3325 3337
3326 3338 2003-08-20 Fernando Perez <fperez@colorado.edu>
3327 3339
3328 3340 * IPython/OInspect.py (Inspector.pinfo): changed String Form
3329 3341 printing so that it would print multi-line string forms starting
3330 3342 with a new line. This way the formatting is better respected for
3331 3343 objects which work hard to make nice string forms.
3332 3344
3333 3345 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
3334 3346 autocall would overtake data access for objects with both
3335 3347 __getitem__ and __call__.
3336 3348
3337 3349 2003-08-19 *** Released version 0.5.0-rc1
3338 3350
3339 3351 2003-08-19 Fernando Perez <fperez@colorado.edu>
3340 3352
3341 3353 * IPython/deep_reload.py (load_tail): single tiny change here
3342 3354 seems to fix the long-standing bug of dreload() failing to work
3343 3355 for dotted names. But this module is pretty tricky, so I may have
3344 3356 missed some subtlety. Needs more testing!.
3345 3357
3346 3358 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
3347 3359 exceptions which have badly implemented __str__ methods.
3348 3360 (VerboseTB.text): harden against inspect.getinnerframes crashing,
3349 3361 which I've been getting reports about from Python 2.3 users. I
3350 3362 wish I had a simple test case to reproduce the problem, so I could
3351 3363 either write a cleaner workaround or file a bug report if
3352 3364 necessary.
3353 3365
3354 3366 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
3355 3367 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
3356 3368 a bug report by Tjabo Kloppenburg.
3357 3369
3358 3370 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
3359 3371 crashes. Wrapped the pdb call in a blanket try/except, since pdb
3360 3372 seems rather unstable. Thanks to a bug report by Tjabo
3361 3373 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
3362 3374
3363 3375 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
3364 3376 this out soon because of the critical fixes in the inner loop for
3365 3377 generators.
3366 3378
3367 3379 * IPython/Magic.py (Magic.getargspec): removed. This (and
3368 3380 _get_def) have been obsoleted by OInspect for a long time, I
3369 3381 hadn't noticed that they were dead code.
3370 3382 (Magic._ofind): restored _ofind functionality for a few literals
3371 3383 (those in ["''",'""','[]','{}','()']). But it won't work anymore
3372 3384 for things like "hello".capitalize?, since that would require a
3373 3385 potentially dangerous eval() again.
3374 3386
3375 3387 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
3376 3388 logic a bit more to clean up the escapes handling and minimize the
3377 3389 use of _ofind to only necessary cases. The interactive 'feel' of
3378 3390 IPython should have improved quite a bit with the changes in
3379 3391 _prefilter and _ofind (besides being far safer than before).
3380 3392
3381 3393 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
3382 3394 obscure, never reported). Edit would fail to find the object to
3383 3395 edit under some circumstances.
3384 3396 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
3385 3397 which were causing double-calling of generators. Those eval calls
3386 3398 were _very_ dangerous, since code with side effects could be
3387 3399 triggered. As they say, 'eval is evil'... These were the
3388 3400 nastiest evals in IPython. Besides, _ofind is now far simpler,
3389 3401 and it should also be quite a bit faster. Its use of inspect is
3390 3402 also safer, so perhaps some of the inspect-related crashes I've
3391 3403 seen lately with Python 2.3 might be taken care of. That will
3392 3404 need more testing.
3393 3405
3394 3406 2003-08-17 Fernando Perez <fperez@colorado.edu>
3395 3407
3396 3408 * IPython/iplib.py (InteractiveShell._prefilter): significant
3397 3409 simplifications to the logic for handling user escapes. Faster
3398 3410 and simpler code.
3399 3411
3400 3412 2003-08-14 Fernando Perez <fperez@colorado.edu>
3401 3413
3402 3414 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
3403 3415 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
3404 3416 but it should be quite a bit faster. And the recursive version
3405 3417 generated O(log N) intermediate storage for all rank>1 arrays,
3406 3418 even if they were contiguous.
3407 3419 (l1norm): Added this function.
3408 3420 (norm): Added this function for arbitrary norms (including
3409 3421 l-infinity). l1 and l2 are still special cases for convenience
3410 3422 and speed.
3411 3423
3412 3424 2003-08-03 Fernando Perez <fperez@colorado.edu>
3413 3425
3414 3426 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
3415 3427 exceptions, which now raise PendingDeprecationWarnings in Python
3416 3428 2.3. There were some in Magic and some in Gnuplot2.
3417 3429
3418 3430 2003-06-30 Fernando Perez <fperez@colorado.edu>
3419 3431
3420 3432 * IPython/genutils.py (page): modified to call curses only for
3421 3433 terminals where TERM=='xterm'. After problems under many other
3422 3434 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
3423 3435
3424 3436 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
3425 3437 would be triggered when readline was absent. This was just an old
3426 3438 debugging statement I'd forgotten to take out.
3427 3439
3428 3440 2003-06-20 Fernando Perez <fperez@colorado.edu>
3429 3441
3430 3442 * IPython/genutils.py (clock): modified to return only user time
3431 3443 (not counting system time), after a discussion on scipy. While
3432 3444 system time may be a useful quantity occasionally, it may much
3433 3445 more easily be skewed by occasional swapping or other similar
3434 3446 activity.
3435 3447
3436 3448 2003-06-05 Fernando Perez <fperez@colorado.edu>
3437 3449
3438 3450 * IPython/numutils.py (identity): new function, for building
3439 3451 arbitrary rank Kronecker deltas (mostly backwards compatible with
3440 3452 Numeric.identity)
3441 3453
3442 3454 2003-06-03 Fernando Perez <fperez@colorado.edu>
3443 3455
3444 3456 * IPython/iplib.py (InteractiveShell.handle_magic): protect
3445 3457 arguments passed to magics with spaces, to allow trailing '\' to
3446 3458 work normally (mainly for Windows users).
3447 3459
3448 3460 2003-05-29 Fernando Perez <fperez@colorado.edu>
3449 3461
3450 3462 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
3451 3463 instead of pydoc.help. This fixes a bizarre behavior where
3452 3464 printing '%s' % locals() would trigger the help system. Now
3453 3465 ipython behaves like normal python does.
3454 3466
3455 3467 Note that if one does 'from pydoc import help', the bizarre
3456 3468 behavior returns, but this will also happen in normal python, so
3457 3469 it's not an ipython bug anymore (it has to do with how pydoc.help
3458 3470 is implemented).
3459 3471
3460 3472 2003-05-22 Fernando Perez <fperez@colorado.edu>
3461 3473
3462 3474 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
3463 3475 return [] instead of None when nothing matches, also match to end
3464 3476 of line. Patch by Gary Bishop.
3465 3477
3466 3478 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
3467 3479 protection as before, for files passed on the command line. This
3468 3480 prevents the CrashHandler from kicking in if user files call into
3469 3481 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
3470 3482 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
3471 3483
3472 3484 2003-05-20 *** Released version 0.4.0
3473 3485
3474 3486 2003-05-20 Fernando Perez <fperez@colorado.edu>
3475 3487
3476 3488 * setup.py: added support for manpages. It's a bit hackish b/c of
3477 3489 a bug in the way the bdist_rpm distutils target handles gzipped
3478 3490 manpages, but it works. After a patch by Jack.
3479 3491
3480 3492 2003-05-19 Fernando Perez <fperez@colorado.edu>
3481 3493
3482 3494 * IPython/numutils.py: added a mockup of the kinds module, since
3483 3495 it was recently removed from Numeric. This way, numutils will
3484 3496 work for all users even if they are missing kinds.
3485 3497
3486 3498 * IPython/Magic.py (Magic._ofind): Harden against an inspect
3487 3499 failure, which can occur with SWIG-wrapped extensions. After a
3488 3500 crash report from Prabhu.
3489 3501
3490 3502 2003-05-16 Fernando Perez <fperez@colorado.edu>
3491 3503
3492 3504 * IPython/iplib.py (InteractiveShell.excepthook): New method to
3493 3505 protect ipython from user code which may call directly
3494 3506 sys.excepthook (this looks like an ipython crash to the user, even
3495 3507 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3496 3508 This is especially important to help users of WxWindows, but may
3497 3509 also be useful in other cases.
3498 3510
3499 3511 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
3500 3512 an optional tb_offset to be specified, and to preserve exception
3501 3513 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3502 3514
3503 3515 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
3504 3516
3505 3517 2003-05-15 Fernando Perez <fperez@colorado.edu>
3506 3518
3507 3519 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
3508 3520 installing for a new user under Windows.
3509 3521
3510 3522 2003-05-12 Fernando Perez <fperez@colorado.edu>
3511 3523
3512 3524 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
3513 3525 handler for Emacs comint-based lines. Currently it doesn't do
3514 3526 much (but importantly, it doesn't update the history cache). In
3515 3527 the future it may be expanded if Alex needs more functionality
3516 3528 there.
3517 3529
3518 3530 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
3519 3531 info to crash reports.
3520 3532
3521 3533 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
3522 3534 just like Python's -c. Also fixed crash with invalid -color
3523 3535 option value at startup. Thanks to Will French
3524 3536 <wfrench-AT-bestweb.net> for the bug report.
3525 3537
3526 3538 2003-05-09 Fernando Perez <fperez@colorado.edu>
3527 3539
3528 3540 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
3529 3541 to EvalDict (it's a mapping, after all) and simplified its code
3530 3542 quite a bit, after a nice discussion on c.l.py where Gustavo
3531 3543 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
3532 3544
3533 3545 2003-04-30 Fernando Perez <fperez@colorado.edu>
3534 3546
3535 3547 * IPython/genutils.py (timings_out): modified it to reduce its
3536 3548 overhead in the common reps==1 case.
3537 3549
3538 3550 2003-04-29 Fernando Perez <fperez@colorado.edu>
3539 3551
3540 3552 * IPython/genutils.py (timings_out): Modified to use the resource
3541 3553 module, which avoids the wraparound problems of time.clock().
3542 3554
3543 3555 2003-04-17 *** Released version 0.2.15pre4
3544 3556
3545 3557 2003-04-17 Fernando Perez <fperez@colorado.edu>
3546 3558
3547 3559 * setup.py (scriptfiles): Split windows-specific stuff over to a
3548 3560 separate file, in an attempt to have a Windows GUI installer.
3549 3561 That didn't work, but part of the groundwork is done.
3550 3562
3551 3563 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
3552 3564 indent/unindent with 4 spaces. Particularly useful in combination
3553 3565 with the new auto-indent option.
3554 3566
3555 3567 2003-04-16 Fernando Perez <fperez@colorado.edu>
3556 3568
3557 3569 * IPython/Magic.py: various replacements of self.rc for
3558 3570 self.shell.rc. A lot more remains to be done to fully disentangle
3559 3571 this class from the main Shell class.
3560 3572
3561 3573 * IPython/GnuplotRuntime.py: added checks for mouse support so
3562 3574 that we don't try to enable it if the current gnuplot doesn't
3563 3575 really support it. Also added checks so that we don't try to
3564 3576 enable persist under Windows (where Gnuplot doesn't recognize the
3565 3577 option).
3566 3578
3567 3579 * IPython/iplib.py (InteractiveShell.interact): Added optional
3568 3580 auto-indenting code, after a patch by King C. Shu
3569 3581 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
3570 3582 get along well with pasting indented code. If I ever figure out
3571 3583 how to make that part go well, it will become on by default.
3572 3584
3573 3585 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
3574 3586 crash ipython if there was an unmatched '%' in the user's prompt
3575 3587 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3576 3588
3577 3589 * IPython/iplib.py (InteractiveShell.interact): removed the
3578 3590 ability to ask the user whether he wants to crash or not at the
3579 3591 'last line' exception handler. Calling functions at that point
3580 3592 changes the stack, and the error reports would have incorrect
3581 3593 tracebacks.
3582 3594
3583 3595 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
3584 3596 pass through a peger a pretty-printed form of any object. After a
3585 3597 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
3586 3598
3587 3599 2003-04-14 Fernando Perez <fperez@colorado.edu>
3588 3600
3589 3601 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
3590 3602 all files in ~ would be modified at first install (instead of
3591 3603 ~/.ipython). This could be potentially disastrous, as the
3592 3604 modification (make line-endings native) could damage binary files.
3593 3605
3594 3606 2003-04-10 Fernando Perez <fperez@colorado.edu>
3595 3607
3596 3608 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
3597 3609 handle only lines which are invalid python. This now means that
3598 3610 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
3599 3611 for the bug report.
3600 3612
3601 3613 2003-04-01 Fernando Perez <fperez@colorado.edu>
3602 3614
3603 3615 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
3604 3616 where failing to set sys.last_traceback would crash pdb.pm().
3605 3617 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
3606 3618 report.
3607 3619
3608 3620 2003-03-25 Fernando Perez <fperez@colorado.edu>
3609 3621
3610 3622 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
3611 3623 before printing it (it had a lot of spurious blank lines at the
3612 3624 end).
3613 3625
3614 3626 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
3615 3627 output would be sent 21 times! Obviously people don't use this
3616 3628 too often, or I would have heard about it.
3617 3629
3618 3630 2003-03-24 Fernando Perez <fperez@colorado.edu>
3619 3631
3620 3632 * setup.py (scriptfiles): renamed the data_files parameter from
3621 3633 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
3622 3634 for the patch.
3623 3635
3624 3636 2003-03-20 Fernando Perez <fperez@colorado.edu>
3625 3637
3626 3638 * IPython/genutils.py (error): added error() and fatal()
3627 3639 functions.
3628 3640
3629 3641 2003-03-18 *** Released version 0.2.15pre3
3630 3642
3631 3643 2003-03-18 Fernando Perez <fperez@colorado.edu>
3632 3644
3633 3645 * setupext/install_data_ext.py
3634 3646 (install_data_ext.initialize_options): Class contributed by Jack
3635 3647 Moffit for fixing the old distutils hack. He is sending this to
3636 3648 the distutils folks so in the future we may not need it as a
3637 3649 private fix.
3638 3650
3639 3651 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
3640 3652 changes for Debian packaging. See his patch for full details.
3641 3653 The old distutils hack of making the ipythonrc* files carry a
3642 3654 bogus .py extension is gone, at last. Examples were moved to a
3643 3655 separate subdir under doc/, and the separate executable scripts
3644 3656 now live in their own directory. Overall a great cleanup. The
3645 3657 manual was updated to use the new files, and setup.py has been
3646 3658 fixed for this setup.
3647 3659
3648 3660 * IPython/PyColorize.py (Parser.usage): made non-executable and
3649 3661 created a pycolor wrapper around it to be included as a script.
3650 3662
3651 3663 2003-03-12 *** Released version 0.2.15pre2
3652 3664
3653 3665 2003-03-12 Fernando Perez <fperez@colorado.edu>
3654 3666
3655 3667 * IPython/ColorANSI.py (make_color_table): Finally fixed the
3656 3668 long-standing problem with garbage characters in some terminals.
3657 3669 The issue was really that the \001 and \002 escapes must _only_ be
3658 3670 passed to input prompts (which call readline), but _never_ to
3659 3671 normal text to be printed on screen. I changed ColorANSI to have
3660 3672 two classes: TermColors and InputTermColors, each with the
3661 3673 appropriate escapes for input prompts or normal text. The code in
3662 3674 Prompts.py got slightly more complicated, but this very old and
3663 3675 annoying bug is finally fixed.
3664 3676
3665 3677 All the credit for nailing down the real origin of this problem
3666 3678 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
3667 3679 *Many* thanks to him for spending quite a bit of effort on this.
3668 3680
3669 3681 2003-03-05 *** Released version 0.2.15pre1
3670 3682
3671 3683 2003-03-03 Fernando Perez <fperez@colorado.edu>
3672 3684
3673 3685 * IPython/FakeModule.py: Moved the former _FakeModule to a
3674 3686 separate file, because it's also needed by Magic (to fix a similar
3675 3687 pickle-related issue in @run).
3676 3688
3677 3689 2003-03-02 Fernando Perez <fperez@colorado.edu>
3678 3690
3679 3691 * IPython/Magic.py (Magic.magic_autocall): new magic to control
3680 3692 the autocall option at runtime.
3681 3693 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
3682 3694 across Magic.py to start separating Magic from InteractiveShell.
3683 3695 (Magic._ofind): Fixed to return proper namespace for dotted
3684 3696 names. Before, a dotted name would always return 'not currently
3685 3697 defined', because it would find the 'parent'. s.x would be found,
3686 3698 but since 'x' isn't defined by itself, it would get confused.
3687 3699 (Magic.magic_run): Fixed pickling problems reported by Ralf
3688 3700 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
3689 3701 that I'd used when Mike Heeter reported similar issues at the
3690 3702 top-level, but now for @run. It boils down to injecting the
3691 3703 namespace where code is being executed with something that looks
3692 3704 enough like a module to fool pickle.dump(). Since a pickle stores
3693 3705 a named reference to the importing module, we need this for
3694 3706 pickles to save something sensible.
3695 3707
3696 3708 * IPython/ipmaker.py (make_IPython): added an autocall option.
3697 3709
3698 3710 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
3699 3711 the auto-eval code. Now autocalling is an option, and the code is
3700 3712 also vastly safer. There is no more eval() involved at all.
3701 3713
3702 3714 2003-03-01 Fernando Perez <fperez@colorado.edu>
3703 3715
3704 3716 * IPython/Magic.py (Magic._ofind): Changed interface to return a
3705 3717 dict with named keys instead of a tuple.
3706 3718
3707 3719 * IPython: Started using CVS for IPython as of 0.2.15pre1.
3708 3720
3709 3721 * setup.py (make_shortcut): Fixed message about directories
3710 3722 created during Windows installation (the directories were ok, just
3711 3723 the printed message was misleading). Thanks to Chris Liechti
3712 3724 <cliechti-AT-gmx.net> for the heads up.
3713 3725
3714 3726 2003-02-21 Fernando Perez <fperez@colorado.edu>
3715 3727
3716 3728 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
3717 3729 of ValueError exception when checking for auto-execution. This
3718 3730 one is raised by things like Numeric arrays arr.flat when the
3719 3731 array is non-contiguous.
3720 3732
3721 3733 2003-01-31 Fernando Perez <fperez@colorado.edu>
3722 3734
3723 3735 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
3724 3736 not return any value at all (even though the command would get
3725 3737 executed).
3726 3738 (xsys): Flush stdout right after printing the command to ensure
3727 3739 proper ordering of commands and command output in the total
3728 3740 output.
3729 3741 (SystemExec/xsys/bq): Switched the names of xsys/bq and
3730 3742 system/getoutput as defaults. The old ones are kept for
3731 3743 compatibility reasons, so no code which uses this library needs
3732 3744 changing.
3733 3745
3734 3746 2003-01-27 *** Released version 0.2.14
3735 3747
3736 3748 2003-01-25 Fernando Perez <fperez@colorado.edu>
3737 3749
3738 3750 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
3739 3751 functions defined in previous edit sessions could not be re-edited
3740 3752 (because the temp files were immediately removed). Now temp files
3741 3753 are removed only at IPython's exit.
3742 3754 (Magic.magic_run): Improved @run to perform shell-like expansions
3743 3755 on its arguments (~users and $VARS). With this, @run becomes more
3744 3756 like a normal command-line.
3745 3757
3746 3758 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
3747 3759 bugs related to embedding and cleaned up that code. A fairly
3748 3760 important one was the impossibility to access the global namespace
3749 3761 through the embedded IPython (only local variables were visible).
3750 3762
3751 3763 2003-01-14 Fernando Perez <fperez@colorado.edu>
3752 3764
3753 3765 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
3754 3766 auto-calling to be a bit more conservative. Now it doesn't get
3755 3767 triggered if any of '!=()<>' are in the rest of the input line, to
3756 3768 allow comparing callables. Thanks to Alex for the heads up.
3757 3769
3758 3770 2003-01-07 Fernando Perez <fperez@colorado.edu>
3759 3771
3760 3772 * IPython/genutils.py (page): fixed estimation of the number of
3761 3773 lines in a string to be paged to simply count newlines. This
3762 3774 prevents over-guessing due to embedded escape sequences. A better
3763 3775 long-term solution would involve stripping out the control chars
3764 3776 for the count, but it's potentially so expensive I just don't
3765 3777 think it's worth doing.
3766 3778
3767 3779 2002-12-19 *** Released version 0.2.14pre50
3768 3780
3769 3781 2002-12-19 Fernando Perez <fperez@colorado.edu>
3770 3782
3771 3783 * tools/release (version): Changed release scripts to inform
3772 3784 Andrea and build a NEWS file with a list of recent changes.
3773 3785
3774 3786 * IPython/ColorANSI.py (__all__): changed terminal detection
3775 3787 code. Seems to work better for xterms without breaking
3776 3788 konsole. Will need more testing to determine if WinXP and Mac OSX
3777 3789 also work ok.
3778 3790
3779 3791 2002-12-18 *** Released version 0.2.14pre49
3780 3792
3781 3793 2002-12-18 Fernando Perez <fperez@colorado.edu>
3782 3794
3783 3795 * Docs: added new info about Mac OSX, from Andrea.
3784 3796
3785 3797 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
3786 3798 allow direct plotting of python strings whose format is the same
3787 3799 of gnuplot data files.
3788 3800
3789 3801 2002-12-16 Fernando Perez <fperez@colorado.edu>
3790 3802
3791 3803 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
3792 3804 value of exit question to be acknowledged.
3793 3805
3794 3806 2002-12-03 Fernando Perez <fperez@colorado.edu>
3795 3807
3796 3808 * IPython/ipmaker.py: removed generators, which had been added
3797 3809 by mistake in an earlier debugging run. This was causing trouble
3798 3810 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
3799 3811 for pointing this out.
3800 3812
3801 3813 2002-11-17 Fernando Perez <fperez@colorado.edu>
3802 3814
3803 3815 * Manual: updated the Gnuplot section.
3804 3816
3805 3817 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
3806 3818 a much better split of what goes in Runtime and what goes in
3807 3819 Interactive.
3808 3820
3809 3821 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
3810 3822 being imported from iplib.
3811 3823
3812 3824 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
3813 3825 for command-passing. Now the global Gnuplot instance is called
3814 3826 'gp' instead of 'g', which was really a far too fragile and
3815 3827 common name.
3816 3828
3817 3829 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
3818 3830 bounding boxes generated by Gnuplot for square plots.
3819 3831
3820 3832 * IPython/genutils.py (popkey): new function added. I should
3821 3833 suggest this on c.l.py as a dict method, it seems useful.
3822 3834
3823 3835 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
3824 3836 to transparently handle PostScript generation. MUCH better than
3825 3837 the previous plot_eps/replot_eps (which I removed now). The code
3826 3838 is also fairly clean and well documented now (including
3827 3839 docstrings).
3828 3840
3829 3841 2002-11-13 Fernando Perez <fperez@colorado.edu>
3830 3842
3831 3843 * IPython/Magic.py (Magic.magic_edit): fixed docstring
3832 3844 (inconsistent with options).
3833 3845
3834 3846 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
3835 3847 manually disabled, I don't know why. Fixed it.
3836 3848 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
3837 3849 eps output.
3838 3850
3839 3851 2002-11-12 Fernando Perez <fperez@colorado.edu>
3840 3852
3841 3853 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
3842 3854 don't propagate up to caller. Fixes crash reported by François
3843 3855 Pinard.
3844 3856
3845 3857 2002-11-09 Fernando Perez <fperez@colorado.edu>
3846 3858
3847 3859 * IPython/ipmaker.py (make_IPython): fixed problem with writing
3848 3860 history file for new users.
3849 3861 (make_IPython): fixed bug where initial install would leave the
3850 3862 user running in the .ipython dir.
3851 3863 (make_IPython): fixed bug where config dir .ipython would be
3852 3864 created regardless of the given -ipythondir option. Thanks to Cory
3853 3865 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
3854 3866
3855 3867 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
3856 3868 type confirmations. Will need to use it in all of IPython's code
3857 3869 consistently.
3858 3870
3859 3871 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
3860 3872 context to print 31 lines instead of the default 5. This will make
3861 3873 the crash reports extremely detailed in case the problem is in
3862 3874 libraries I don't have access to.
3863 3875
3864 3876 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
3865 3877 line of defense' code to still crash, but giving users fair
3866 3878 warning. I don't want internal errors to go unreported: if there's
3867 3879 an internal problem, IPython should crash and generate a full
3868 3880 report.
3869 3881
3870 3882 2002-11-08 Fernando Perez <fperez@colorado.edu>
3871 3883
3872 3884 * IPython/iplib.py (InteractiveShell.interact): added code to trap
3873 3885 otherwise uncaught exceptions which can appear if people set
3874 3886 sys.stdout to something badly broken. Thanks to a crash report
3875 3887 from henni-AT-mail.brainbot.com.
3876 3888
3877 3889 2002-11-04 Fernando Perez <fperez@colorado.edu>
3878 3890
3879 3891 * IPython/iplib.py (InteractiveShell.interact): added
3880 3892 __IPYTHON__active to the builtins. It's a flag which goes on when
3881 3893 the interaction starts and goes off again when it stops. This
3882 3894 allows embedding code to detect being inside IPython. Before this
3883 3895 was done via __IPYTHON__, but that only shows that an IPython
3884 3896 instance has been created.
3885 3897
3886 3898 * IPython/Magic.py (Magic.magic_env): I realized that in a
3887 3899 UserDict, instance.data holds the data as a normal dict. So I
3888 3900 modified @env to return os.environ.data instead of rebuilding a
3889 3901 dict by hand.
3890 3902
3891 3903 2002-11-02 Fernando Perez <fperez@colorado.edu>
3892 3904
3893 3905 * IPython/genutils.py (warn): changed so that level 1 prints no
3894 3906 header. Level 2 is now the default (with 'WARNING' header, as
3895 3907 before). I think I tracked all places where changes were needed in
3896 3908 IPython, but outside code using the old level numbering may have
3897 3909 broken.
3898 3910
3899 3911 * IPython/iplib.py (InteractiveShell.runcode): added this to
3900 3912 handle the tracebacks in SystemExit traps correctly. The previous
3901 3913 code (through interact) was printing more of the stack than
3902 3914 necessary, showing IPython internal code to the user.
3903 3915
3904 3916 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
3905 3917 default. Now that the default at the confirmation prompt is yes,
3906 3918 it's not so intrusive. François' argument that ipython sessions
3907 3919 tend to be complex enough not to lose them from an accidental C-d,
3908 3920 is a valid one.
3909 3921
3910 3922 * IPython/iplib.py (InteractiveShell.interact): added a
3911 3923 showtraceback() call to the SystemExit trap, and modified the exit
3912 3924 confirmation to have yes as the default.
3913 3925
3914 3926 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
3915 3927 this file. It's been gone from the code for a long time, this was
3916 3928 simply leftover junk.
3917 3929
3918 3930 2002-11-01 Fernando Perez <fperez@colorado.edu>
3919 3931
3920 3932 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
3921 3933 added. If set, IPython now traps EOF and asks for
3922 3934 confirmation. After a request by François Pinard.
3923 3935
3924 3936 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
3925 3937 of @abort, and with a new (better) mechanism for handling the
3926 3938 exceptions.
3927 3939
3928 3940 2002-10-27 Fernando Perez <fperez@colorado.edu>
3929 3941
3930 3942 * IPython/usage.py (__doc__): updated the --help information and
3931 3943 the ipythonrc file to indicate that -log generates
3932 3944 ./ipython.log. Also fixed the corresponding info in @logstart.
3933 3945 This and several other fixes in the manuals thanks to reports by
3934 3946 François Pinard <pinard-AT-iro.umontreal.ca>.
3935 3947
3936 3948 * IPython/Logger.py (Logger.switch_log): Fixed error message to
3937 3949 refer to @logstart (instead of @log, which doesn't exist).
3938 3950
3939 3951 * IPython/iplib.py (InteractiveShell._prefilter): fixed
3940 3952 AttributeError crash. Thanks to Christopher Armstrong
3941 3953 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
3942 3954 introduced recently (in 0.2.14pre37) with the fix to the eval
3943 3955 problem mentioned below.
3944 3956
3945 3957 2002-10-17 Fernando Perez <fperez@colorado.edu>
3946 3958
3947 3959 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
3948 3960 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
3949 3961
3950 3962 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
3951 3963 this function to fix a problem reported by Alex Schmolck. He saw
3952 3964 it with list comprehensions and generators, which were getting
3953 3965 called twice. The real problem was an 'eval' call in testing for
3954 3966 automagic which was evaluating the input line silently.
3955 3967
3956 3968 This is a potentially very nasty bug, if the input has side
3957 3969 effects which must not be repeated. The code is much cleaner now,
3958 3970 without any blanket 'except' left and with a regexp test for
3959 3971 actual function names.
3960 3972
3961 3973 But an eval remains, which I'm not fully comfortable with. I just
3962 3974 don't know how to find out if an expression could be a callable in
3963 3975 the user's namespace without doing an eval on the string. However
3964 3976 that string is now much more strictly checked so that no code
3965 3977 slips by, so the eval should only happen for things that can
3966 3978 really be only function/method names.
3967 3979
3968 3980 2002-10-15 Fernando Perez <fperez@colorado.edu>
3969 3981
3970 3982 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
3971 3983 OSX information to main manual, removed README_Mac_OSX file from
3972 3984 distribution. Also updated credits for recent additions.
3973 3985
3974 3986 2002-10-10 Fernando Perez <fperez@colorado.edu>
3975 3987
3976 3988 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3977 3989 terminal-related issues. Many thanks to Andrea Riciputi
3978 3990 <andrea.riciputi-AT-libero.it> for writing it.
3979 3991
3980 3992 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3981 3993 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3982 3994
3983 3995 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3984 3996 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3985 3997 <syver-en-AT-online.no> who both submitted patches for this problem.
3986 3998
3987 3999 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3988 4000 global embedding to make sure that things don't overwrite user
3989 4001 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3990 4002
3991 4003 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3992 4004 compatibility. Thanks to Hayden Callow
3993 4005 <h.callow-AT-elec.canterbury.ac.nz>
3994 4006
3995 4007 2002-10-04 Fernando Perez <fperez@colorado.edu>
3996 4008
3997 4009 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3998 4010 Gnuplot.File objects.
3999 4011
4000 4012 2002-07-23 Fernando Perez <fperez@colorado.edu>
4001 4013
4002 4014 * IPython/genutils.py (timing): Added timings() and timing() for
4003 4015 quick access to the most commonly needed data, the execution
4004 4016 times. Old timing() renamed to timings_out().
4005 4017
4006 4018 2002-07-18 Fernando Perez <fperez@colorado.edu>
4007 4019
4008 4020 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4009 4021 bug with nested instances disrupting the parent's tab completion.
4010 4022
4011 4023 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4012 4024 all_completions code to begin the emacs integration.
4013 4025
4014 4026 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4015 4027 argument to allow titling individual arrays when plotting.
4016 4028
4017 4029 2002-07-15 Fernando Perez <fperez@colorado.edu>
4018 4030
4019 4031 * setup.py (make_shortcut): changed to retrieve the value of
4020 4032 'Program Files' directory from the registry (this value changes in
4021 4033 non-english versions of Windows). Thanks to Thomas Fanslau
4022 4034 <tfanslau-AT-gmx.de> for the report.
4023 4035
4024 4036 2002-07-10 Fernando Perez <fperez@colorado.edu>
4025 4037
4026 4038 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4027 4039 a bug in pdb, which crashes if a line with only whitespace is
4028 4040 entered. Bug report submitted to sourceforge.
4029 4041
4030 4042 2002-07-09 Fernando Perez <fperez@colorado.edu>
4031 4043
4032 4044 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4033 4045 reporting exceptions (it's a bug in inspect.py, I just set a
4034 4046 workaround).
4035 4047
4036 4048 2002-07-08 Fernando Perez <fperez@colorado.edu>
4037 4049
4038 4050 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4039 4051 __IPYTHON__ in __builtins__ to show up in user_ns.
4040 4052
4041 4053 2002-07-03 Fernando Perez <fperez@colorado.edu>
4042 4054
4043 4055 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4044 4056 name from @gp_set_instance to @gp_set_default.
4045 4057
4046 4058 * IPython/ipmaker.py (make_IPython): default editor value set to
4047 4059 '0' (a string), to match the rc file. Otherwise will crash when
4048 4060 .strip() is called on it.
4049 4061
4050 4062
4051 4063 2002-06-28 Fernando Perez <fperez@colorado.edu>
4052 4064
4053 4065 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4054 4066 of files in current directory when a file is executed via
4055 4067 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4056 4068
4057 4069 * setup.py (manfiles): fix for rpm builds, submitted by RA
4058 4070 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4059 4071
4060 4072 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4061 4073 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4062 4074 string!). A. Schmolck caught this one.
4063 4075
4064 4076 2002-06-27 Fernando Perez <fperez@colorado.edu>
4065 4077
4066 4078 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4067 4079 defined files at the cmd line. __name__ wasn't being set to
4068 4080 __main__.
4069 4081
4070 4082 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4071 4083 regular lists and tuples besides Numeric arrays.
4072 4084
4073 4085 * IPython/Prompts.py (CachedOutput.__call__): Added output
4074 4086 supression for input ending with ';'. Similar to Mathematica and
4075 4087 Matlab. The _* vars and Out[] list are still updated, just like
4076 4088 Mathematica behaves.
4077 4089
4078 4090 2002-06-25 Fernando Perez <fperez@colorado.edu>
4079 4091
4080 4092 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4081 4093 .ini extensions for profiels under Windows.
4082 4094
4083 4095 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4084 4096 string form. Fix contributed by Alexander Schmolck
4085 4097 <a.schmolck-AT-gmx.net>
4086 4098
4087 4099 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4088 4100 pre-configured Gnuplot instance.
4089 4101
4090 4102 2002-06-21 Fernando Perez <fperez@colorado.edu>
4091 4103
4092 4104 * IPython/numutils.py (exp_safe): new function, works around the
4093 4105 underflow problems in Numeric.
4094 4106 (log2): New fn. Safe log in base 2: returns exact integer answer
4095 4107 for exact integer powers of 2.
4096 4108
4097 4109 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4098 4110 properly.
4099 4111
4100 4112 2002-06-20 Fernando Perez <fperez@colorado.edu>
4101 4113
4102 4114 * IPython/genutils.py (timing): new function like
4103 4115 Mathematica's. Similar to time_test, but returns more info.
4104 4116
4105 4117 2002-06-18 Fernando Perez <fperez@colorado.edu>
4106 4118
4107 4119 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4108 4120 according to Mike Heeter's suggestions.
4109 4121
4110 4122 2002-06-16 Fernando Perez <fperez@colorado.edu>
4111 4123
4112 4124 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4113 4125 system. GnuplotMagic is gone as a user-directory option. New files
4114 4126 make it easier to use all the gnuplot stuff both from external
4115 4127 programs as well as from IPython. Had to rewrite part of
4116 4128 hardcopy() b/c of a strange bug: often the ps files simply don't
4117 4129 get created, and require a repeat of the command (often several
4118 4130 times).
4119 4131
4120 4132 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4121 4133 resolve output channel at call time, so that if sys.stderr has
4122 4134 been redirected by user this gets honored.
4123 4135
4124 4136 2002-06-13 Fernando Perez <fperez@colorado.edu>
4125 4137
4126 4138 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4127 4139 IPShell. Kept a copy with the old names to avoid breaking people's
4128 4140 embedded code.
4129 4141
4130 4142 * IPython/ipython: simplified it to the bare minimum after
4131 4143 Holger's suggestions. Added info about how to use it in
4132 4144 PYTHONSTARTUP.
4133 4145
4134 4146 * IPython/Shell.py (IPythonShell): changed the options passing
4135 4147 from a string with funky %s replacements to a straight list. Maybe
4136 4148 a bit more typing, but it follows sys.argv conventions, so there's
4137 4149 less special-casing to remember.
4138 4150
4139 4151 2002-06-12 Fernando Perez <fperez@colorado.edu>
4140 4152
4141 4153 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4142 4154 command. Thanks to a suggestion by Mike Heeter.
4143 4155 (Magic.magic_pfile): added behavior to look at filenames if given
4144 4156 arg is not a defined object.
4145 4157 (Magic.magic_save): New @save function to save code snippets. Also
4146 4158 a Mike Heeter idea.
4147 4159
4148 4160 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4149 4161 plot() and replot(). Much more convenient now, especially for
4150 4162 interactive use.
4151 4163
4152 4164 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4153 4165 filenames.
4154 4166
4155 4167 2002-06-02 Fernando Perez <fperez@colorado.edu>
4156 4168
4157 4169 * IPython/Struct.py (Struct.__init__): modified to admit
4158 4170 initialization via another struct.
4159 4171
4160 4172 * IPython/genutils.py (SystemExec.__init__): New stateful
4161 4173 interface to xsys and bq. Useful for writing system scripts.
4162 4174
4163 4175 2002-05-30 Fernando Perez <fperez@colorado.edu>
4164 4176
4165 4177 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4166 4178 documents. This will make the user download smaller (it's getting
4167 4179 too big).
4168 4180
4169 4181 2002-05-29 Fernando Perez <fperez@colorado.edu>
4170 4182
4171 4183 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4172 4184 fix problems with shelve and pickle. Seems to work, but I don't
4173 4185 know if corner cases break it. Thanks to Mike Heeter
4174 4186 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4175 4187
4176 4188 2002-05-24 Fernando Perez <fperez@colorado.edu>
4177 4189
4178 4190 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4179 4191 macros having broken.
4180 4192
4181 4193 2002-05-21 Fernando Perez <fperez@colorado.edu>
4182 4194
4183 4195 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4184 4196 introduced logging bug: all history before logging started was
4185 4197 being written one character per line! This came from the redesign
4186 4198 of the input history as a special list which slices to strings,
4187 4199 not to lists.
4188 4200
4189 4201 2002-05-20 Fernando Perez <fperez@colorado.edu>
4190 4202
4191 4203 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4192 4204 be an attribute of all classes in this module. The design of these
4193 4205 classes needs some serious overhauling.
4194 4206
4195 4207 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4196 4208 which was ignoring '_' in option names.
4197 4209
4198 4210 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4199 4211 'Verbose_novars' to 'Context' and made it the new default. It's a
4200 4212 bit more readable and also safer than verbose.
4201 4213
4202 4214 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4203 4215 triple-quoted strings.
4204 4216
4205 4217 * IPython/OInspect.py (__all__): new module exposing the object
4206 4218 introspection facilities. Now the corresponding magics are dummy
4207 4219 wrappers around this. Having this module will make it much easier
4208 4220 to put these functions into our modified pdb.
4209 4221 This new object inspector system uses the new colorizing module,
4210 4222 so source code and other things are nicely syntax highlighted.
4211 4223
4212 4224 2002-05-18 Fernando Perez <fperez@colorado.edu>
4213 4225
4214 4226 * IPython/ColorANSI.py: Split the coloring tools into a separate
4215 4227 module so I can use them in other code easier (they were part of
4216 4228 ultraTB).
4217 4229
4218 4230 2002-05-17 Fernando Perez <fperez@colorado.edu>
4219 4231
4220 4232 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4221 4233 fixed it to set the global 'g' also to the called instance, as
4222 4234 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4223 4235 user's 'g' variables).
4224 4236
4225 4237 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4226 4238 global variables (aliases to _ih,_oh) so that users which expect
4227 4239 In[5] or Out[7] to work aren't unpleasantly surprised.
4228 4240 (InputList.__getslice__): new class to allow executing slices of
4229 4241 input history directly. Very simple class, complements the use of
4230 4242 macros.
4231 4243
4232 4244 2002-05-16 Fernando Perez <fperez@colorado.edu>
4233 4245
4234 4246 * setup.py (docdirbase): make doc directory be just doc/IPython
4235 4247 without version numbers, it will reduce clutter for users.
4236 4248
4237 4249 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4238 4250 execfile call to prevent possible memory leak. See for details:
4239 4251 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4240 4252
4241 4253 2002-05-15 Fernando Perez <fperez@colorado.edu>
4242 4254
4243 4255 * IPython/Magic.py (Magic.magic_psource): made the object
4244 4256 introspection names be more standard: pdoc, pdef, pfile and
4245 4257 psource. They all print/page their output, and it makes
4246 4258 remembering them easier. Kept old names for compatibility as
4247 4259 aliases.
4248 4260
4249 4261 2002-05-14 Fernando Perez <fperez@colorado.edu>
4250 4262
4251 4263 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4252 4264 what the mouse problem was. The trick is to use gnuplot with temp
4253 4265 files and NOT with pipes (for data communication), because having
4254 4266 both pipes and the mouse on is bad news.
4255 4267
4256 4268 2002-05-13 Fernando Perez <fperez@colorado.edu>
4257 4269
4258 4270 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4259 4271 bug. Information would be reported about builtins even when
4260 4272 user-defined functions overrode them.
4261 4273
4262 4274 2002-05-11 Fernando Perez <fperez@colorado.edu>
4263 4275
4264 4276 * IPython/__init__.py (__all__): removed FlexCompleter from
4265 4277 __all__ so that things don't fail in platforms without readline.
4266 4278
4267 4279 2002-05-10 Fernando Perez <fperez@colorado.edu>
4268 4280
4269 4281 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4270 4282 it requires Numeric, effectively making Numeric a dependency for
4271 4283 IPython.
4272 4284
4273 4285 * Released 0.2.13
4274 4286
4275 4287 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4276 4288 profiler interface. Now all the major options from the profiler
4277 4289 module are directly supported in IPython, both for single
4278 4290 expressions (@prun) and for full programs (@run -p).
4279 4291
4280 4292 2002-05-09 Fernando Perez <fperez@colorado.edu>
4281 4293
4282 4294 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4283 4295 magic properly formatted for screen.
4284 4296
4285 4297 * setup.py (make_shortcut): Changed things to put pdf version in
4286 4298 doc/ instead of doc/manual (had to change lyxport a bit).
4287 4299
4288 4300 * IPython/Magic.py (Profile.string_stats): made profile runs go
4289 4301 through pager (they are long and a pager allows searching, saving,
4290 4302 etc.)
4291 4303
4292 4304 2002-05-08 Fernando Perez <fperez@colorado.edu>
4293 4305
4294 4306 * Released 0.2.12
4295 4307
4296 4308 2002-05-06 Fernando Perez <fperez@colorado.edu>
4297 4309
4298 4310 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4299 4311 introduced); 'hist n1 n2' was broken.
4300 4312 (Magic.magic_pdb): added optional on/off arguments to @pdb
4301 4313 (Magic.magic_run): added option -i to @run, which executes code in
4302 4314 the IPython namespace instead of a clean one. Also added @irun as
4303 4315 an alias to @run -i.
4304 4316
4305 4317 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4306 4318 fixed (it didn't really do anything, the namespaces were wrong).
4307 4319
4308 4320 * IPython/Debugger.py (__init__): Added workaround for python 2.1
4309 4321
4310 4322 * IPython/__init__.py (__all__): Fixed package namespace, now
4311 4323 'import IPython' does give access to IPython.<all> as
4312 4324 expected. Also renamed __release__ to Release.
4313 4325
4314 4326 * IPython/Debugger.py (__license__): created new Pdb class which
4315 4327 functions like a drop-in for the normal pdb.Pdb but does NOT
4316 4328 import readline by default. This way it doesn't muck up IPython's
4317 4329 readline handling, and now tab-completion finally works in the
4318 4330 debugger -- sort of. It completes things globally visible, but the
4319 4331 completer doesn't track the stack as pdb walks it. That's a bit
4320 4332 tricky, and I'll have to implement it later.
4321 4333
4322 4334 2002-05-05 Fernando Perez <fperez@colorado.edu>
4323 4335
4324 4336 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
4325 4337 magic docstrings when printed via ? (explicit \'s were being
4326 4338 printed).
4327 4339
4328 4340 * IPython/ipmaker.py (make_IPython): fixed namespace
4329 4341 identification bug. Now variables loaded via logs or command-line
4330 4342 files are recognized in the interactive namespace by @who.
4331 4343
4332 4344 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
4333 4345 log replay system stemming from the string form of Structs.
4334 4346
4335 4347 * IPython/Magic.py (Macro.__init__): improved macros to properly
4336 4348 handle magic commands in them.
4337 4349 (Magic.magic_logstart): usernames are now expanded so 'logstart
4338 4350 ~/mylog' now works.
4339 4351
4340 4352 * IPython/iplib.py (complete): fixed bug where paths starting with
4341 4353 '/' would be completed as magic names.
4342 4354
4343 4355 2002-05-04 Fernando Perez <fperez@colorado.edu>
4344 4356
4345 4357 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
4346 4358 allow running full programs under the profiler's control.
4347 4359
4348 4360 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
4349 4361 mode to report exceptions verbosely but without formatting
4350 4362 variables. This addresses the issue of ipython 'freezing' (it's
4351 4363 not frozen, but caught in an expensive formatting loop) when huge
4352 4364 variables are in the context of an exception.
4353 4365 (VerboseTB.text): Added '--->' markers at line where exception was
4354 4366 triggered. Much clearer to read, especially in NoColor modes.
4355 4367
4356 4368 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
4357 4369 implemented in reverse when changing to the new parse_options().
4358 4370
4359 4371 2002-05-03 Fernando Perez <fperez@colorado.edu>
4360 4372
4361 4373 * IPython/Magic.py (Magic.parse_options): new function so that
4362 4374 magics can parse options easier.
4363 4375 (Magic.magic_prun): new function similar to profile.run(),
4364 4376 suggested by Chris Hart.
4365 4377 (Magic.magic_cd): fixed behavior so that it only changes if
4366 4378 directory actually is in history.
4367 4379
4368 4380 * IPython/usage.py (__doc__): added information about potential
4369 4381 slowness of Verbose exception mode when there are huge data
4370 4382 structures to be formatted (thanks to Archie Paulson).
4371 4383
4372 4384 * IPython/ipmaker.py (make_IPython): Changed default logging
4373 4385 (when simply called with -log) to use curr_dir/ipython.log in
4374 4386 rotate mode. Fixed crash which was occuring with -log before
4375 4387 (thanks to Jim Boyle).
4376 4388
4377 4389 2002-05-01 Fernando Perez <fperez@colorado.edu>
4378 4390
4379 4391 * Released 0.2.11 for these fixes (mainly the ultraTB one which
4380 4392 was nasty -- though somewhat of a corner case).
4381 4393
4382 4394 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
4383 4395 text (was a bug).
4384 4396
4385 4397 2002-04-30 Fernando Perez <fperez@colorado.edu>
4386 4398
4387 4399 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
4388 4400 a print after ^D or ^C from the user so that the In[] prompt
4389 4401 doesn't over-run the gnuplot one.
4390 4402
4391 4403 2002-04-29 Fernando Perez <fperez@colorado.edu>
4392 4404
4393 4405 * Released 0.2.10
4394 4406
4395 4407 * IPython/__release__.py (version): get date dynamically.
4396 4408
4397 4409 * Misc. documentation updates thanks to Arnd's comments. Also ran
4398 4410 a full spellcheck on the manual (hadn't been done in a while).
4399 4411
4400 4412 2002-04-27 Fernando Perez <fperez@colorado.edu>
4401 4413
4402 4414 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
4403 4415 starting a log in mid-session would reset the input history list.
4404 4416
4405 4417 2002-04-26 Fernando Perez <fperez@colorado.edu>
4406 4418
4407 4419 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
4408 4420 all files were being included in an update. Now anything in
4409 4421 UserConfig that matches [A-Za-z]*.py will go (this excludes
4410 4422 __init__.py)
4411 4423
4412 4424 2002-04-25 Fernando Perez <fperez@colorado.edu>
4413 4425
4414 4426 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
4415 4427 to __builtins__ so that any form of embedded or imported code can
4416 4428 test for being inside IPython.
4417 4429
4418 4430 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
4419 4431 changed to GnuplotMagic because it's now an importable module,
4420 4432 this makes the name follow that of the standard Gnuplot module.
4421 4433 GnuplotMagic can now be loaded at any time in mid-session.
4422 4434
4423 4435 2002-04-24 Fernando Perez <fperez@colorado.edu>
4424 4436
4425 4437 * IPython/numutils.py: removed SIUnits. It doesn't properly set
4426 4438 the globals (IPython has its own namespace) and the
4427 4439 PhysicalQuantity stuff is much better anyway.
4428 4440
4429 4441 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
4430 4442 embedding example to standard user directory for
4431 4443 distribution. Also put it in the manual.
4432 4444
4433 4445 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
4434 4446 instance as first argument (so it doesn't rely on some obscure
4435 4447 hidden global).
4436 4448
4437 4449 * IPython/UserConfig/ipythonrc.py: put () back in accepted
4438 4450 delimiters. While it prevents ().TAB from working, it allows
4439 4451 completions in open (... expressions. This is by far a more common
4440 4452 case.
4441 4453
4442 4454 2002-04-23 Fernando Perez <fperez@colorado.edu>
4443 4455
4444 4456 * IPython/Extensions/InterpreterPasteInput.py: new
4445 4457 syntax-processing module for pasting lines with >>> or ... at the
4446 4458 start.
4447 4459
4448 4460 * IPython/Extensions/PhysicalQ_Interactive.py
4449 4461 (PhysicalQuantityInteractive.__int__): fixed to work with either
4450 4462 Numeric or math.
4451 4463
4452 4464 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
4453 4465 provided profiles. Now we have:
4454 4466 -math -> math module as * and cmath with its own namespace.
4455 4467 -numeric -> Numeric as *, plus gnuplot & grace
4456 4468 -physics -> same as before
4457 4469
4458 4470 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
4459 4471 user-defined magics wouldn't be found by @magic if they were
4460 4472 defined as class methods. Also cleaned up the namespace search
4461 4473 logic and the string building (to use %s instead of many repeated
4462 4474 string adds).
4463 4475
4464 4476 * IPython/UserConfig/example-magic.py (magic_foo): updated example
4465 4477 of user-defined magics to operate with class methods (cleaner, in
4466 4478 line with the gnuplot code).
4467 4479
4468 4480 2002-04-22 Fernando Perez <fperez@colorado.edu>
4469 4481
4470 4482 * setup.py: updated dependency list so that manual is updated when
4471 4483 all included files change.
4472 4484
4473 4485 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
4474 4486 the delimiter removal option (the fix is ugly right now).
4475 4487
4476 4488 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
4477 4489 all of the math profile (quicker loading, no conflict between
4478 4490 g-9.8 and g-gnuplot).
4479 4491
4480 4492 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
4481 4493 name of post-mortem files to IPython_crash_report.txt.
4482 4494
4483 4495 * Cleanup/update of the docs. Added all the new readline info and
4484 4496 formatted all lists as 'real lists'.
4485 4497
4486 4498 * IPython/ipmaker.py (make_IPython): removed now-obsolete
4487 4499 tab-completion options, since the full readline parse_and_bind is
4488 4500 now accessible.
4489 4501
4490 4502 * IPython/iplib.py (InteractiveShell.init_readline): Changed
4491 4503 handling of readline options. Now users can specify any string to
4492 4504 be passed to parse_and_bind(), as well as the delimiters to be
4493 4505 removed.
4494 4506 (InteractiveShell.__init__): Added __name__ to the global
4495 4507 namespace so that things like Itpl which rely on its existence
4496 4508 don't crash.
4497 4509 (InteractiveShell._prefilter): Defined the default with a _ so
4498 4510 that prefilter() is easier to override, while the default one
4499 4511 remains available.
4500 4512
4501 4513 2002-04-18 Fernando Perez <fperez@colorado.edu>
4502 4514
4503 4515 * Added information about pdb in the docs.
4504 4516
4505 4517 2002-04-17 Fernando Perez <fperez@colorado.edu>
4506 4518
4507 4519 * IPython/ipmaker.py (make_IPython): added rc_override option to
4508 4520 allow passing config options at creation time which may override
4509 4521 anything set in the config files or command line. This is
4510 4522 particularly useful for configuring embedded instances.
4511 4523
4512 4524 2002-04-15 Fernando Perez <fperez@colorado.edu>
4513 4525
4514 4526 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
4515 4527 crash embedded instances because of the input cache falling out of
4516 4528 sync with the output counter.
4517 4529
4518 4530 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
4519 4531 mode which calls pdb after an uncaught exception in IPython itself.
4520 4532
4521 4533 2002-04-14 Fernando Perez <fperez@colorado.edu>
4522 4534
4523 4535 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
4524 4536 readline, fix it back after each call.
4525 4537
4526 4538 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
4527 4539 method to force all access via __call__(), which guarantees that
4528 4540 traceback references are properly deleted.
4529 4541
4530 4542 * IPython/Prompts.py (CachedOutput._display): minor fixes to
4531 4543 improve printing when pprint is in use.
4532 4544
4533 4545 2002-04-13 Fernando Perez <fperez@colorado.edu>
4534 4546
4535 4547 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
4536 4548 exceptions aren't caught anymore. If the user triggers one, he
4537 4549 should know why he's doing it and it should go all the way up,
4538 4550 just like any other exception. So now @abort will fully kill the
4539 4551 embedded interpreter and the embedding code (unless that happens
4540 4552 to catch SystemExit).
4541 4553
4542 4554 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
4543 4555 and a debugger() method to invoke the interactive pdb debugger
4544 4556 after printing exception information. Also added the corresponding
4545 4557 -pdb option and @pdb magic to control this feature, and updated
4546 4558 the docs. After a suggestion from Christopher Hart
4547 4559 (hart-AT-caltech.edu).
4548 4560
4549 4561 2002-04-12 Fernando Perez <fperez@colorado.edu>
4550 4562
4551 4563 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
4552 4564 the exception handlers defined by the user (not the CrashHandler)
4553 4565 so that user exceptions don't trigger an ipython bug report.
4554 4566
4555 4567 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
4556 4568 configurable (it should have always been so).
4557 4569
4558 4570 2002-03-26 Fernando Perez <fperez@colorado.edu>
4559 4571
4560 4572 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
4561 4573 and there to fix embedding namespace issues. This should all be
4562 4574 done in a more elegant way.
4563 4575
4564 4576 2002-03-25 Fernando Perez <fperez@colorado.edu>
4565 4577
4566 4578 * IPython/genutils.py (get_home_dir): Try to make it work under
4567 4579 win9x also.
4568 4580
4569 4581 2002-03-20 Fernando Perez <fperez@colorado.edu>
4570 4582
4571 4583 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
4572 4584 sys.displayhook untouched upon __init__.
4573 4585
4574 4586 2002-03-19 Fernando Perez <fperez@colorado.edu>
4575 4587
4576 4588 * Released 0.2.9 (for embedding bug, basically).
4577 4589
4578 4590 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
4579 4591 exceptions so that enclosing shell's state can be restored.
4580 4592
4581 4593 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
4582 4594 naming conventions in the .ipython/ dir.
4583 4595
4584 4596 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
4585 4597 from delimiters list so filenames with - in them get expanded.
4586 4598
4587 4599 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
4588 4600 sys.displayhook not being properly restored after an embedded call.
4589 4601
4590 4602 2002-03-18 Fernando Perez <fperez@colorado.edu>
4591 4603
4592 4604 * Released 0.2.8
4593 4605
4594 4606 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
4595 4607 some files weren't being included in a -upgrade.
4596 4608 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
4597 4609 on' so that the first tab completes.
4598 4610 (InteractiveShell.handle_magic): fixed bug with spaces around
4599 4611 quotes breaking many magic commands.
4600 4612
4601 4613 * setup.py: added note about ignoring the syntax error messages at
4602 4614 installation.
4603 4615
4604 4616 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
4605 4617 streamlining the gnuplot interface, now there's only one magic @gp.
4606 4618
4607 4619 2002-03-17 Fernando Perez <fperez@colorado.edu>
4608 4620
4609 4621 * IPython/UserConfig/magic_gnuplot.py: new name for the
4610 4622 example-magic_pm.py file. Much enhanced system, now with a shell
4611 4623 for communicating directly with gnuplot, one command at a time.
4612 4624
4613 4625 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
4614 4626 setting __name__=='__main__'.
4615 4627
4616 4628 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
4617 4629 mini-shell for accessing gnuplot from inside ipython. Should
4618 4630 extend it later for grace access too. Inspired by Arnd's
4619 4631 suggestion.
4620 4632
4621 4633 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
4622 4634 calling magic functions with () in their arguments. Thanks to Arnd
4623 4635 Baecker for pointing this to me.
4624 4636
4625 4637 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
4626 4638 infinitely for integer or complex arrays (only worked with floats).
4627 4639
4628 4640 2002-03-16 Fernando Perez <fperez@colorado.edu>
4629 4641
4630 4642 * setup.py: Merged setup and setup_windows into a single script
4631 4643 which properly handles things for windows users.
4632 4644
4633 4645 2002-03-15 Fernando Perez <fperez@colorado.edu>
4634 4646
4635 4647 * Big change to the manual: now the magics are all automatically
4636 4648 documented. This information is generated from their docstrings
4637 4649 and put in a latex file included by the manual lyx file. This way
4638 4650 we get always up to date information for the magics. The manual
4639 4651 now also has proper version information, also auto-synced.
4640 4652
4641 4653 For this to work, an undocumented --magic_docstrings option was added.
4642 4654
4643 4655 2002-03-13 Fernando Perez <fperez@colorado.edu>
4644 4656
4645 4657 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
4646 4658 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
4647 4659
4648 4660 2002-03-12 Fernando Perez <fperez@colorado.edu>
4649 4661
4650 4662 * IPython/ultraTB.py (TermColors): changed color escapes again to
4651 4663 fix the (old, reintroduced) line-wrapping bug. Basically, if
4652 4664 \001..\002 aren't given in the color escapes, lines get wrapped
4653 4665 weirdly. But giving those screws up old xterms and emacs terms. So
4654 4666 I added some logic for emacs terms to be ok, but I can't identify old
4655 4667 xterms separately ($TERM=='xterm' for many terminals, like konsole).
4656 4668
4657 4669 2002-03-10 Fernando Perez <fperez@colorado.edu>
4658 4670
4659 4671 * IPython/usage.py (__doc__): Various documentation cleanups and
4660 4672 updates, both in usage docstrings and in the manual.
4661 4673
4662 4674 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
4663 4675 handling of caching. Set minimum acceptabe value for having a
4664 4676 cache at 20 values.
4665 4677
4666 4678 * IPython/iplib.py (InteractiveShell.user_setup): moved the
4667 4679 install_first_time function to a method, renamed it and added an
4668 4680 'upgrade' mode. Now people can update their config directory with
4669 4681 a simple command line switch (-upgrade, also new).
4670 4682
4671 4683 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
4672 4684 @file (convenient for automagic users under Python >= 2.2).
4673 4685 Removed @files (it seemed more like a plural than an abbrev. of
4674 4686 'file show').
4675 4687
4676 4688 * IPython/iplib.py (install_first_time): Fixed crash if there were
4677 4689 backup files ('~') in .ipython/ install directory.
4678 4690
4679 4691 * IPython/ipmaker.py (make_IPython): fixes for new prompt
4680 4692 system. Things look fine, but these changes are fairly
4681 4693 intrusive. Test them for a few days.
4682 4694
4683 4695 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
4684 4696 the prompts system. Now all in/out prompt strings are user
4685 4697 controllable. This is particularly useful for embedding, as one
4686 4698 can tag embedded instances with particular prompts.
4687 4699
4688 4700 Also removed global use of sys.ps1/2, which now allows nested
4689 4701 embeddings without any problems. Added command-line options for
4690 4702 the prompt strings.
4691 4703
4692 4704 2002-03-08 Fernando Perez <fperez@colorado.edu>
4693 4705
4694 4706 * IPython/UserConfig/example-embed-short.py (ipshell): added
4695 4707 example file with the bare minimum code for embedding.
4696 4708
4697 4709 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
4698 4710 functionality for the embeddable shell to be activated/deactivated
4699 4711 either globally or at each call.
4700 4712
4701 4713 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
4702 4714 rewriting the prompt with '--->' for auto-inputs with proper
4703 4715 coloring. Now the previous UGLY hack in handle_auto() is gone, and
4704 4716 this is handled by the prompts class itself, as it should.
4705 4717
4706 4718 2002-03-05 Fernando Perez <fperez@colorado.edu>
4707 4719
4708 4720 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
4709 4721 @logstart to avoid name clashes with the math log function.
4710 4722
4711 4723 * Big updates to X/Emacs section of the manual.
4712 4724
4713 4725 * Removed ipython_emacs. Milan explained to me how to pass
4714 4726 arguments to ipython through Emacs. Some day I'm going to end up
4715 4727 learning some lisp...
4716 4728
4717 4729 2002-03-04 Fernando Perez <fperez@colorado.edu>
4718 4730
4719 4731 * IPython/ipython_emacs: Created script to be used as the
4720 4732 py-python-command Emacs variable so we can pass IPython
4721 4733 parameters. I can't figure out how to tell Emacs directly to pass
4722 4734 parameters to IPython, so a dummy shell script will do it.
4723 4735
4724 4736 Other enhancements made for things to work better under Emacs'
4725 4737 various types of terminals. Many thanks to Milan Zamazal
4726 4738 <pdm-AT-zamazal.org> for all the suggestions and pointers.
4727 4739
4728 4740 2002-03-01 Fernando Perez <fperez@colorado.edu>
4729 4741
4730 4742 * IPython/ipmaker.py (make_IPython): added a --readline! option so
4731 4743 that loading of readline is now optional. This gives better
4732 4744 control to emacs users.
4733 4745
4734 4746 * IPython/ultraTB.py (__date__): Modified color escape sequences
4735 4747 and now things work fine under xterm and in Emacs' term buffers
4736 4748 (though not shell ones). Well, in emacs you get colors, but all
4737 4749 seem to be 'light' colors (no difference between dark and light
4738 4750 ones). But the garbage chars are gone, and also in xterms. It
4739 4751 seems that now I'm using 'cleaner' ansi sequences.
4740 4752
4741 4753 2002-02-21 Fernando Perez <fperez@colorado.edu>
4742 4754
4743 4755 * Released 0.2.7 (mainly to publish the scoping fix).
4744 4756
4745 4757 * IPython/Logger.py (Logger.logstate): added. A corresponding
4746 4758 @logstate magic was created.
4747 4759
4748 4760 * IPython/Magic.py: fixed nested scoping problem under Python
4749 4761 2.1.x (automagic wasn't working).
4750 4762
4751 4763 2002-02-20 Fernando Perez <fperez@colorado.edu>
4752 4764
4753 4765 * Released 0.2.6.
4754 4766
4755 4767 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
4756 4768 option so that logs can come out without any headers at all.
4757 4769
4758 4770 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
4759 4771 SciPy.
4760 4772
4761 4773 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
4762 4774 that embedded IPython calls don't require vars() to be explicitly
4763 4775 passed. Now they are extracted from the caller's frame (code
4764 4776 snatched from Eric Jones' weave). Added better documentation to
4765 4777 the section on embedding and the example file.
4766 4778
4767 4779 * IPython/genutils.py (page): Changed so that under emacs, it just
4768 4780 prints the string. You can then page up and down in the emacs
4769 4781 buffer itself. This is how the builtin help() works.
4770 4782
4771 4783 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
4772 4784 macro scoping: macros need to be executed in the user's namespace
4773 4785 to work as if they had been typed by the user.
4774 4786
4775 4787 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
4776 4788 execute automatically (no need to type 'exec...'). They then
4777 4789 behave like 'true macros'. The printing system was also modified
4778 4790 for this to work.
4779 4791
4780 4792 2002-02-19 Fernando Perez <fperez@colorado.edu>
4781 4793
4782 4794 * IPython/genutils.py (page_file): new function for paging files
4783 4795 in an OS-independent way. Also necessary for file viewing to work
4784 4796 well inside Emacs buffers.
4785 4797 (page): Added checks for being in an emacs buffer.
4786 4798 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
4787 4799 same bug in iplib.
4788 4800
4789 4801 2002-02-18 Fernando Perez <fperez@colorado.edu>
4790 4802
4791 4803 * IPython/iplib.py (InteractiveShell.init_readline): modified use
4792 4804 of readline so that IPython can work inside an Emacs buffer.
4793 4805
4794 4806 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
4795 4807 method signatures (they weren't really bugs, but it looks cleaner
4796 4808 and keeps PyChecker happy).
4797 4809
4798 4810 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
4799 4811 for implementing various user-defined hooks. Currently only
4800 4812 display is done.
4801 4813
4802 4814 * IPython/Prompts.py (CachedOutput._display): changed display
4803 4815 functions so that they can be dynamically changed by users easily.
4804 4816
4805 4817 * IPython/Extensions/numeric_formats.py (num_display): added an
4806 4818 extension for printing NumPy arrays in flexible manners. It
4807 4819 doesn't do anything yet, but all the structure is in
4808 4820 place. Ultimately the plan is to implement output format control
4809 4821 like in Octave.
4810 4822
4811 4823 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
4812 4824 methods are found at run-time by all the automatic machinery.
4813 4825
4814 4826 2002-02-17 Fernando Perez <fperez@colorado.edu>
4815 4827
4816 4828 * setup_Windows.py (make_shortcut): documented. Cleaned up the
4817 4829 whole file a little.
4818 4830
4819 4831 * ToDo: closed this document. Now there's a new_design.lyx
4820 4832 document for all new ideas. Added making a pdf of it for the
4821 4833 end-user distro.
4822 4834
4823 4835 * IPython/Logger.py (Logger.switch_log): Created this to replace
4824 4836 logon() and logoff(). It also fixes a nasty crash reported by
4825 4837 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
4826 4838
4827 4839 * IPython/iplib.py (complete): got auto-completion to work with
4828 4840 automagic (I had wanted this for a long time).
4829 4841
4830 4842 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
4831 4843 to @file, since file() is now a builtin and clashes with automagic
4832 4844 for @file.
4833 4845
4834 4846 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
4835 4847 of this was previously in iplib, which had grown to more than 2000
4836 4848 lines, way too long. No new functionality, but it makes managing
4837 4849 the code a bit easier.
4838 4850
4839 4851 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
4840 4852 information to crash reports.
4841 4853
4842 4854 2002-02-12 Fernando Perez <fperez@colorado.edu>
4843 4855
4844 4856 * Released 0.2.5.
4845 4857
4846 4858 2002-02-11 Fernando Perez <fperez@colorado.edu>
4847 4859
4848 4860 * Wrote a relatively complete Windows installer. It puts
4849 4861 everything in place, creates Start Menu entries and fixes the
4850 4862 color issues. Nothing fancy, but it works.
4851 4863
4852 4864 2002-02-10 Fernando Perez <fperez@colorado.edu>
4853 4865
4854 4866 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
4855 4867 os.path.expanduser() call so that we can type @run ~/myfile.py and
4856 4868 have thigs work as expected.
4857 4869
4858 4870 * IPython/genutils.py (page): fixed exception handling so things
4859 4871 work both in Unix and Windows correctly. Quitting a pager triggers
4860 4872 an IOError/broken pipe in Unix, and in windows not finding a pager
4861 4873 is also an IOError, so I had to actually look at the return value
4862 4874 of the exception, not just the exception itself. Should be ok now.
4863 4875
4864 4876 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
4865 4877 modified to allow case-insensitive color scheme changes.
4866 4878
4867 4879 2002-02-09 Fernando Perez <fperez@colorado.edu>
4868 4880
4869 4881 * IPython/genutils.py (native_line_ends): new function to leave
4870 4882 user config files with os-native line-endings.
4871 4883
4872 4884 * README and manual updates.
4873 4885
4874 4886 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
4875 4887 instead of StringType to catch Unicode strings.
4876 4888
4877 4889 * IPython/genutils.py (filefind): fixed bug for paths with
4878 4890 embedded spaces (very common in Windows).
4879 4891
4880 4892 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
4881 4893 files under Windows, so that they get automatically associated
4882 4894 with a text editor. Windows makes it a pain to handle
4883 4895 extension-less files.
4884 4896
4885 4897 * IPython/iplib.py (InteractiveShell.init_readline): Made the
4886 4898 warning about readline only occur for Posix. In Windows there's no
4887 4899 way to get readline, so why bother with the warning.
4888 4900
4889 4901 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
4890 4902 for __str__ instead of dir(self), since dir() changed in 2.2.
4891 4903
4892 4904 * Ported to Windows! Tested on XP, I suspect it should work fine
4893 4905 on NT/2000, but I don't think it will work on 98 et al. That
4894 4906 series of Windows is such a piece of junk anyway that I won't try
4895 4907 porting it there. The XP port was straightforward, showed a few
4896 4908 bugs here and there (fixed all), in particular some string
4897 4909 handling stuff which required considering Unicode strings (which
4898 4910 Windows uses). This is good, but hasn't been too tested :) No
4899 4911 fancy installer yet, I'll put a note in the manual so people at
4900 4912 least make manually a shortcut.
4901 4913
4902 4914 * IPython/iplib.py (Magic.magic_colors): Unified the color options
4903 4915 into a single one, "colors". This now controls both prompt and
4904 4916 exception color schemes, and can be changed both at startup
4905 4917 (either via command-line switches or via ipythonrc files) and at
4906 4918 runtime, with @colors.
4907 4919 (Magic.magic_run): renamed @prun to @run and removed the old
4908 4920 @run. The two were too similar to warrant keeping both.
4909 4921
4910 4922 2002-02-03 Fernando Perez <fperez@colorado.edu>
4911 4923
4912 4924 * IPython/iplib.py (install_first_time): Added comment on how to
4913 4925 configure the color options for first-time users. Put a <return>
4914 4926 request at the end so that small-terminal users get a chance to
4915 4927 read the startup info.
4916 4928
4917 4929 2002-01-23 Fernando Perez <fperez@colorado.edu>
4918 4930
4919 4931 * IPython/iplib.py (CachedOutput.update): Changed output memory
4920 4932 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
4921 4933 input history we still use _i. Did this b/c these variable are
4922 4934 very commonly used in interactive work, so the less we need to
4923 4935 type the better off we are.
4924 4936 (Magic.magic_prun): updated @prun to better handle the namespaces
4925 4937 the file will run in, including a fix for __name__ not being set
4926 4938 before.
4927 4939
4928 4940 2002-01-20 Fernando Perez <fperez@colorado.edu>
4929 4941
4930 4942 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
4931 4943 extra garbage for Python 2.2. Need to look more carefully into
4932 4944 this later.
4933 4945
4934 4946 2002-01-19 Fernando Perez <fperez@colorado.edu>
4935 4947
4936 4948 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
4937 4949 display SyntaxError exceptions properly formatted when they occur
4938 4950 (they can be triggered by imported code).
4939 4951
4940 4952 2002-01-18 Fernando Perez <fperez@colorado.edu>
4941 4953
4942 4954 * IPython/iplib.py (InteractiveShell.safe_execfile): now
4943 4955 SyntaxError exceptions are reported nicely formatted, instead of
4944 4956 spitting out only offset information as before.
4945 4957 (Magic.magic_prun): Added the @prun function for executing
4946 4958 programs with command line args inside IPython.
4947 4959
4948 4960 2002-01-16 Fernando Perez <fperez@colorado.edu>
4949 4961
4950 4962 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
4951 4963 to *not* include the last item given in a range. This brings their
4952 4964 behavior in line with Python's slicing:
4953 4965 a[n1:n2] -> a[n1]...a[n2-1]
4954 4966 It may be a bit less convenient, but I prefer to stick to Python's
4955 4967 conventions *everywhere*, so users never have to wonder.
4956 4968 (Magic.magic_macro): Added @macro function to ease the creation of
4957 4969 macros.
4958 4970
4959 4971 2002-01-05 Fernando Perez <fperez@colorado.edu>
4960 4972
4961 4973 * Released 0.2.4.
4962 4974
4963 4975 * IPython/iplib.py (Magic.magic_pdef):
4964 4976 (InteractiveShell.safe_execfile): report magic lines and error
4965 4977 lines without line numbers so one can easily copy/paste them for
4966 4978 re-execution.
4967 4979
4968 4980 * Updated manual with recent changes.
4969 4981
4970 4982 * IPython/iplib.py (Magic.magic_oinfo): added constructor
4971 4983 docstring printing when class? is called. Very handy for knowing
4972 4984 how to create class instances (as long as __init__ is well
4973 4985 documented, of course :)
4974 4986 (Magic.magic_doc): print both class and constructor docstrings.
4975 4987 (Magic.magic_pdef): give constructor info if passed a class and
4976 4988 __call__ info for callable object instances.
4977 4989
4978 4990 2002-01-04 Fernando Perez <fperez@colorado.edu>
4979 4991
4980 4992 * Made deep_reload() off by default. It doesn't always work
4981 4993 exactly as intended, so it's probably safer to have it off. It's
4982 4994 still available as dreload() anyway, so nothing is lost.
4983 4995
4984 4996 2002-01-02 Fernando Perez <fperez@colorado.edu>
4985 4997
4986 4998 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4987 4999 so I wanted an updated release).
4988 5000
4989 5001 2001-12-27 Fernando Perez <fperez@colorado.edu>
4990 5002
4991 5003 * IPython/iplib.py (InteractiveShell.interact): Added the original
4992 5004 code from 'code.py' for this module in order to change the
4993 5005 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4994 5006 the history cache would break when the user hit Ctrl-C, and
4995 5007 interact() offers no way to add any hooks to it.
4996 5008
4997 5009 2001-12-23 Fernando Perez <fperez@colorado.edu>
4998 5010
4999 5011 * setup.py: added check for 'MANIFEST' before trying to remove
5000 5012 it. Thanks to Sean Reifschneider.
5001 5013
5002 5014 2001-12-22 Fernando Perez <fperez@colorado.edu>
5003 5015
5004 5016 * Released 0.2.2.
5005 5017
5006 5018 * Finished (reasonably) writing the manual. Later will add the
5007 5019 python-standard navigation stylesheets, but for the time being
5008 5020 it's fairly complete. Distribution will include html and pdf
5009 5021 versions.
5010 5022
5011 5023 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5012 5024 (MayaVi author).
5013 5025
5014 5026 2001-12-21 Fernando Perez <fperez@colorado.edu>
5015 5027
5016 5028 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5017 5029 good public release, I think (with the manual and the distutils
5018 5030 installer). The manual can use some work, but that can go
5019 5031 slowly. Otherwise I think it's quite nice for end users. Next
5020 5032 summer, rewrite the guts of it...
5021 5033
5022 5034 * Changed format of ipythonrc files to use whitespace as the
5023 5035 separator instead of an explicit '='. Cleaner.
5024 5036
5025 5037 2001-12-20 Fernando Perez <fperez@colorado.edu>
5026 5038
5027 5039 * Started a manual in LyX. For now it's just a quick merge of the
5028 5040 various internal docstrings and READMEs. Later it may grow into a
5029 5041 nice, full-blown manual.
5030 5042
5031 5043 * Set up a distutils based installer. Installation should now be
5032 5044 trivially simple for end-users.
5033 5045
5034 5046 2001-12-11 Fernando Perez <fperez@colorado.edu>
5035 5047
5036 5048 * Released 0.2.0. First public release, announced it at
5037 5049 comp.lang.python. From now on, just bugfixes...
5038 5050
5039 5051 * Went through all the files, set copyright/license notices and
5040 5052 cleaned up things. Ready for release.
5041 5053
5042 5054 2001-12-10 Fernando Perez <fperez@colorado.edu>
5043 5055
5044 5056 * Changed the first-time installer not to use tarfiles. It's more
5045 5057 robust now and less unix-dependent. Also makes it easier for
5046 5058 people to later upgrade versions.
5047 5059
5048 5060 * Changed @exit to @abort to reflect the fact that it's pretty
5049 5061 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5050 5062 becomes significant only when IPyhton is embedded: in that case,
5051 5063 C-D closes IPython only, but @abort kills the enclosing program
5052 5064 too (unless it had called IPython inside a try catching
5053 5065 SystemExit).
5054 5066
5055 5067 * Created Shell module which exposes the actuall IPython Shell
5056 5068 classes, currently the normal and the embeddable one. This at
5057 5069 least offers a stable interface we won't need to change when
5058 5070 (later) the internals are rewritten. That rewrite will be confined
5059 5071 to iplib and ipmaker, but the Shell interface should remain as is.
5060 5072
5061 5073 * Added embed module which offers an embeddable IPShell object,
5062 5074 useful to fire up IPython *inside* a running program. Great for
5063 5075 debugging or dynamical data analysis.
5064 5076
5065 5077 2001-12-08 Fernando Perez <fperez@colorado.edu>
5066 5078
5067 5079 * Fixed small bug preventing seeing info from methods of defined
5068 5080 objects (incorrect namespace in _ofind()).
5069 5081
5070 5082 * Documentation cleanup. Moved the main usage docstrings to a
5071 5083 separate file, usage.py (cleaner to maintain, and hopefully in the
5072 5084 future some perlpod-like way of producing interactive, man and
5073 5085 html docs out of it will be found).
5074 5086
5075 5087 * Added @profile to see your profile at any time.
5076 5088
5077 5089 * Added @p as an alias for 'print'. It's especially convenient if
5078 5090 using automagic ('p x' prints x).
5079 5091
5080 5092 * Small cleanups and fixes after a pychecker run.
5081 5093
5082 5094 * Changed the @cd command to handle @cd - and @cd -<n> for
5083 5095 visiting any directory in _dh.
5084 5096
5085 5097 * Introduced _dh, a history of visited directories. @dhist prints
5086 5098 it out with numbers.
5087 5099
5088 5100 2001-12-07 Fernando Perez <fperez@colorado.edu>
5089 5101
5090 5102 * Released 0.1.22
5091 5103
5092 5104 * Made initialization a bit more robust against invalid color
5093 5105 options in user input (exit, not traceback-crash).
5094 5106
5095 5107 * Changed the bug crash reporter to write the report only in the
5096 5108 user's .ipython directory. That way IPython won't litter people's
5097 5109 hard disks with crash files all over the place. Also print on
5098 5110 screen the necessary mail command.
5099 5111
5100 5112 * With the new ultraTB, implemented LightBG color scheme for light
5101 5113 background terminals. A lot of people like white backgrounds, so I
5102 5114 guess we should at least give them something readable.
5103 5115
5104 5116 2001-12-06 Fernando Perez <fperez@colorado.edu>
5105 5117
5106 5118 * Modified the structure of ultraTB. Now there's a proper class
5107 5119 for tables of color schemes which allow adding schemes easily and
5108 5120 switching the active scheme without creating a new instance every
5109 5121 time (which was ridiculous). The syntax for creating new schemes
5110 5122 is also cleaner. I think ultraTB is finally done, with a clean
5111 5123 class structure. Names are also much cleaner (now there's proper
5112 5124 color tables, no need for every variable to also have 'color' in
5113 5125 its name).
5114 5126
5115 5127 * Broke down genutils into separate files. Now genutils only
5116 5128 contains utility functions, and classes have been moved to their
5117 5129 own files (they had enough independent functionality to warrant
5118 5130 it): ConfigLoader, OutputTrap, Struct.
5119 5131
5120 5132 2001-12-05 Fernando Perez <fperez@colorado.edu>
5121 5133
5122 5134 * IPython turns 21! Released version 0.1.21, as a candidate for
5123 5135 public consumption. If all goes well, release in a few days.
5124 5136
5125 5137 * Fixed path bug (files in Extensions/ directory wouldn't be found
5126 5138 unless IPython/ was explicitly in sys.path).
5127 5139
5128 5140 * Extended the FlexCompleter class as MagicCompleter to allow
5129 5141 completion of @-starting lines.
5130 5142
5131 5143 * Created __release__.py file as a central repository for release
5132 5144 info that other files can read from.
5133 5145
5134 5146 * Fixed small bug in logging: when logging was turned on in
5135 5147 mid-session, old lines with special meanings (!@?) were being
5136 5148 logged without the prepended comment, which is necessary since
5137 5149 they are not truly valid python syntax. This should make session
5138 5150 restores produce less errors.
5139 5151
5140 5152 * The namespace cleanup forced me to make a FlexCompleter class
5141 5153 which is nothing but a ripoff of rlcompleter, but with selectable
5142 5154 namespace (rlcompleter only works in __main__.__dict__). I'll try
5143 5155 to submit a note to the authors to see if this change can be
5144 5156 incorporated in future rlcompleter releases (Dec.6: done)
5145 5157
5146 5158 * More fixes to namespace handling. It was a mess! Now all
5147 5159 explicit references to __main__.__dict__ are gone (except when
5148 5160 really needed) and everything is handled through the namespace
5149 5161 dicts in the IPython instance. We seem to be getting somewhere
5150 5162 with this, finally...
5151 5163
5152 5164 * Small documentation updates.
5153 5165
5154 5166 * Created the Extensions directory under IPython (with an
5155 5167 __init__.py). Put the PhysicalQ stuff there. This directory should
5156 5168 be used for all special-purpose extensions.
5157 5169
5158 5170 * File renaming:
5159 5171 ipythonlib --> ipmaker
5160 5172 ipplib --> iplib
5161 5173 This makes a bit more sense in terms of what these files actually do.
5162 5174
5163 5175 * Moved all the classes and functions in ipythonlib to ipplib, so
5164 5176 now ipythonlib only has make_IPython(). This will ease up its
5165 5177 splitting in smaller functional chunks later.
5166 5178
5167 5179 * Cleaned up (done, I think) output of @whos. Better column
5168 5180 formatting, and now shows str(var) for as much as it can, which is
5169 5181 typically what one gets with a 'print var'.
5170 5182
5171 5183 2001-12-04 Fernando Perez <fperez@colorado.edu>
5172 5184
5173 5185 * Fixed namespace problems. Now builtin/IPyhton/user names get
5174 5186 properly reported in their namespace. Internal namespace handling
5175 5187 is finally getting decent (not perfect yet, but much better than
5176 5188 the ad-hoc mess we had).
5177 5189
5178 5190 * Removed -exit option. If people just want to run a python
5179 5191 script, that's what the normal interpreter is for. Less
5180 5192 unnecessary options, less chances for bugs.
5181 5193
5182 5194 * Added a crash handler which generates a complete post-mortem if
5183 5195 IPython crashes. This will help a lot in tracking bugs down the
5184 5196 road.
5185 5197
5186 5198 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5187 5199 which were boud to functions being reassigned would bypass the
5188 5200 logger, breaking the sync of _il with the prompt counter. This
5189 5201 would then crash IPython later when a new line was logged.
5190 5202
5191 5203 2001-12-02 Fernando Perez <fperez@colorado.edu>
5192 5204
5193 5205 * Made IPython a package. This means people don't have to clutter
5194 5206 their sys.path with yet another directory. Changed the INSTALL
5195 5207 file accordingly.
5196 5208
5197 5209 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5198 5210 sorts its output (so @who shows it sorted) and @whos formats the
5199 5211 table according to the width of the first column. Nicer, easier to
5200 5212 read. Todo: write a generic table_format() which takes a list of
5201 5213 lists and prints it nicely formatted, with optional row/column
5202 5214 separators and proper padding and justification.
5203 5215
5204 5216 * Released 0.1.20
5205 5217
5206 5218 * Fixed bug in @log which would reverse the inputcache list (a
5207 5219 copy operation was missing).
5208 5220
5209 5221 * Code cleanup. @config was changed to use page(). Better, since
5210 5222 its output is always quite long.
5211 5223
5212 5224 * Itpl is back as a dependency. I was having too many problems
5213 5225 getting the parametric aliases to work reliably, and it's just
5214 5226 easier to code weird string operations with it than playing %()s
5215 5227 games. It's only ~6k, so I don't think it's too big a deal.
5216 5228
5217 5229 * Found (and fixed) a very nasty bug with history. !lines weren't
5218 5230 getting cached, and the out of sync caches would crash
5219 5231 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5220 5232 division of labor a bit better. Bug fixed, cleaner structure.
5221 5233
5222 5234 2001-12-01 Fernando Perez <fperez@colorado.edu>
5223 5235
5224 5236 * Released 0.1.19
5225 5237
5226 5238 * Added option -n to @hist to prevent line number printing. Much
5227 5239 easier to copy/paste code this way.
5228 5240
5229 5241 * Created global _il to hold the input list. Allows easy
5230 5242 re-execution of blocks of code by slicing it (inspired by Janko's
5231 5243 comment on 'macros').
5232 5244
5233 5245 * Small fixes and doc updates.
5234 5246
5235 5247 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5236 5248 much too fragile with automagic. Handles properly multi-line
5237 5249 statements and takes parameters.
5238 5250
5239 5251 2001-11-30 Fernando Perez <fperez@colorado.edu>
5240 5252
5241 5253 * Version 0.1.18 released.
5242 5254
5243 5255 * Fixed nasty namespace bug in initial module imports.
5244 5256
5245 5257 * Added copyright/license notes to all code files (except
5246 5258 DPyGetOpt). For the time being, LGPL. That could change.
5247 5259
5248 5260 * Rewrote a much nicer README, updated INSTALL, cleaned up
5249 5261 ipythonrc-* samples.
5250 5262
5251 5263 * Overall code/documentation cleanup. Basically ready for
5252 5264 release. Only remaining thing: licence decision (LGPL?).
5253 5265
5254 5266 * Converted load_config to a class, ConfigLoader. Now recursion
5255 5267 control is better organized. Doesn't include the same file twice.
5256 5268
5257 5269 2001-11-29 Fernando Perez <fperez@colorado.edu>
5258 5270
5259 5271 * Got input history working. Changed output history variables from
5260 5272 _p to _o so that _i is for input and _o for output. Just cleaner
5261 5273 convention.
5262 5274
5263 5275 * Implemented parametric aliases. This pretty much allows the
5264 5276 alias system to offer full-blown shell convenience, I think.
5265 5277
5266 5278 * Version 0.1.17 released, 0.1.18 opened.
5267 5279
5268 5280 * dot_ipython/ipythonrc (alias): added documentation.
5269 5281 (xcolor): Fixed small bug (xcolors -> xcolor)
5270 5282
5271 5283 * Changed the alias system. Now alias is a magic command to define
5272 5284 aliases just like the shell. Rationale: the builtin magics should
5273 5285 be there for things deeply connected to IPython's
5274 5286 architecture. And this is a much lighter system for what I think
5275 5287 is the really important feature: allowing users to define quickly
5276 5288 magics that will do shell things for them, so they can customize
5277 5289 IPython easily to match their work habits. If someone is really
5278 5290 desperate to have another name for a builtin alias, they can
5279 5291 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5280 5292 works.
5281 5293
5282 5294 2001-11-28 Fernando Perez <fperez@colorado.edu>
5283 5295
5284 5296 * Changed @file so that it opens the source file at the proper
5285 5297 line. Since it uses less, if your EDITOR environment is
5286 5298 configured, typing v will immediately open your editor of choice
5287 5299 right at the line where the object is defined. Not as quick as
5288 5300 having a direct @edit command, but for all intents and purposes it
5289 5301 works. And I don't have to worry about writing @edit to deal with
5290 5302 all the editors, less does that.
5291 5303
5292 5304 * Version 0.1.16 released, 0.1.17 opened.
5293 5305
5294 5306 * Fixed some nasty bugs in the page/page_dumb combo that could
5295 5307 crash IPython.
5296 5308
5297 5309 2001-11-27 Fernando Perez <fperez@colorado.edu>
5298 5310
5299 5311 * Version 0.1.15 released, 0.1.16 opened.
5300 5312
5301 5313 * Finally got ? and ?? to work for undefined things: now it's
5302 5314 possible to type {}.get? and get information about the get method
5303 5315 of dicts, or os.path? even if only os is defined (so technically
5304 5316 os.path isn't). Works at any level. For example, after import os,
5305 5317 os?, os.path?, os.path.abspath? all work. This is great, took some
5306 5318 work in _ofind.
5307 5319
5308 5320 * Fixed more bugs with logging. The sanest way to do it was to add
5309 5321 to @log a 'mode' parameter. Killed two in one shot (this mode
5310 5322 option was a request of Janko's). I think it's finally clean
5311 5323 (famous last words).
5312 5324
5313 5325 * Added a page_dumb() pager which does a decent job of paging on
5314 5326 screen, if better things (like less) aren't available. One less
5315 5327 unix dependency (someday maybe somebody will port this to
5316 5328 windows).
5317 5329
5318 5330 * Fixed problem in magic_log: would lock of logging out if log
5319 5331 creation failed (because it would still think it had succeeded).
5320 5332
5321 5333 * Improved the page() function using curses to auto-detect screen
5322 5334 size. Now it can make a much better decision on whether to print
5323 5335 or page a string. Option screen_length was modified: a value 0
5324 5336 means auto-detect, and that's the default now.
5325 5337
5326 5338 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
5327 5339 go out. I'll test it for a few days, then talk to Janko about
5328 5340 licences and announce it.
5329 5341
5330 5342 * Fixed the length of the auto-generated ---> prompt which appears
5331 5343 for auto-parens and auto-quotes. Getting this right isn't trivial,
5332 5344 with all the color escapes, different prompt types and optional
5333 5345 separators. But it seems to be working in all the combinations.
5334 5346
5335 5347 2001-11-26 Fernando Perez <fperez@colorado.edu>
5336 5348
5337 5349 * Wrote a regexp filter to get option types from the option names
5338 5350 string. This eliminates the need to manually keep two duplicate
5339 5351 lists.
5340 5352
5341 5353 * Removed the unneeded check_option_names. Now options are handled
5342 5354 in a much saner manner and it's easy to visually check that things
5343 5355 are ok.
5344 5356
5345 5357 * Updated version numbers on all files I modified to carry a
5346 5358 notice so Janko and Nathan have clear version markers.
5347 5359
5348 5360 * Updated docstring for ultraTB with my changes. I should send
5349 5361 this to Nathan.
5350 5362
5351 5363 * Lots of small fixes. Ran everything through pychecker again.
5352 5364
5353 5365 * Made loading of deep_reload an cmd line option. If it's not too
5354 5366 kosher, now people can just disable it. With -nodeep_reload it's
5355 5367 still available as dreload(), it just won't overwrite reload().
5356 5368
5357 5369 * Moved many options to the no| form (-opt and -noopt
5358 5370 accepted). Cleaner.
5359 5371
5360 5372 * Changed magic_log so that if called with no parameters, it uses
5361 5373 'rotate' mode. That way auto-generated logs aren't automatically
5362 5374 over-written. For normal logs, now a backup is made if it exists
5363 5375 (only 1 level of backups). A new 'backup' mode was added to the
5364 5376 Logger class to support this. This was a request by Janko.
5365 5377
5366 5378 * Added @logoff/@logon to stop/restart an active log.
5367 5379
5368 5380 * Fixed a lot of bugs in log saving/replay. It was pretty
5369 5381 broken. Now special lines (!@,/) appear properly in the command
5370 5382 history after a log replay.
5371 5383
5372 5384 * Tried and failed to implement full session saving via pickle. My
5373 5385 idea was to pickle __main__.__dict__, but modules can't be
5374 5386 pickled. This would be a better alternative to replaying logs, but
5375 5387 seems quite tricky to get to work. Changed -session to be called
5376 5388 -logplay, which more accurately reflects what it does. And if we
5377 5389 ever get real session saving working, -session is now available.
5378 5390
5379 5391 * Implemented color schemes for prompts also. As for tracebacks,
5380 5392 currently only NoColor and Linux are supported. But now the
5381 5393 infrastructure is in place, based on a generic ColorScheme
5382 5394 class. So writing and activating new schemes both for the prompts
5383 5395 and the tracebacks should be straightforward.
5384 5396
5385 5397 * Version 0.1.13 released, 0.1.14 opened.
5386 5398
5387 5399 * Changed handling of options for output cache. Now counter is
5388 5400 hardwired starting at 1 and one specifies the maximum number of
5389 5401 entries *in the outcache* (not the max prompt counter). This is
5390 5402 much better, since many statements won't increase the cache
5391 5403 count. It also eliminated some confusing options, now there's only
5392 5404 one: cache_size.
5393 5405
5394 5406 * Added 'alias' magic function and magic_alias option in the
5395 5407 ipythonrc file. Now the user can easily define whatever names he
5396 5408 wants for the magic functions without having to play weird
5397 5409 namespace games. This gives IPython a real shell-like feel.
5398 5410
5399 5411 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
5400 5412 @ or not).
5401 5413
5402 5414 This was one of the last remaining 'visible' bugs (that I know
5403 5415 of). I think if I can clean up the session loading so it works
5404 5416 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
5405 5417 about licensing).
5406 5418
5407 5419 2001-11-25 Fernando Perez <fperez@colorado.edu>
5408 5420
5409 5421 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
5410 5422 there's a cleaner distinction between what ? and ?? show.
5411 5423
5412 5424 * Added screen_length option. Now the user can define his own
5413 5425 screen size for page() operations.
5414 5426
5415 5427 * Implemented magic shell-like functions with automatic code
5416 5428 generation. Now adding another function is just a matter of adding
5417 5429 an entry to a dict, and the function is dynamically generated at
5418 5430 run-time. Python has some really cool features!
5419 5431
5420 5432 * Renamed many options to cleanup conventions a little. Now all
5421 5433 are lowercase, and only underscores where needed. Also in the code
5422 5434 option name tables are clearer.
5423 5435
5424 5436 * Changed prompts a little. Now input is 'In [n]:' instead of
5425 5437 'In[n]:='. This allows it the numbers to be aligned with the
5426 5438 Out[n] numbers, and removes usage of ':=' which doesn't exist in
5427 5439 Python (it was a Mathematica thing). The '...' continuation prompt
5428 5440 was also changed a little to align better.
5429 5441
5430 5442 * Fixed bug when flushing output cache. Not all _p<n> variables
5431 5443 exist, so their deletion needs to be wrapped in a try:
5432 5444
5433 5445 * Figured out how to properly use inspect.formatargspec() (it
5434 5446 requires the args preceded by *). So I removed all the code from
5435 5447 _get_pdef in Magic, which was just replicating that.
5436 5448
5437 5449 * Added test to prefilter to allow redefining magic function names
5438 5450 as variables. This is ok, since the @ form is always available,
5439 5451 but whe should allow the user to define a variable called 'ls' if
5440 5452 he needs it.
5441 5453
5442 5454 * Moved the ToDo information from README into a separate ToDo.
5443 5455
5444 5456 * General code cleanup and small bugfixes. I think it's close to a
5445 5457 state where it can be released, obviously with a big 'beta'
5446 5458 warning on it.
5447 5459
5448 5460 * Got the magic function split to work. Now all magics are defined
5449 5461 in a separate class. It just organizes things a bit, and now
5450 5462 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
5451 5463 was too long).
5452 5464
5453 5465 * Changed @clear to @reset to avoid potential confusions with
5454 5466 the shell command clear. Also renamed @cl to @clear, which does
5455 5467 exactly what people expect it to from their shell experience.
5456 5468
5457 5469 Added a check to the @reset command (since it's so
5458 5470 destructive, it's probably a good idea to ask for confirmation).
5459 5471 But now reset only works for full namespace resetting. Since the
5460 5472 del keyword is already there for deleting a few specific
5461 5473 variables, I don't see the point of having a redundant magic
5462 5474 function for the same task.
5463 5475
5464 5476 2001-11-24 Fernando Perez <fperez@colorado.edu>
5465 5477
5466 5478 * Updated the builtin docs (esp. the ? ones).
5467 5479
5468 5480 * Ran all the code through pychecker. Not terribly impressed with
5469 5481 it: lots of spurious warnings and didn't really find anything of
5470 5482 substance (just a few modules being imported and not used).
5471 5483
5472 5484 * Implemented the new ultraTB functionality into IPython. New
5473 5485 option: xcolors. This chooses color scheme. xmode now only selects
5474 5486 between Plain and Verbose. Better orthogonality.
5475 5487
5476 5488 * Large rewrite of ultraTB. Much cleaner now, with a separation of
5477 5489 mode and color scheme for the exception handlers. Now it's
5478 5490 possible to have the verbose traceback with no coloring.
5479 5491
5480 5492 2001-11-23 Fernando Perez <fperez@colorado.edu>
5481 5493
5482 5494 * Version 0.1.12 released, 0.1.13 opened.
5483 5495
5484 5496 * Removed option to set auto-quote and auto-paren escapes by
5485 5497 user. The chances of breaking valid syntax are just too high. If
5486 5498 someone *really* wants, they can always dig into the code.
5487 5499
5488 5500 * Made prompt separators configurable.
5489 5501
5490 5502 2001-11-22 Fernando Perez <fperez@colorado.edu>
5491 5503
5492 5504 * Small bugfixes in many places.
5493 5505
5494 5506 * Removed the MyCompleter class from ipplib. It seemed redundant
5495 5507 with the C-p,C-n history search functionality. Less code to
5496 5508 maintain.
5497 5509
5498 5510 * Moved all the original ipython.py code into ipythonlib.py. Right
5499 5511 now it's just one big dump into a function called make_IPython, so
5500 5512 no real modularity has been gained. But at least it makes the
5501 5513 wrapper script tiny, and since ipythonlib is a module, it gets
5502 5514 compiled and startup is much faster.
5503 5515
5504 5516 This is a reasobably 'deep' change, so we should test it for a
5505 5517 while without messing too much more with the code.
5506 5518
5507 5519 2001-11-21 Fernando Perez <fperez@colorado.edu>
5508 5520
5509 5521 * Version 0.1.11 released, 0.1.12 opened for further work.
5510 5522
5511 5523 * Removed dependency on Itpl. It was only needed in one place. It
5512 5524 would be nice if this became part of python, though. It makes life
5513 5525 *a lot* easier in some cases.
5514 5526
5515 5527 * Simplified the prefilter code a bit. Now all handlers are
5516 5528 expected to explicitly return a value (at least a blank string).
5517 5529
5518 5530 * Heavy edits in ipplib. Removed the help system altogether. Now
5519 5531 obj?/?? is used for inspecting objects, a magic @doc prints
5520 5532 docstrings, and full-blown Python help is accessed via the 'help'
5521 5533 keyword. This cleans up a lot of code (less to maintain) and does
5522 5534 the job. Since 'help' is now a standard Python component, might as
5523 5535 well use it and remove duplicate functionality.
5524 5536
5525 5537 Also removed the option to use ipplib as a standalone program. By
5526 5538 now it's too dependent on other parts of IPython to function alone.
5527 5539
5528 5540 * Fixed bug in genutils.pager. It would crash if the pager was
5529 5541 exited immediately after opening (broken pipe).
5530 5542
5531 5543 * Trimmed down the VerboseTB reporting a little. The header is
5532 5544 much shorter now and the repeated exception arguments at the end
5533 5545 have been removed. For interactive use the old header seemed a bit
5534 5546 excessive.
5535 5547
5536 5548 * Fixed small bug in output of @whos for variables with multi-word
5537 5549 types (only first word was displayed).
5538 5550
5539 5551 2001-11-17 Fernando Perez <fperez@colorado.edu>
5540 5552
5541 5553 * Version 0.1.10 released, 0.1.11 opened for further work.
5542 5554
5543 5555 * Modified dirs and friends. dirs now *returns* the stack (not
5544 5556 prints), so one can manipulate it as a variable. Convenient to
5545 5557 travel along many directories.
5546 5558
5547 5559 * Fixed bug in magic_pdef: would only work with functions with
5548 5560 arguments with default values.
5549 5561
5550 5562 2001-11-14 Fernando Perez <fperez@colorado.edu>
5551 5563
5552 5564 * Added the PhysicsInput stuff to dot_ipython so it ships as an
5553 5565 example with IPython. Various other minor fixes and cleanups.
5554 5566
5555 5567 * Version 0.1.9 released, 0.1.10 opened for further work.
5556 5568
5557 5569 * Added sys.path to the list of directories searched in the
5558 5570 execfile= option. It used to be the current directory and the
5559 5571 user's IPYTHONDIR only.
5560 5572
5561 5573 2001-11-13 Fernando Perez <fperez@colorado.edu>
5562 5574
5563 5575 * Reinstated the raw_input/prefilter separation that Janko had
5564 5576 initially. This gives a more convenient setup for extending the
5565 5577 pre-processor from the outside: raw_input always gets a string,
5566 5578 and prefilter has to process it. We can then redefine prefilter
5567 5579 from the outside and implement extensions for special
5568 5580 purposes.
5569 5581
5570 5582 Today I got one for inputting PhysicalQuantity objects
5571 5583 (from Scientific) without needing any function calls at
5572 5584 all. Extremely convenient, and it's all done as a user-level
5573 5585 extension (no IPython code was touched). Now instead of:
5574 5586 a = PhysicalQuantity(4.2,'m/s**2')
5575 5587 one can simply say
5576 5588 a = 4.2 m/s**2
5577 5589 or even
5578 5590 a = 4.2 m/s^2
5579 5591
5580 5592 I use this, but it's also a proof of concept: IPython really is
5581 5593 fully user-extensible, even at the level of the parsing of the
5582 5594 command line. It's not trivial, but it's perfectly doable.
5583 5595
5584 5596 * Added 'add_flip' method to inclusion conflict resolver. Fixes
5585 5597 the problem of modules being loaded in the inverse order in which
5586 5598 they were defined in
5587 5599
5588 5600 * Version 0.1.8 released, 0.1.9 opened for further work.
5589 5601
5590 5602 * Added magics pdef, source and file. They respectively show the
5591 5603 definition line ('prototype' in C), source code and full python
5592 5604 file for any callable object. The object inspector oinfo uses
5593 5605 these to show the same information.
5594 5606
5595 5607 * Version 0.1.7 released, 0.1.8 opened for further work.
5596 5608
5597 5609 * Separated all the magic functions into a class called Magic. The
5598 5610 InteractiveShell class was becoming too big for Xemacs to handle
5599 5611 (de-indenting a line would lock it up for 10 seconds while it
5600 5612 backtracked on the whole class!)
5601 5613
5602 5614 FIXME: didn't work. It can be done, but right now namespaces are
5603 5615 all messed up. Do it later (reverted it for now, so at least
5604 5616 everything works as before).
5605 5617
5606 5618 * Got the object introspection system (magic_oinfo) working! I
5607 5619 think this is pretty much ready for release to Janko, so he can
5608 5620 test it for a while and then announce it. Pretty much 100% of what
5609 5621 I wanted for the 'phase 1' release is ready. Happy, tired.
5610 5622
5611 5623 2001-11-12 Fernando Perez <fperez@colorado.edu>
5612 5624
5613 5625 * Version 0.1.6 released, 0.1.7 opened for further work.
5614 5626
5615 5627 * Fixed bug in printing: it used to test for truth before
5616 5628 printing, so 0 wouldn't print. Now checks for None.
5617 5629
5618 5630 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
5619 5631 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
5620 5632 reaches by hand into the outputcache. Think of a better way to do
5621 5633 this later.
5622 5634
5623 5635 * Various small fixes thanks to Nathan's comments.
5624 5636
5625 5637 * Changed magic_pprint to magic_Pprint. This way it doesn't
5626 5638 collide with pprint() and the name is consistent with the command
5627 5639 line option.
5628 5640
5629 5641 * Changed prompt counter behavior to be fully like
5630 5642 Mathematica's. That is, even input that doesn't return a result
5631 5643 raises the prompt counter. The old behavior was kind of confusing
5632 5644 (getting the same prompt number several times if the operation
5633 5645 didn't return a result).
5634 5646
5635 5647 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
5636 5648
5637 5649 * Fixed -Classic mode (wasn't working anymore).
5638 5650
5639 5651 * Added colored prompts using Nathan's new code. Colors are
5640 5652 currently hardwired, they can be user-configurable. For
5641 5653 developers, they can be chosen in file ipythonlib.py, at the
5642 5654 beginning of the CachedOutput class def.
5643 5655
5644 5656 2001-11-11 Fernando Perez <fperez@colorado.edu>
5645 5657
5646 5658 * Version 0.1.5 released, 0.1.6 opened for further work.
5647 5659
5648 5660 * Changed magic_env to *return* the environment as a dict (not to
5649 5661 print it). This way it prints, but it can also be processed.
5650 5662
5651 5663 * Added Verbose exception reporting to interactive
5652 5664 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
5653 5665 traceback. Had to make some changes to the ultraTB file. This is
5654 5666 probably the last 'big' thing in my mental todo list. This ties
5655 5667 in with the next entry:
5656 5668
5657 5669 * Changed -Xi and -Xf to a single -xmode option. Now all the user
5658 5670 has to specify is Plain, Color or Verbose for all exception
5659 5671 handling.
5660 5672
5661 5673 * Removed ShellServices option. All this can really be done via
5662 5674 the magic system. It's easier to extend, cleaner and has automatic
5663 5675 namespace protection and documentation.
5664 5676
5665 5677 2001-11-09 Fernando Perez <fperez@colorado.edu>
5666 5678
5667 5679 * Fixed bug in output cache flushing (missing parameter to
5668 5680 __init__). Other small bugs fixed (found using pychecker).
5669 5681
5670 5682 * Version 0.1.4 opened for bugfixing.
5671 5683
5672 5684 2001-11-07 Fernando Perez <fperez@colorado.edu>
5673 5685
5674 5686 * Version 0.1.3 released, mainly because of the raw_input bug.
5675 5687
5676 5688 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
5677 5689 and when testing for whether things were callable, a call could
5678 5690 actually be made to certain functions. They would get called again
5679 5691 once 'really' executed, with a resulting double call. A disaster
5680 5692 in many cases (list.reverse() would never work!).
5681 5693
5682 5694 * Removed prefilter() function, moved its code to raw_input (which
5683 5695 after all was just a near-empty caller for prefilter). This saves
5684 5696 a function call on every prompt, and simplifies the class a tiny bit.
5685 5697
5686 5698 * Fix _ip to __ip name in magic example file.
5687 5699
5688 5700 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
5689 5701 work with non-gnu versions of tar.
5690 5702
5691 5703 2001-11-06 Fernando Perez <fperez@colorado.edu>
5692 5704
5693 5705 * Version 0.1.2. Just to keep track of the recent changes.
5694 5706
5695 5707 * Fixed nasty bug in output prompt routine. It used to check 'if
5696 5708 arg != None...'. Problem is, this fails if arg implements a
5697 5709 special comparison (__cmp__) which disallows comparing to
5698 5710 None. Found it when trying to use the PhysicalQuantity module from
5699 5711 ScientificPython.
5700 5712
5701 5713 2001-11-05 Fernando Perez <fperez@colorado.edu>
5702 5714
5703 5715 * Also added dirs. Now the pushd/popd/dirs family functions
5704 5716 basically like the shell, with the added convenience of going home
5705 5717 when called with no args.
5706 5718
5707 5719 * pushd/popd slightly modified to mimic shell behavior more
5708 5720 closely.
5709 5721
5710 5722 * Added env,pushd,popd from ShellServices as magic functions. I
5711 5723 think the cleanest will be to port all desired functions from
5712 5724 ShellServices as magics and remove ShellServices altogether. This
5713 5725 will provide a single, clean way of adding functionality
5714 5726 (shell-type or otherwise) to IP.
5715 5727
5716 5728 2001-11-04 Fernando Perez <fperez@colorado.edu>
5717 5729
5718 5730 * Added .ipython/ directory to sys.path. This way users can keep
5719 5731 customizations there and access them via import.
5720 5732
5721 5733 2001-11-03 Fernando Perez <fperez@colorado.edu>
5722 5734
5723 5735 * Opened version 0.1.1 for new changes.
5724 5736
5725 5737 * Changed version number to 0.1.0: first 'public' release, sent to
5726 5738 Nathan and Janko.
5727 5739
5728 5740 * Lots of small fixes and tweaks.
5729 5741
5730 5742 * Minor changes to whos format. Now strings are shown, snipped if
5731 5743 too long.
5732 5744
5733 5745 * Changed ShellServices to work on __main__ so they show up in @who
5734 5746
5735 5747 * Help also works with ? at the end of a line:
5736 5748 ?sin and sin?
5737 5749 both produce the same effect. This is nice, as often I use the
5738 5750 tab-complete to find the name of a method, but I used to then have
5739 5751 to go to the beginning of the line to put a ? if I wanted more
5740 5752 info. Now I can just add the ? and hit return. Convenient.
5741 5753
5742 5754 2001-11-02 Fernando Perez <fperez@colorado.edu>
5743 5755
5744 5756 * Python version check (>=2.1) added.
5745 5757
5746 5758 * Added LazyPython documentation. At this point the docs are quite
5747 5759 a mess. A cleanup is in order.
5748 5760
5749 5761 * Auto-installer created. For some bizarre reason, the zipfiles
5750 5762 module isn't working on my system. So I made a tar version
5751 5763 (hopefully the command line options in various systems won't kill
5752 5764 me).
5753 5765
5754 5766 * Fixes to Struct in genutils. Now all dictionary-like methods are
5755 5767 protected (reasonably).
5756 5768
5757 5769 * Added pager function to genutils and changed ? to print usage
5758 5770 note through it (it was too long).
5759 5771
5760 5772 * Added the LazyPython functionality. Works great! I changed the
5761 5773 auto-quote escape to ';', it's on home row and next to '. But
5762 5774 both auto-quote and auto-paren (still /) escapes are command-line
5763 5775 parameters.
5764 5776
5765 5777
5766 5778 2001-11-01 Fernando Perez <fperez@colorado.edu>
5767 5779
5768 5780 * Version changed to 0.0.7. Fairly large change: configuration now
5769 5781 is all stored in a directory, by default .ipython. There, all
5770 5782 config files have normal looking names (not .names)
5771 5783
5772 5784 * Version 0.0.6 Released first to Lucas and Archie as a test
5773 5785 run. Since it's the first 'semi-public' release, change version to
5774 5786 > 0.0.6 for any changes now.
5775 5787
5776 5788 * Stuff I had put in the ipplib.py changelog:
5777 5789
5778 5790 Changes to InteractiveShell:
5779 5791
5780 5792 - Made the usage message a parameter.
5781 5793
5782 5794 - Require the name of the shell variable to be given. It's a bit
5783 5795 of a hack, but allows the name 'shell' not to be hardwired in the
5784 5796 magic (@) handler, which is problematic b/c it requires
5785 5797 polluting the global namespace with 'shell'. This in turn is
5786 5798 fragile: if a user redefines a variable called shell, things
5787 5799 break.
5788 5800
5789 5801 - magic @: all functions available through @ need to be defined
5790 5802 as magic_<name>, even though they can be called simply as
5791 5803 @<name>. This allows the special command @magic to gather
5792 5804 information automatically about all existing magic functions,
5793 5805 even if they are run-time user extensions, by parsing the shell
5794 5806 instance __dict__ looking for special magic_ names.
5795 5807
5796 5808 - mainloop: added *two* local namespace parameters. This allows
5797 5809 the class to differentiate between parameters which were there
5798 5810 before and after command line initialization was processed. This
5799 5811 way, later @who can show things loaded at startup by the
5800 5812 user. This trick was necessary to make session saving/reloading
5801 5813 really work: ideally after saving/exiting/reloading a session,
5802 5814 *everything* should look the same, including the output of @who. I
5803 5815 was only able to make this work with this double namespace
5804 5816 trick.
5805 5817
5806 5818 - added a header to the logfile which allows (almost) full
5807 5819 session restoring.
5808 5820
5809 5821 - prepend lines beginning with @ or !, with a and log
5810 5822 them. Why? !lines: may be useful to know what you did @lines:
5811 5823 they may affect session state. So when restoring a session, at
5812 5824 least inform the user of their presence. I couldn't quite get
5813 5825 them to properly re-execute, but at least the user is warned.
5814 5826
5815 5827 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now