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