##// END OF EJS Templates
ipapi rehaul, moved api methods to class IPApi. Usage didn't change...
vivainio -
Show More
@@ -1,101 +1,102 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """ IPython extension: add %rehashdir magic
2 """ IPython extension: add %rehashdir magic
3
3
4 Usage:
4 Usage:
5
5
6 %rehashdir c:/bin c:/tools
6 %rehashdir c:/bin c:/tools
7 - Add all executables under c:/bin and c:/tools to alias table, in
7 - Add all executables under c:/bin and c:/tools to alias table, in
8 order to make them directly executable from any directory.
8 order to make them directly executable from any directory.
9
9
10 This also serves as an example on how to extend ipython
10 This also serves as an example on how to extend ipython
11 with new magic functions.
11 with new magic functions.
12
12
13 Unlike rest of ipython, this requires Python 2.4 (optional
13 Unlike rest of ipython, this requires Python 2.4 (optional
14 extensions are allowed to do that).
14 extensions are allowed to do that).
15
15
16 To install, add
16 To install, add
17
17
18 "import_mod ext_rehashdir"
18 "import_mod ext_rehashdir"
19
19
20 To your ipythonrc or just execute "import rehash_dir" in ipython
20 To your ipythonrc or just execute "import rehash_dir" in ipython
21 prompt.
21 prompt.
22
22
23
23
24 $Id: InterpreterExec.py 994 2006-01-08 08:29:44Z fperez $
24 $Id: InterpreterExec.py 994 2006-01-08 08:29:44Z fperez $
25 """
25 """
26
26
27 import IPython.ipapi as ip
27 import IPython.ipapi
28 ip = IPython.ipapi.get()
28
29
29
30
30 import os,re,fnmatch
31 import os,re,fnmatch
31
32
32 @ip.asmagic("rehashdir")
33 def rehashdir_f(self,arg):
33 def rehashdir_f(self,arg):
34 """ Add executables in all specified dirs to alias table
34 """ Add executables in all specified dirs to alias table
35
35
36 Usage:
36 Usage:
37
37
38 %rehashdir c:/bin c:/tools
38 %rehashdir c:/bin c:/tools
39 - Add all executables under c:/bin and c:/tools to alias table, in
39 - Add all executables under c:/bin and c:/tools to alias table, in
40 order to make them directly executable from any directory.
40 order to make them directly executable from any directory.
41
41
42 Without arguments, add all executables in current directory.
42 Without arguments, add all executables in current directory.
43
43
44 """
44 """
45
45
46 # most of the code copied from Magic.magic_rehashx
46 # most of the code copied from Magic.magic_rehashx
47
47
48 def isjunk(fname):
48 def isjunk(fname):
49 junk = ['*~']
49 junk = ['*~']
50 for j in junk:
50 for j in junk:
51 if fnmatch.fnmatch(fname, j):
51 if fnmatch.fnmatch(fname, j):
52 return True
52 return True
53 return False
53 return False
54
54
55 if not arg:
55 if not arg:
56 arg = '.'
56 arg = '.'
57 path = map(os.path.abspath,arg.split())
57 path = map(os.path.abspath,arg.split())
58 alias_table = self.shell.alias_table
58 alias_table = self.shell.alias_table
59
59
60 if os.name == 'posix':
60 if os.name == 'posix':
61 isexec = lambda fname:os.path.isfile(fname) and \
61 isexec = lambda fname:os.path.isfile(fname) and \
62 os.access(fname,os.X_OK)
62 os.access(fname,os.X_OK)
63 else:
63 else:
64
64
65 try:
65 try:
66 winext = os.environ['pathext'].replace(';','|').replace('.','')
66 winext = os.environ['pathext'].replace(';','|').replace('.','')
67 except KeyError:
67 except KeyError:
68 winext = 'exe|com|bat|py'
68 winext = 'exe|com|bat|py'
69
69
70 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
70 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
71 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
71 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
72 savedir = os.getcwd()
72 savedir = os.getcwd()
73 try:
73 try:
74 # write the whole loop for posix/Windows so we don't have an if in
74 # write the whole loop for posix/Windows so we don't have an if in
75 # the innermost part
75 # the innermost part
76 if os.name == 'posix':
76 if os.name == 'posix':
77 for pdir in path:
77 for pdir in path:
78 os.chdir(pdir)
78 os.chdir(pdir)
79 for ff in os.listdir(pdir):
79 for ff in os.listdir(pdir):
80 if isexec(ff) and not isjunk(ff):
80 if isexec(ff) and not isjunk(ff):
81 # each entry in the alias table must be (N,name),
81 # each entry in the alias table must be (N,name),
82 # where N is the number of positional arguments of the
82 # where N is the number of positional arguments of the
83 # alias.
83 # alias.
84 src,tgt = os.path.splitext(ff)[0], os.path.abspath(ff)
84 src,tgt = os.path.splitext(ff)[0], os.path.abspath(ff)
85 print "Aliasing:",src,"->",tgt
85 print "Aliasing:",src,"->",tgt
86 alias_table[src] = (0,tgt)
86 alias_table[src] = (0,tgt)
87 else:
87 else:
88 for pdir in path:
88 for pdir in path:
89 os.chdir(pdir)
89 os.chdir(pdir)
90 for ff in os.listdir(pdir):
90 for ff in os.listdir(pdir):
91 if isexec(ff) and not isjunk(ff):
91 if isexec(ff) and not isjunk(ff):
92 src, tgt = execre.sub(r'\1',ff), os.path.abspath(ff)
92 src, tgt = execre.sub(r'\1',ff), os.path.abspath(ff)
93 print "Aliasing:",src,"->",tgt
93 print "Aliasing:",src,"->",tgt
94 alias_table[src] = (0,tgt)
94 alias_table[src] = (0,tgt)
95 # Make sure the alias table doesn't contain keywords or builtins
95 # Make sure the alias table doesn't contain keywords or builtins
96 self.shell.alias_table_validate()
96 self.shell.alias_table_validate()
97 # Call again init_auto_alias() so we get 'rm -i' and other
97 # Call again init_auto_alias() so we get 'rm -i' and other
98 # modified aliases since %rehashx will probably clobber them
98 # modified aliases since %rehashx will probably clobber them
99 self.shell.init_auto_alias()
99 self.shell.init_auto_alias()
100 finally:
100 finally:
101 os.chdir(savedir)
101 os.chdir(savedir)
102 ip.expose_magic("rehashdir",rehashdir_f)
@@ -1,955 +1,955 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """IPython Shell classes.
2 """IPython Shell classes.
3
3
4 All the matplotlib support code was co-developed with John Hunter,
4 All the matplotlib support code was co-developed with John Hunter,
5 matplotlib's author.
5 matplotlib's author.
6
6
7 $Id: Shell.py 1058 2006-01-22 14:30:01Z vivainio $"""
7 $Id: Shell.py 1079 2006-01-24 21:52:31Z vivainio $"""
8
8
9 #*****************************************************************************
9 #*****************************************************************************
10 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
10 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
11 #
11 #
12 # Distributed under the terms of the BSD License. The full license is in
12 # Distributed under the terms of the BSD License. The full license is in
13 # the file COPYING, distributed as part of this software.
13 # the file COPYING, distributed as part of this software.
14 #*****************************************************************************
14 #*****************************************************************************
15
15
16 from IPython import Release
16 from IPython import Release
17 __author__ = '%s <%s>' % Release.authors['Fernando']
17 __author__ = '%s <%s>' % Release.authors['Fernando']
18 __license__ = Release.license
18 __license__ = Release.license
19
19
20 # Code begins
20 # Code begins
21 import __builtin__
21 import __builtin__
22 import __main__
22 import __main__
23 import Queue
23 import Queue
24 import os
24 import os
25 import signal
25 import signal
26 import sys
26 import sys
27 import threading
27 import threading
28 import time
28 import time
29
29
30 import IPython
30 import IPython
31 from IPython import ultraTB
31 from IPython import ultraTB
32 from IPython.genutils import Term,warn,error,flag_calls
32 from IPython.genutils import Term,warn,error,flag_calls
33 from IPython.iplib import InteractiveShell
33 from IPython.iplib import InteractiveShell
34 from IPython.ipmaker import make_IPython
34 from IPython.ipmaker import make_IPython
35 from IPython.Magic import Magic
35 from IPython.Magic import Magic
36 from IPython.ipstruct import Struct
36 from IPython.ipstruct import Struct
37
37
38 # global flag to pass around information about Ctrl-C without exceptions
38 # global flag to pass around information about Ctrl-C without exceptions
39 KBINT = False
39 KBINT = False
40
40
41 # global flag to turn on/off Tk support.
41 # global flag to turn on/off Tk support.
42 USE_TK = False
42 USE_TK = False
43
43
44 #-----------------------------------------------------------------------------
44 #-----------------------------------------------------------------------------
45 # This class is trivial now, but I want to have it in to publish a clean
45 # This class is trivial now, but I want to have it in to publish a clean
46 # interface. Later when the internals are reorganized, code that uses this
46 # interface. Later when the internals are reorganized, code that uses this
47 # shouldn't have to change.
47 # shouldn't have to change.
48
48
49 class IPShell:
49 class IPShell:
50 """Create an IPython instance."""
50 """Create an IPython instance."""
51
51
52 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
52 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
53 debug=1,shell_class=InteractiveShell):
53 debug=1,shell_class=InteractiveShell):
54 self.IP = make_IPython(argv,user_ns=user_ns,user_global_ns=user_global_ns,
54 self.IP = make_IPython(argv,user_ns=user_ns,user_global_ns=user_global_ns,
55 debug=debug,shell_class=shell_class)
55 debug=debug,shell_class=shell_class)
56
56
57 def mainloop(self,sys_exit=0,banner=None):
57 def mainloop(self,sys_exit=0,banner=None):
58 self.IP.mainloop(banner)
58 self.IP.mainloop(banner)
59 if sys_exit:
59 if sys_exit:
60 sys.exit()
60 sys.exit()
61
61
62 #-----------------------------------------------------------------------------
62 #-----------------------------------------------------------------------------
63 class IPShellEmbed:
63 class IPShellEmbed:
64 """Allow embedding an IPython shell into a running program.
64 """Allow embedding an IPython shell into a running program.
65
65
66 Instances of this class are callable, with the __call__ method being an
66 Instances of this class are callable, with the __call__ method being an
67 alias to the embed() method of an InteractiveShell instance.
67 alias to the embed() method of an InteractiveShell instance.
68
68
69 Usage (see also the example-embed.py file for a running example):
69 Usage (see also the example-embed.py file for a running example):
70
70
71 ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override])
71 ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override])
72
72
73 - argv: list containing valid command-line options for IPython, as they
73 - argv: list containing valid command-line options for IPython, as they
74 would appear in sys.argv[1:].
74 would appear in sys.argv[1:].
75
75
76 For example, the following command-line options:
76 For example, the following command-line options:
77
77
78 $ ipython -prompt_in1 'Input <\\#>' -colors LightBG
78 $ ipython -prompt_in1 'Input <\\#>' -colors LightBG
79
79
80 would be passed in the argv list as:
80 would be passed in the argv list as:
81
81
82 ['-prompt_in1','Input <\\#>','-colors','LightBG']
82 ['-prompt_in1','Input <\\#>','-colors','LightBG']
83
83
84 - banner: string which gets printed every time the interpreter starts.
84 - banner: string which gets printed every time the interpreter starts.
85
85
86 - exit_msg: string which gets printed every time the interpreter exits.
86 - exit_msg: string which gets printed every time the interpreter exits.
87
87
88 - rc_override: a dict or Struct of configuration options such as those
88 - rc_override: a dict or Struct of configuration options such as those
89 used by IPython. These options are read from your ~/.ipython/ipythonrc
89 used by IPython. These options are read from your ~/.ipython/ipythonrc
90 file when the Shell object is created. Passing an explicit rc_override
90 file when the Shell object is created. Passing an explicit rc_override
91 dict with any options you want allows you to override those values at
91 dict with any options you want allows you to override those values at
92 creation time without having to modify the file. This way you can create
92 creation time without having to modify the file. This way you can create
93 embeddable instances configured in any way you want without editing any
93 embeddable instances configured in any way you want without editing any
94 global files (thus keeping your interactive IPython configuration
94 global files (thus keeping your interactive IPython configuration
95 unchanged).
95 unchanged).
96
96
97 Then the ipshell instance can be called anywhere inside your code:
97 Then the ipshell instance can be called anywhere inside your code:
98
98
99 ipshell(header='') -> Opens up an IPython shell.
99 ipshell(header='') -> Opens up an IPython shell.
100
100
101 - header: string printed by the IPython shell upon startup. This can let
101 - header: string printed by the IPython shell upon startup. This can let
102 you know where in your code you are when dropping into the shell. Note
102 you know where in your code you are when dropping into the shell. Note
103 that 'banner' gets prepended to all calls, so header is used for
103 that 'banner' gets prepended to all calls, so header is used for
104 location-specific information.
104 location-specific information.
105
105
106 For more details, see the __call__ method below.
106 For more details, see the __call__ method below.
107
107
108 When the IPython shell is exited with Ctrl-D, normal program execution
108 When the IPython shell is exited with Ctrl-D, normal program execution
109 resumes.
109 resumes.
110
110
111 This functionality was inspired by a posting on comp.lang.python by cmkl
111 This functionality was inspired by a posting on comp.lang.python by cmkl
112 <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and
112 <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and
113 by the IDL stop/continue commands."""
113 by the IDL stop/continue commands."""
114
114
115 def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None):
115 def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None):
116 """Note that argv here is a string, NOT a list."""
116 """Note that argv here is a string, NOT a list."""
117 self.set_banner(banner)
117 self.set_banner(banner)
118 self.set_exit_msg(exit_msg)
118 self.set_exit_msg(exit_msg)
119 self.set_dummy_mode(0)
119 self.set_dummy_mode(0)
120
120
121 # sys.displayhook is a global, we need to save the user's original
121 # sys.displayhook is a global, we need to save the user's original
122 # Don't rely on __displayhook__, as the user may have changed that.
122 # Don't rely on __displayhook__, as the user may have changed that.
123 self.sys_displayhook_ori = sys.displayhook
123 self.sys_displayhook_ori = sys.displayhook
124
124
125 # save readline completer status
125 # save readline completer status
126 try:
126 try:
127 #print 'Save completer',sys.ipcompleter # dbg
127 #print 'Save completer',sys.ipcompleter # dbg
128 self.sys_ipcompleter_ori = sys.ipcompleter
128 self.sys_ipcompleter_ori = sys.ipcompleter
129 except:
129 except:
130 pass # not nested with IPython
130 pass # not nested with IPython
131
131
132 # FIXME. Passing user_ns breaks namespace handling.
132 # FIXME. Passing user_ns breaks namespace handling.
133 #self.IP = make_IPython(argv,user_ns=__main__.__dict__)
133 #self.IP = make_IPython(argv,user_ns=__main__.__dict__)
134 self.IP = make_IPython(argv,rc_override=rc_override,embedded=True)
134 self.IP = make_IPython(argv,rc_override=rc_override,embedded=True)
135
135
136 # copy our own displayhook also
136 # copy our own displayhook also
137 self.sys_displayhook_embed = sys.displayhook
137 self.sys_displayhook_embed = sys.displayhook
138 # and leave the system's display hook clean
138 # and leave the system's display hook clean
139 sys.displayhook = self.sys_displayhook_ori
139 sys.displayhook = self.sys_displayhook_ori
140 # don't use the ipython crash handler so that user exceptions aren't
140 # don't use the ipython crash handler so that user exceptions aren't
141 # trapped
141 # trapped
142 sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors,
142 sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors,
143 mode = self.IP.rc.xmode,
143 mode = self.IP.rc.xmode,
144 call_pdb = self.IP.rc.pdb)
144 call_pdb = self.IP.rc.pdb)
145 self.restore_system_completer()
145 self.restore_system_completer()
146
146
147 def restore_system_completer(self):
147 def restore_system_completer(self):
148 """Restores the readline completer which was in place.
148 """Restores the readline completer which was in place.
149
149
150 This allows embedded IPython within IPython not to disrupt the
150 This allows embedded IPython within IPython not to disrupt the
151 parent's completion.
151 parent's completion.
152 """
152 """
153
153
154 try:
154 try:
155 self.IP.readline.set_completer(self.sys_ipcompleter_ori)
155 self.IP.readline.set_completer(self.sys_ipcompleter_ori)
156 sys.ipcompleter = self.sys_ipcompleter_ori
156 sys.ipcompleter = self.sys_ipcompleter_ori
157 except:
157 except:
158 pass
158 pass
159
159
160 def __call__(self,header='',local_ns=None,global_ns=None,dummy=None):
160 def __call__(self,header='',local_ns=None,global_ns=None,dummy=None):
161 """Activate the interactive interpreter.
161 """Activate the interactive interpreter.
162
162
163 __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start
163 __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start
164 the interpreter shell with the given local and global namespaces, and
164 the interpreter shell with the given local and global namespaces, and
165 optionally print a header string at startup.
165 optionally print a header string at startup.
166
166
167 The shell can be globally activated/deactivated using the
167 The shell can be globally activated/deactivated using the
168 set/get_dummy_mode methods. This allows you to turn off a shell used
168 set/get_dummy_mode methods. This allows you to turn off a shell used
169 for debugging globally.
169 for debugging globally.
170
170
171 However, *each* time you call the shell you can override the current
171 However, *each* time you call the shell you can override the current
172 state of dummy_mode with the optional keyword parameter 'dummy'. For
172 state of dummy_mode with the optional keyword parameter 'dummy'. For
173 example, if you set dummy mode on with IPShell.set_dummy_mode(1), you
173 example, if you set dummy mode on with IPShell.set_dummy_mode(1), you
174 can still have a specific call work by making it as IPShell(dummy=0).
174 can still have a specific call work by making it as IPShell(dummy=0).
175
175
176 The optional keyword parameter dummy controls whether the call
176 The optional keyword parameter dummy controls whether the call
177 actually does anything. """
177 actually does anything. """
178
178
179 # Allow the dummy parameter to override the global __dummy_mode
179 # Allow the dummy parameter to override the global __dummy_mode
180 if dummy or (dummy != 0 and self.__dummy_mode):
180 if dummy or (dummy != 0 and self.__dummy_mode):
181 return
181 return
182
182
183 # Set global subsystems (display,completions) to our values
183 # Set global subsystems (display,completions) to our values
184 sys.displayhook = self.sys_displayhook_embed
184 sys.displayhook = self.sys_displayhook_embed
185 if self.IP.has_readline:
185 if self.IP.has_readline:
186 self.IP.readline.set_completer(self.IP.Completer.complete)
186 self.IP.readline.set_completer(self.IP.Completer.complete)
187
187
188 if self.banner and header:
188 if self.banner and header:
189 format = '%s\n%s\n'
189 format = '%s\n%s\n'
190 else:
190 else:
191 format = '%s%s\n'
191 format = '%s%s\n'
192 banner = format % (self.banner,header)
192 banner = format % (self.banner,header)
193
193
194 # Call the embedding code with a stack depth of 1 so it can skip over
194 # Call the embedding code with a stack depth of 1 so it can skip over
195 # our call and get the original caller's namespaces.
195 # our call and get the original caller's namespaces.
196 self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1)
196 self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1)
197
197
198 if self.exit_msg:
198 if self.exit_msg:
199 print self.exit_msg
199 print self.exit_msg
200
200
201 # Restore global systems (display, completion)
201 # Restore global systems (display, completion)
202 sys.displayhook = self.sys_displayhook_ori
202 sys.displayhook = self.sys_displayhook_ori
203 self.restore_system_completer()
203 self.restore_system_completer()
204
204
205 def set_dummy_mode(self,dummy):
205 def set_dummy_mode(self,dummy):
206 """Sets the embeddable shell's dummy mode parameter.
206 """Sets the embeddable shell's dummy mode parameter.
207
207
208 set_dummy_mode(dummy): dummy = 0 or 1.
208 set_dummy_mode(dummy): dummy = 0 or 1.
209
209
210 This parameter is persistent and makes calls to the embeddable shell
210 This parameter is persistent and makes calls to the embeddable shell
211 silently return without performing any action. This allows you to
211 silently return without performing any action. This allows you to
212 globally activate or deactivate a shell you're using with a single call.
212 globally activate or deactivate a shell you're using with a single call.
213
213
214 If you need to manually"""
214 If you need to manually"""
215
215
216 if dummy not in [0,1,False,True]:
216 if dummy not in [0,1,False,True]:
217 raise ValueError,'dummy parameter must be boolean'
217 raise ValueError,'dummy parameter must be boolean'
218 self.__dummy_mode = dummy
218 self.__dummy_mode = dummy
219
219
220 def get_dummy_mode(self):
220 def get_dummy_mode(self):
221 """Return the current value of the dummy mode parameter.
221 """Return the current value of the dummy mode parameter.
222 """
222 """
223 return self.__dummy_mode
223 return self.__dummy_mode
224
224
225 def set_banner(self,banner):
225 def set_banner(self,banner):
226 """Sets the global banner.
226 """Sets the global banner.
227
227
228 This banner gets prepended to every header printed when the shell
228 This banner gets prepended to every header printed when the shell
229 instance is called."""
229 instance is called."""
230
230
231 self.banner = banner
231 self.banner = banner
232
232
233 def set_exit_msg(self,exit_msg):
233 def set_exit_msg(self,exit_msg):
234 """Sets the global exit_msg.
234 """Sets the global exit_msg.
235
235
236 This exit message gets printed upon exiting every time the embedded
236 This exit message gets printed upon exiting every time the embedded
237 shell is called. It is None by default. """
237 shell is called. It is None by default. """
238
238
239 self.exit_msg = exit_msg
239 self.exit_msg = exit_msg
240
240
241 #-----------------------------------------------------------------------------
241 #-----------------------------------------------------------------------------
242 def sigint_handler (signum,stack_frame):
242 def sigint_handler (signum,stack_frame):
243 """Sigint handler for threaded apps.
243 """Sigint handler for threaded apps.
244
244
245 This is a horrible hack to pass information about SIGINT _without_ using
245 This is a horrible hack to pass information about SIGINT _without_ using
246 exceptions, since I haven't been able to properly manage cross-thread
246 exceptions, since I haven't been able to properly manage cross-thread
247 exceptions in GTK/WX. In fact, I don't think it can be done (or at least
247 exceptions in GTK/WX. In fact, I don't think it can be done (or at least
248 that's my understanding from a c.l.py thread where this was discussed)."""
248 that's my understanding from a c.l.py thread where this was discussed)."""
249
249
250 global KBINT
250 global KBINT
251
251
252 print '\nKeyboardInterrupt - Press <Enter> to continue.',
252 print '\nKeyboardInterrupt - Press <Enter> to continue.',
253 Term.cout.flush()
253 Term.cout.flush()
254 # Set global flag so that runsource can know that Ctrl-C was hit
254 # Set global flag so that runsource can know that Ctrl-C was hit
255 KBINT = True
255 KBINT = True
256
256
257 class MTInteractiveShell(InteractiveShell):
257 class MTInteractiveShell(InteractiveShell):
258 """Simple multi-threaded shell."""
258 """Simple multi-threaded shell."""
259
259
260 # Threading strategy taken from:
260 # Threading strategy taken from:
261 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian
261 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian
262 # McErlean and John Finlay. Modified with corrections by Antoon Pardon,
262 # McErlean and John Finlay. Modified with corrections by Antoon Pardon,
263 # from the pygtk mailing list, to avoid lockups with system calls.
263 # from the pygtk mailing list, to avoid lockups with system calls.
264
264
265 # class attribute to indicate whether the class supports threads or not.
265 # class attribute to indicate whether the class supports threads or not.
266 # Subclasses with thread support should override this as needed.
266 # Subclasses with thread support should override this as needed.
267 isthreaded = True
267 isthreaded = True
268
268
269 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
269 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
270 user_ns=None,user_global_ns=None,banner2='',**kw):
270 user_ns=None,user_global_ns=None,banner2='',**kw):
271 """Similar to the normal InteractiveShell, but with threading control"""
271 """Similar to the normal InteractiveShell, but with threading control"""
272
272
273 InteractiveShell.__init__(self,name,usage,rc,user_ns,
273 InteractiveShell.__init__(self,name,usage,rc,user_ns,
274 user_global_ns,banner2)
274 user_global_ns,banner2)
275
275
276 # Locking control variable. We need to use a norma lock, not an RLock
276 # Locking control variable. We need to use a norma lock, not an RLock
277 # here. I'm not exactly sure why, it seems to me like it should be
277 # here. I'm not exactly sure why, it seems to me like it should be
278 # the opposite, but we deadlock with an RLock. Puzzled...
278 # the opposite, but we deadlock with an RLock. Puzzled...
279 self.thread_ready = threading.Condition(threading.Lock())
279 self.thread_ready = threading.Condition(threading.Lock())
280
280
281 # A queue to hold the code to be executed. A scalar variable is NOT
281 # A queue to hold the code to be executed. A scalar variable is NOT
282 # enough, because uses like macros cause reentrancy.
282 # enough, because uses like macros cause reentrancy.
283 self.code_queue = Queue.Queue()
283 self.code_queue = Queue.Queue()
284
284
285 # Stuff to do at closing time
285 # Stuff to do at closing time
286 self._kill = False
286 self._kill = False
287 on_kill = kw.get('on_kill')
287 on_kill = kw.get('on_kill')
288 if on_kill is None:
288 if on_kill is None:
289 on_kill = []
289 on_kill = []
290 # Check that all things to kill are callable:
290 # Check that all things to kill are callable:
291 for t in on_kill:
291 for t in on_kill:
292 if not callable(t):
292 if not callable(t):
293 raise TypeError,'on_kill must be a list of callables'
293 raise TypeError,'on_kill must be a list of callables'
294 self.on_kill = on_kill
294 self.on_kill = on_kill
295
295
296 def runsource(self, source, filename="<input>", symbol="single"):
296 def runsource(self, source, filename="<input>", symbol="single"):
297 """Compile and run some source in the interpreter.
297 """Compile and run some source in the interpreter.
298
298
299 Modified version of code.py's runsource(), to handle threading issues.
299 Modified version of code.py's runsource(), to handle threading issues.
300 See the original for full docstring details."""
300 See the original for full docstring details."""
301
301
302 global KBINT
302 global KBINT
303
303
304 # If Ctrl-C was typed, we reset the flag and return right away
304 # If Ctrl-C was typed, we reset the flag and return right away
305 if KBINT:
305 if KBINT:
306 KBINT = False
306 KBINT = False
307 return False
307 return False
308
308
309 try:
309 try:
310 code = self.compile(source, filename, symbol)
310 code = self.compile(source, filename, symbol)
311 except (OverflowError, SyntaxError, ValueError):
311 except (OverflowError, SyntaxError, ValueError):
312 # Case 1
312 # Case 1
313 self.showsyntaxerror(filename)
313 self.showsyntaxerror(filename)
314 return False
314 return False
315
315
316 if code is None:
316 if code is None:
317 # Case 2
317 # Case 2
318 return True
318 return True
319
319
320 # Case 3
320 # Case 3
321 # Store code in queue, so the execution thread can handle it.
321 # Store code in queue, so the execution thread can handle it.
322
322
323 # Note that with macros and other applications, we MAY re-enter this
323 # Note that with macros and other applications, we MAY re-enter this
324 # section, so we have to acquire the lock with non-blocking semantics,
324 # section, so we have to acquire the lock with non-blocking semantics,
325 # else we deadlock.
325 # else we deadlock.
326 got_lock = self.thread_ready.acquire(False)
326 got_lock = self.thread_ready.acquire(False)
327 self.code_queue.put(code)
327 self.code_queue.put(code)
328 if got_lock:
328 if got_lock:
329 self.thread_ready.wait() # Wait until processed in timeout interval
329 self.thread_ready.wait() # Wait until processed in timeout interval
330 self.thread_ready.release()
330 self.thread_ready.release()
331
331
332 return False
332 return False
333
333
334 def runcode(self):
334 def runcode(self):
335 """Execute a code object.
335 """Execute a code object.
336
336
337 Multithreaded wrapper around IPython's runcode()."""
337 Multithreaded wrapper around IPython's runcode()."""
338
338
339 # lock thread-protected stuff
339 # lock thread-protected stuff
340 self.thread_ready.acquire(False)
340 self.thread_ready.acquire(False)
341
341
342 # Install sigint handler
342 # Install sigint handler
343 try:
343 try:
344 signal.signal(signal.SIGINT, sigint_handler)
344 signal.signal(signal.SIGINT, sigint_handler)
345 except SystemError:
345 except SystemError:
346 # This happens under Windows, which seems to have all sorts
346 # This happens under Windows, which seems to have all sorts
347 # of problems with signal handling. Oh well...
347 # of problems with signal handling. Oh well...
348 pass
348 pass
349
349
350 if self._kill:
350 if self._kill:
351 print >>Term.cout, 'Closing threads...',
351 print >>Term.cout, 'Closing threads...',
352 Term.cout.flush()
352 Term.cout.flush()
353 for tokill in self.on_kill:
353 for tokill in self.on_kill:
354 tokill()
354 tokill()
355 print >>Term.cout, 'Done.'
355 print >>Term.cout, 'Done.'
356
356
357 # Flush queue of pending code by calling the run methood of the parent
357 # Flush queue of pending code by calling the run methood of the parent
358 # class with all items which may be in the queue.
358 # class with all items which may be in the queue.
359 while 1:
359 while 1:
360 try:
360 try:
361 code_to_run = self.code_queue.get_nowait()
361 code_to_run = self.code_queue.get_nowait()
362 except Queue.Empty:
362 except Queue.Empty:
363 break
363 break
364 self.thread_ready.notify()
364 self.thread_ready.notify()
365 InteractiveShell.runcode(self,code_to_run)
365 InteractiveShell.runcode(self,code_to_run)
366
366
367 # We're done with thread-protected variables
367 # We're done with thread-protected variables
368 self.thread_ready.release()
368 self.thread_ready.release()
369 # This MUST return true for gtk threading to work
369 # This MUST return true for gtk threading to work
370 return True
370 return True
371
371
372 def kill (self):
372 def kill (self):
373 """Kill the thread, returning when it has been shut down."""
373 """Kill the thread, returning when it has been shut down."""
374 self.thread_ready.acquire(False)
374 self.thread_ready.acquire(False)
375 self._kill = True
375 self._kill = True
376 self.thread_ready.release()
376 self.thread_ready.release()
377
377
378 class MatplotlibShellBase:
378 class MatplotlibShellBase:
379 """Mixin class to provide the necessary modifications to regular IPython
379 """Mixin class to provide the necessary modifications to regular IPython
380 shell classes for matplotlib support.
380 shell classes for matplotlib support.
381
381
382 Given Python's MRO, this should be used as the FIRST class in the
382 Given Python's MRO, this should be used as the FIRST class in the
383 inheritance hierarchy, so that it overrides the relevant methods."""
383 inheritance hierarchy, so that it overrides the relevant methods."""
384
384
385 def _matplotlib_config(self,name):
385 def _matplotlib_config(self,name):
386 """Return items needed to setup the user's shell with matplotlib"""
386 """Return items needed to setup the user's shell with matplotlib"""
387
387
388 # Initialize matplotlib to interactive mode always
388 # Initialize matplotlib to interactive mode always
389 import matplotlib
389 import matplotlib
390 from matplotlib import backends
390 from matplotlib import backends
391 matplotlib.interactive(True)
391 matplotlib.interactive(True)
392
392
393 def use(arg):
393 def use(arg):
394 """IPython wrapper for matplotlib's backend switcher.
394 """IPython wrapper for matplotlib's backend switcher.
395
395
396 In interactive use, we can not allow switching to a different
396 In interactive use, we can not allow switching to a different
397 interactive backend, since thread conflicts will most likely crash
397 interactive backend, since thread conflicts will most likely crash
398 the python interpreter. This routine does a safety check first,
398 the python interpreter. This routine does a safety check first,
399 and refuses to perform a dangerous switch. It still allows
399 and refuses to perform a dangerous switch. It still allows
400 switching to non-interactive backends."""
400 switching to non-interactive backends."""
401
401
402 if arg in backends.interactive_bk and arg != self.mpl_backend:
402 if arg in backends.interactive_bk and arg != self.mpl_backend:
403 m=('invalid matplotlib backend switch.\n'
403 m=('invalid matplotlib backend switch.\n'
404 'This script attempted to switch to the interactive '
404 'This script attempted to switch to the interactive '
405 'backend: `%s`\n'
405 'backend: `%s`\n'
406 'Your current choice of interactive backend is: `%s`\n\n'
406 'Your current choice of interactive backend is: `%s`\n\n'
407 'Switching interactive matplotlib backends at runtime\n'
407 'Switching interactive matplotlib backends at runtime\n'
408 'would crash the python interpreter, '
408 'would crash the python interpreter, '
409 'and IPython has blocked it.\n\n'
409 'and IPython has blocked it.\n\n'
410 'You need to either change your choice of matplotlib backend\n'
410 'You need to either change your choice of matplotlib backend\n'
411 'by editing your .matplotlibrc file, or run this script as a \n'
411 'by editing your .matplotlibrc file, or run this script as a \n'
412 'standalone file from the command line, not using IPython.\n' %
412 'standalone file from the command line, not using IPython.\n' %
413 (arg,self.mpl_backend) )
413 (arg,self.mpl_backend) )
414 raise RuntimeError, m
414 raise RuntimeError, m
415 else:
415 else:
416 self.mpl_use(arg)
416 self.mpl_use(arg)
417 self.mpl_use._called = True
417 self.mpl_use._called = True
418
418
419 self.matplotlib = matplotlib
419 self.matplotlib = matplotlib
420 self.mpl_backend = matplotlib.rcParams['backend']
420 self.mpl_backend = matplotlib.rcParams['backend']
421
421
422 # we also need to block switching of interactive backends by use()
422 # we also need to block switching of interactive backends by use()
423 self.mpl_use = matplotlib.use
423 self.mpl_use = matplotlib.use
424 self.mpl_use._called = False
424 self.mpl_use._called = False
425 # overwrite the original matplotlib.use with our wrapper
425 # overwrite the original matplotlib.use with our wrapper
426 matplotlib.use = use
426 matplotlib.use = use
427
427
428 # This must be imported last in the matplotlib series, after
428 # This must be imported last in the matplotlib series, after
429 # backend/interactivity choices have been made
429 # backend/interactivity choices have been made
430 try:
430 try:
431 import matplotlib.pylab as pylab
431 import matplotlib.pylab as pylab
432 self.pylab = pylab
432 self.pylab = pylab
433 self.pylab_name = 'pylab'
433 self.pylab_name = 'pylab'
434 except ImportError:
434 except ImportError:
435 import matplotlib.matlab as matlab
435 import matplotlib.matlab as matlab
436 self.pylab = matlab
436 self.pylab = matlab
437 self.pylab_name = 'matlab'
437 self.pylab_name = 'matlab'
438
438
439 self.pylab.show._needmain = False
439 self.pylab.show._needmain = False
440 # We need to detect at runtime whether show() is called by the user.
440 # We need to detect at runtime whether show() is called by the user.
441 # For this, we wrap it into a decorator which adds a 'called' flag.
441 # For this, we wrap it into a decorator which adds a 'called' flag.
442 self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive)
442 self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive)
443
443
444 # Build a user namespace initialized with matplotlib/matlab features.
444 # Build a user namespace initialized with matplotlib/matlab features.
445 user_ns = {'__name__':'__main__',
445 user_ns = {'__name__':'__main__',
446 '__builtins__' : __builtin__ }
446 '__builtins__' : __builtin__ }
447
447
448 # Be careful not to remove the final \n in the code string below, or
448 # Be careful not to remove the final \n in the code string below, or
449 # things will break badly with py22 (I think it's a python bug, 2.3 is
449 # things will break badly with py22 (I think it's a python bug, 2.3 is
450 # OK).
450 # OK).
451 pname = self.pylab_name # Python can't interpolate dotted var names
451 pname = self.pylab_name # Python can't interpolate dotted var names
452 exec ("import matplotlib\n"
452 exec ("import matplotlib\n"
453 "import matplotlib.%(pname)s as %(pname)s\n"
453 "import matplotlib.%(pname)s as %(pname)s\n"
454 "from matplotlib.%(pname)s import *\n" % locals()) in user_ns
454 "from matplotlib.%(pname)s import *\n" % locals()) in user_ns
455
455
456 # Build matplotlib info banner
456 # Build matplotlib info banner
457 b="""
457 b="""
458 Welcome to pylab, a matplotlib-based Python environment.
458 Welcome to pylab, a matplotlib-based Python environment.
459 For more information, type 'help(pylab)'.
459 For more information, type 'help(pylab)'.
460 """
460 """
461 return user_ns,b
461 return user_ns,b
462
462
463 def mplot_exec(self,fname,*where,**kw):
463 def mplot_exec(self,fname,*where,**kw):
464 """Execute a matplotlib script.
464 """Execute a matplotlib script.
465
465
466 This is a call to execfile(), but wrapped in safeties to properly
466 This is a call to execfile(), but wrapped in safeties to properly
467 handle interactive rendering and backend switching."""
467 handle interactive rendering and backend switching."""
468
468
469 #print '*** Matplotlib runner ***' # dbg
469 #print '*** Matplotlib runner ***' # dbg
470 # turn off rendering until end of script
470 # turn off rendering until end of script
471 isInteractive = self.matplotlib.rcParams['interactive']
471 isInteractive = self.matplotlib.rcParams['interactive']
472 self.matplotlib.interactive(False)
472 self.matplotlib.interactive(False)
473 self.safe_execfile(fname,*where,**kw)
473 self.safe_execfile(fname,*where,**kw)
474 self.matplotlib.interactive(isInteractive)
474 self.matplotlib.interactive(isInteractive)
475 # make rendering call now, if the user tried to do it
475 # make rendering call now, if the user tried to do it
476 if self.pylab.draw_if_interactive.called:
476 if self.pylab.draw_if_interactive.called:
477 self.pylab.draw()
477 self.pylab.draw()
478 self.pylab.draw_if_interactive.called = False
478 self.pylab.draw_if_interactive.called = False
479
479
480 # if a backend switch was performed, reverse it now
480 # if a backend switch was performed, reverse it now
481 if self.mpl_use._called:
481 if self.mpl_use._called:
482 self.matplotlib.rcParams['backend'] = self.mpl_backend
482 self.matplotlib.rcParams['backend'] = self.mpl_backend
483
483
484 def magic_run(self,parameter_s=''):
484 def magic_run(self,parameter_s=''):
485 Magic.magic_run(self,parameter_s,runner=self.mplot_exec)
485 Magic.magic_run(self,parameter_s,runner=self.mplot_exec)
486
486
487 # Fix the docstring so users see the original as well
487 # Fix the docstring so users see the original as well
488 magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__,
488 magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__,
489 "\n *** Modified %run for Matplotlib,"
489 "\n *** Modified %run for Matplotlib,"
490 " with proper interactive handling ***")
490 " with proper interactive handling ***")
491
491
492 # Now we provide 2 versions of a matplotlib-aware IPython base shells, single
492 # Now we provide 2 versions of a matplotlib-aware IPython base shells, single
493 # and multithreaded. Note that these are meant for internal use, the IPShell*
493 # and multithreaded. Note that these are meant for internal use, the IPShell*
494 # classes below are the ones meant for public consumption.
494 # classes below are the ones meant for public consumption.
495
495
496 class MatplotlibShell(MatplotlibShellBase,InteractiveShell):
496 class MatplotlibShell(MatplotlibShellBase,InteractiveShell):
497 """Single-threaded shell with matplotlib support."""
497 """Single-threaded shell with matplotlib support."""
498
498
499 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
499 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
500 user_ns=None,user_global_ns=None,**kw):
500 user_ns=None,user_global_ns=None,**kw):
501 user_ns,b2 = self._matplotlib_config(name)
501 user_ns,b2 = self._matplotlib_config(name)
502 InteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns,
502 InteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns,
503 banner2=b2,**kw)
503 banner2=b2,**kw)
504
504
505 class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell):
505 class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell):
506 """Multi-threaded shell with matplotlib support."""
506 """Multi-threaded shell with matplotlib support."""
507
507
508 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
508 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
509 user_ns=None,user_global_ns=None, **kw):
509 user_ns=None,user_global_ns=None, **kw):
510 user_ns,b2 = self._matplotlib_config(name)
510 user_ns,b2 = self._matplotlib_config(name)
511 MTInteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns,
511 MTInteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns,
512 banner2=b2,**kw)
512 banner2=b2,**kw)
513
513
514 #-----------------------------------------------------------------------------
514 #-----------------------------------------------------------------------------
515 # Utility functions for the different GUI enabled IPShell* classes.
515 # Utility functions for the different GUI enabled IPShell* classes.
516
516
517 def get_tk():
517 def get_tk():
518 """Tries to import Tkinter and returns a withdrawn Tkinter root
518 """Tries to import Tkinter and returns a withdrawn Tkinter root
519 window. If Tkinter is already imported or not available, this
519 window. If Tkinter is already imported or not available, this
520 returns None. This function calls `hijack_tk` underneath.
520 returns None. This function calls `hijack_tk` underneath.
521 """
521 """
522 if not USE_TK or sys.modules.has_key('Tkinter'):
522 if not USE_TK or sys.modules.has_key('Tkinter'):
523 return None
523 return None
524 else:
524 else:
525 try:
525 try:
526 import Tkinter
526 import Tkinter
527 except ImportError:
527 except ImportError:
528 return None
528 return None
529 else:
529 else:
530 hijack_tk()
530 hijack_tk()
531 r = Tkinter.Tk()
531 r = Tkinter.Tk()
532 r.withdraw()
532 r.withdraw()
533 return r
533 return r
534
534
535 def hijack_tk():
535 def hijack_tk():
536 """Modifies Tkinter's mainloop with a dummy so when a module calls
536 """Modifies Tkinter's mainloop with a dummy so when a module calls
537 mainloop, it does not block.
537 mainloop, it does not block.
538
538
539 """
539 """
540 def misc_mainloop(self, n=0):
540 def misc_mainloop(self, n=0):
541 pass
541 pass
542 def tkinter_mainloop(n=0):
542 def tkinter_mainloop(n=0):
543 pass
543 pass
544
544
545 import Tkinter
545 import Tkinter
546 Tkinter.Misc.mainloop = misc_mainloop
546 Tkinter.Misc.mainloop = misc_mainloop
547 Tkinter.mainloop = tkinter_mainloop
547 Tkinter.mainloop = tkinter_mainloop
548
548
549 def update_tk(tk):
549 def update_tk(tk):
550 """Updates the Tkinter event loop. This is typically called from
550 """Updates the Tkinter event loop. This is typically called from
551 the respective WX or GTK mainloops.
551 the respective WX or GTK mainloops.
552 """
552 """
553 if tk:
553 if tk:
554 tk.update()
554 tk.update()
555
555
556 def hijack_wx():
556 def hijack_wx():
557 """Modifies wxPython's MainLoop with a dummy so user code does not
557 """Modifies wxPython's MainLoop with a dummy so user code does not
558 block IPython. The hijacked mainloop function is returned.
558 block IPython. The hijacked mainloop function is returned.
559 """
559 """
560 def dummy_mainloop(*args, **kw):
560 def dummy_mainloop(*args, **kw):
561 pass
561 pass
562 import wxPython
562 import wxPython
563 ver = wxPython.__version__
563 ver = wxPython.__version__
564 orig_mainloop = None
564 orig_mainloop = None
565 if ver[:3] >= '2.5':
565 if ver[:3] >= '2.5':
566 import wx
566 import wx
567 if hasattr(wx, '_core_'): core = getattr(wx, '_core_')
567 if hasattr(wx, '_core_'): core = getattr(wx, '_core_')
568 elif hasattr(wx, '_core'): core = getattr(wx, '_core')
568 elif hasattr(wx, '_core'): core = getattr(wx, '_core')
569 else: raise AttributeError('Could not find wx core module')
569 else: raise AttributeError('Could not find wx core module')
570 orig_mainloop = core.PyApp_MainLoop
570 orig_mainloop = core.PyApp_MainLoop
571 core.PyApp_MainLoop = dummy_mainloop
571 core.PyApp_MainLoop = dummy_mainloop
572 elif ver[:3] == '2.4':
572 elif ver[:3] == '2.4':
573 orig_mainloop = wxPython.wxc.wxPyApp_MainLoop
573 orig_mainloop = wxPython.wxc.wxPyApp_MainLoop
574 wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop
574 wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop
575 else:
575 else:
576 warn("Unable to find either wxPython version 2.4 or >= 2.5.")
576 warn("Unable to find either wxPython version 2.4 or >= 2.5.")
577 return orig_mainloop
577 return orig_mainloop
578
578
579 def hijack_gtk():
579 def hijack_gtk():
580 """Modifies pyGTK's mainloop with a dummy so user code does not
580 """Modifies pyGTK's mainloop with a dummy so user code does not
581 block IPython. This function returns the original `gtk.mainloop`
581 block IPython. This function returns the original `gtk.mainloop`
582 function that has been hijacked.
582 function that has been hijacked.
583 """
583 """
584 def dummy_mainloop(*args, **kw):
584 def dummy_mainloop(*args, **kw):
585 pass
585 pass
586 import gtk
586 import gtk
587 if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main
587 if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main
588 else: orig_mainloop = gtk.mainloop
588 else: orig_mainloop = gtk.mainloop
589 gtk.mainloop = dummy_mainloop
589 gtk.mainloop = dummy_mainloop
590 gtk.main = dummy_mainloop
590 gtk.main = dummy_mainloop
591 return orig_mainloop
591 return orig_mainloop
592
592
593 #-----------------------------------------------------------------------------
593 #-----------------------------------------------------------------------------
594 # The IPShell* classes below are the ones meant to be run by external code as
594 # The IPShell* classes below are the ones meant to be run by external code as
595 # IPython instances. Note that unless a specific threading strategy is
595 # IPython instances. Note that unless a specific threading strategy is
596 # desired, the factory function start() below should be used instead (it
596 # desired, the factory function start() below should be used instead (it
597 # selects the proper threaded class).
597 # selects the proper threaded class).
598
598
599 class IPShellGTK(threading.Thread):
599 class IPShellGTK(threading.Thread):
600 """Run a gtk mainloop() in a separate thread.
600 """Run a gtk mainloop() in a separate thread.
601
601
602 Python commands can be passed to the thread where they will be executed.
602 Python commands can be passed to the thread where they will be executed.
603 This is implemented by periodically checking for passed code using a
603 This is implemented by periodically checking for passed code using a
604 GTK timeout callback."""
604 GTK timeout callback."""
605
605
606 TIMEOUT = 100 # Millisecond interval between timeouts.
606 TIMEOUT = 100 # Millisecond interval between timeouts.
607
607
608 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
608 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
609 debug=1,shell_class=MTInteractiveShell):
609 debug=1,shell_class=MTInteractiveShell):
610
610
611 import gtk
611 import gtk
612
612
613 self.gtk = gtk
613 self.gtk = gtk
614 self.gtk_mainloop = hijack_gtk()
614 self.gtk_mainloop = hijack_gtk()
615
615
616 # Allows us to use both Tk and GTK.
616 # Allows us to use both Tk and GTK.
617 self.tk = get_tk()
617 self.tk = get_tk()
618
618
619 if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit
619 if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit
620 else: mainquit = self.gtk.mainquit
620 else: mainquit = self.gtk.mainquit
621
621
622 self.IP = make_IPython(argv,user_ns=user_ns,
622 self.IP = make_IPython(argv,user_ns=user_ns,
623 user_global_ns=user_global_ns,
623 user_global_ns=user_global_ns,
624 debug=debug,
624 debug=debug,
625 shell_class=shell_class,
625 shell_class=shell_class,
626 on_kill=[mainquit])
626 on_kill=[mainquit])
627
627
628 # HACK: slot for banner in self; it will be passed to the mainloop
628 # HACK: slot for banner in self; it will be passed to the mainloop
629 # method only and .run() needs it. The actual value will be set by
629 # method only and .run() needs it. The actual value will be set by
630 # .mainloop().
630 # .mainloop().
631 self._banner = None
631 self._banner = None
632
632
633 threading.Thread.__init__(self)
633 threading.Thread.__init__(self)
634
634
635 def run(self):
635 def run(self):
636 self.IP.mainloop(self._banner)
636 self.IP.mainloop(self._banner)
637 self.IP.kill()
637 self.IP.kill()
638
638
639 def mainloop(self,sys_exit=0,banner=None):
639 def mainloop(self,sys_exit=0,banner=None):
640
640
641 self._banner = banner
641 self._banner = banner
642
642
643 if self.gtk.pygtk_version >= (2,4,0):
643 if self.gtk.pygtk_version >= (2,4,0):
644 import gobject
644 import gobject
645 gobject.idle_add(self.on_timer)
645 gobject.idle_add(self.on_timer)
646 else:
646 else:
647 self.gtk.idle_add(self.on_timer)
647 self.gtk.idle_add(self.on_timer)
648
648
649 if sys.platform != 'win32':
649 if sys.platform != 'win32':
650 try:
650 try:
651 if self.gtk.gtk_version[0] >= 2:
651 if self.gtk.gtk_version[0] >= 2:
652 self.gtk.threads_init()
652 self.gtk.threads_init()
653 except AttributeError:
653 except AttributeError:
654 pass
654 pass
655 except RuntimeError:
655 except RuntimeError:
656 error('Your pyGTK likely has not been compiled with '
656 error('Your pyGTK likely has not been compiled with '
657 'threading support.\n'
657 'threading support.\n'
658 'The exception printout is below.\n'
658 'The exception printout is below.\n'
659 'You can either rebuild pyGTK with threads, or '
659 'You can either rebuild pyGTK with threads, or '
660 'try using \n'
660 'try using \n'
661 'matplotlib with a different backend (like Tk or WX).\n'
661 'matplotlib with a different backend (like Tk or WX).\n'
662 'Note that matplotlib will most likely not work in its '
662 'Note that matplotlib will most likely not work in its '
663 'current state!')
663 'current state!')
664 self.IP.InteractiveTB()
664 self.IP.InteractiveTB()
665 self.start()
665 self.start()
666 self.gtk.threads_enter()
666 self.gtk.threads_enter()
667 self.gtk_mainloop()
667 self.gtk_mainloop()
668 self.gtk.threads_leave()
668 self.gtk.threads_leave()
669 self.join()
669 self.join()
670
670
671 def on_timer(self):
671 def on_timer(self):
672 """Called when GTK is idle.
672 """Called when GTK is idle.
673
673
674 Must return True always, otherwise GTK stops calling it"""
674 Must return True always, otherwise GTK stops calling it"""
675
675
676 update_tk(self.tk)
676 update_tk(self.tk)
677 self.IP.runcode()
677 self.IP.runcode()
678 time.sleep(0.01)
678 time.sleep(0.01)
679 return True
679 return True
680
680
681 class IPShellWX(threading.Thread):
681 class IPShellWX(threading.Thread):
682 """Run a wx mainloop() in a separate thread.
682 """Run a wx mainloop() in a separate thread.
683
683
684 Python commands can be passed to the thread where they will be executed.
684 Python commands can be passed to the thread where they will be executed.
685 This is implemented by periodically checking for passed code using a
685 This is implemented by periodically checking for passed code using a
686 GTK timeout callback."""
686 GTK timeout callback."""
687
687
688 TIMEOUT = 100 # Millisecond interval between timeouts.
688 TIMEOUT = 100 # Millisecond interval between timeouts.
689
689
690 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
690 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
691 debug=1,shell_class=MTInteractiveShell):
691 debug=1,shell_class=MTInteractiveShell):
692
692
693 self.IP = make_IPython(argv,user_ns=user_ns,
693 self.IP = make_IPython(argv,user_ns=user_ns,
694 user_global_ns=user_global_ns,
694 user_global_ns=user_global_ns,
695 debug=debug,
695 debug=debug,
696 shell_class=shell_class,
696 shell_class=shell_class,
697 on_kill=[self.wxexit])
697 on_kill=[self.wxexit])
698
698
699 wantedwxversion=self.IP.rc.wxversion
699 wantedwxversion=self.IP.rc.wxversion
700 if wantedwxversion!="0":
700 if wantedwxversion!="0":
701 try:
701 try:
702 import wxversion
702 import wxversion
703 except ImportError:
703 except ImportError:
704 error('The wxversion module is needed for WX version selection')
704 error('The wxversion module is needed for WX version selection')
705 else:
705 else:
706 try:
706 try:
707 wxversion.select(wantedwxversion)
707 wxversion.select(wantedwxversion)
708 except:
708 except:
709 self.IP.InteractiveTB()
709 self.IP.InteractiveTB()
710 error('Requested wxPython version %s could not be loaded' %
710 error('Requested wxPython version %s could not be loaded' %
711 wantedwxversion)
711 wantedwxversion)
712
712
713 import wxPython.wx as wx
713 import wxPython.wx as wx
714
714
715 threading.Thread.__init__(self)
715 threading.Thread.__init__(self)
716 self.wx = wx
716 self.wx = wx
717 self.wx_mainloop = hijack_wx()
717 self.wx_mainloop = hijack_wx()
718
718
719 # Allows us to use both Tk and GTK.
719 # Allows us to use both Tk and GTK.
720 self.tk = get_tk()
720 self.tk = get_tk()
721
721
722
722
723 # HACK: slot for banner in self; it will be passed to the mainloop
723 # HACK: slot for banner in self; it will be passed to the mainloop
724 # method only and .run() needs it. The actual value will be set by
724 # method only and .run() needs it. The actual value will be set by
725 # .mainloop().
725 # .mainloop().
726 self._banner = None
726 self._banner = None
727
727
728 self.app = None
728 self.app = None
729
729
730 def wxexit(self, *args):
730 def wxexit(self, *args):
731 if self.app is not None:
731 if self.app is not None:
732 self.app.agent.timer.Stop()
732 self.app.agent.timer.Stop()
733 self.app.ExitMainLoop()
733 self.app.ExitMainLoop()
734
734
735 def run(self):
735 def run(self):
736 self.IP.mainloop(self._banner)
736 self.IP.mainloop(self._banner)
737 self.IP.kill()
737 self.IP.kill()
738
738
739 def mainloop(self,sys_exit=0,banner=None):
739 def mainloop(self,sys_exit=0,banner=None):
740
740
741 self._banner = banner
741 self._banner = banner
742
742
743 self.start()
743 self.start()
744
744
745 class TimerAgent(self.wx.wxMiniFrame):
745 class TimerAgent(self.wx.wxMiniFrame):
746 wx = self.wx
746 wx = self.wx
747 IP = self.IP
747 IP = self.IP
748 tk = self.tk
748 tk = self.tk
749 def __init__(self, parent, interval):
749 def __init__(self, parent, interval):
750 style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ
750 style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ
751 self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200),
751 self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200),
752 size=(100, 100),style=style)
752 size=(100, 100),style=style)
753 self.Show(False)
753 self.Show(False)
754 self.interval = interval
754 self.interval = interval
755 self.timerId = self.wx.wxNewId()
755 self.timerId = self.wx.wxNewId()
756
756
757 def StartWork(self):
757 def StartWork(self):
758 self.timer = self.wx.wxTimer(self, self.timerId)
758 self.timer = self.wx.wxTimer(self, self.timerId)
759 self.wx.EVT_TIMER(self, self.timerId, self.OnTimer)
759 self.wx.EVT_TIMER(self, self.timerId, self.OnTimer)
760 self.timer.Start(self.interval)
760 self.timer.Start(self.interval)
761
761
762 def OnTimer(self, event):
762 def OnTimer(self, event):
763 update_tk(self.tk)
763 update_tk(self.tk)
764 self.IP.runcode()
764 self.IP.runcode()
765
765
766 class App(self.wx.wxApp):
766 class App(self.wx.wxApp):
767 wx = self.wx
767 wx = self.wx
768 TIMEOUT = self.TIMEOUT
768 TIMEOUT = self.TIMEOUT
769 def OnInit(self):
769 def OnInit(self):
770 'Create the main window and insert the custom frame'
770 'Create the main window and insert the custom frame'
771 self.agent = TimerAgent(None, self.TIMEOUT)
771 self.agent = TimerAgent(None, self.TIMEOUT)
772 self.agent.Show(self.wx.false)
772 self.agent.Show(self.wx.false)
773 self.agent.StartWork()
773 self.agent.StartWork()
774 return self.wx.true
774 return self.wx.true
775
775
776 self.app = App(redirect=False)
776 self.app = App(redirect=False)
777 self.wx_mainloop(self.app)
777 self.wx_mainloop(self.app)
778 self.join()
778 self.join()
779
779
780
780
781 class IPShellQt(threading.Thread):
781 class IPShellQt(threading.Thread):
782 """Run a Qt event loop in a separate thread.
782 """Run a Qt event loop in a separate thread.
783
783
784 Python commands can be passed to the thread where they will be executed.
784 Python commands can be passed to the thread where they will be executed.
785 This is implemented by periodically checking for passed code using a
785 This is implemented by periodically checking for passed code using a
786 Qt timer / slot."""
786 Qt timer / slot."""
787
787
788 TIMEOUT = 100 # Millisecond interval between timeouts.
788 TIMEOUT = 100 # Millisecond interval between timeouts.
789
789
790 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
790 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
791 debug=0,shell_class=MTInteractiveShell):
791 debug=0,shell_class=MTInteractiveShell):
792
792
793 import qt
793 import qt
794
794
795 class newQApplication:
795 class newQApplication:
796 def __init__( self ):
796 def __init__( self ):
797 self.QApplication = qt.QApplication
797 self.QApplication = qt.QApplication
798
798
799 def __call__( *args, **kwargs ):
799 def __call__( *args, **kwargs ):
800 return qt.qApp
800 return qt.qApp
801
801
802 def exec_loop( *args, **kwargs ):
802 def exec_loop( *args, **kwargs ):
803 pass
803 pass
804
804
805 def __getattr__( self, name ):
805 def __getattr__( self, name ):
806 return getattr( self.QApplication, name )
806 return getattr( self.QApplication, name )
807
807
808 qt.QApplication = newQApplication()
808 qt.QApplication = newQApplication()
809
809
810 # Allows us to use both Tk and QT.
810 # Allows us to use both Tk and QT.
811 self.tk = get_tk()
811 self.tk = get_tk()
812
812
813 self.IP = make_IPython(argv,user_ns=user_ns,
813 self.IP = make_IPython(argv,user_ns=user_ns,
814 user_global_ns=user_global_ns,
814 user_global_ns=user_global_ns,
815 debug=debug,
815 debug=debug,
816 shell_class=shell_class,
816 shell_class=shell_class,
817 on_kill=[qt.qApp.exit])
817 on_kill=[qt.qApp.exit])
818
818
819 # HACK: slot for banner in self; it will be passed to the mainloop
819 # HACK: slot for banner in self; it will be passed to the mainloop
820 # method only and .run() needs it. The actual value will be set by
820 # method only and .run() needs it. The actual value will be set by
821 # .mainloop().
821 # .mainloop().
822 self._banner = None
822 self._banner = None
823
823
824 threading.Thread.__init__(self)
824 threading.Thread.__init__(self)
825
825
826 def run(self):
826 def run(self):
827 self.IP.mainloop(self._banner)
827 self.IP.mainloop(self._banner)
828 self.IP.kill()
828 self.IP.kill()
829
829
830 def mainloop(self,sys_exit=0,banner=None):
830 def mainloop(self,sys_exit=0,banner=None):
831
831
832 import qt
832 import qt
833
833
834 self._banner = banner
834 self._banner = banner
835
835
836 if qt.QApplication.startingUp():
836 if qt.QApplication.startingUp():
837 a = qt.QApplication.QApplication(sys.argv)
837 a = qt.QApplication.QApplication(sys.argv)
838 self.timer = qt.QTimer()
838 self.timer = qt.QTimer()
839 qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer )
839 qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer )
840
840
841 self.start()
841 self.start()
842 self.timer.start( self.TIMEOUT, True )
842 self.timer.start( self.TIMEOUT, True )
843 while True:
843 while True:
844 if self.IP._kill: break
844 if self.IP._kill: break
845 qt.qApp.exec_loop()
845 qt.qApp.exec_loop()
846 self.join()
846 self.join()
847
847
848 def on_timer(self):
848 def on_timer(self):
849 update_tk(self.tk)
849 update_tk(self.tk)
850 result = self.IP.runcode()
850 result = self.IP.runcode()
851 self.timer.start( self.TIMEOUT, True )
851 self.timer.start( self.TIMEOUT, True )
852 return result
852 return result
853
853
854 # A set of matplotlib public IPython shell classes, for single-threaded
854 # A set of matplotlib public IPython shell classes, for single-threaded
855 # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use.
855 # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use.
856 class IPShellMatplotlib(IPShell):
856 class IPShellMatplotlib(IPShell):
857 """Subclass IPShell with MatplotlibShell as the internal shell.
857 """Subclass IPShell with MatplotlibShell as the internal shell.
858
858
859 Single-threaded class, meant for the Tk* and FLTK* backends.
859 Single-threaded class, meant for the Tk* and FLTK* backends.
860
860
861 Having this on a separate class simplifies the external driver code."""
861 Having this on a separate class simplifies the external driver code."""
862
862
863 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
863 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
864 IPShell.__init__(self,argv,user_ns,user_global_ns,debug,
864 IPShell.__init__(self,argv,user_ns,user_global_ns,debug,
865 shell_class=MatplotlibShell)
865 shell_class=MatplotlibShell)
866
866
867 class IPShellMatplotlibGTK(IPShellGTK):
867 class IPShellMatplotlibGTK(IPShellGTK):
868 """Subclass IPShellGTK with MatplotlibMTShell as the internal shell.
868 """Subclass IPShellGTK with MatplotlibMTShell as the internal shell.
869
869
870 Multi-threaded class, meant for the GTK* backends."""
870 Multi-threaded class, meant for the GTK* backends."""
871
871
872 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
872 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
873 IPShellGTK.__init__(self,argv,user_ns,user_global_ns,debug,
873 IPShellGTK.__init__(self,argv,user_ns,user_global_ns,debug,
874 shell_class=MatplotlibMTShell)
874 shell_class=MatplotlibMTShell)
875
875
876 class IPShellMatplotlibWX(IPShellWX):
876 class IPShellMatplotlibWX(IPShellWX):
877 """Subclass IPShellWX with MatplotlibMTShell as the internal shell.
877 """Subclass IPShellWX with MatplotlibMTShell as the internal shell.
878
878
879 Multi-threaded class, meant for the WX* backends."""
879 Multi-threaded class, meant for the WX* backends."""
880
880
881 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
881 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
882 IPShellWX.__init__(self,argv,user_ns,user_global_ns,debug,
882 IPShellWX.__init__(self,argv,user_ns,user_global_ns,debug,
883 shell_class=MatplotlibMTShell)
883 shell_class=MatplotlibMTShell)
884
884
885 class IPShellMatplotlibQt(IPShellQt):
885 class IPShellMatplotlibQt(IPShellQt):
886 """Subclass IPShellQt with MatplotlibMTShell as the internal shell.
886 """Subclass IPShellQt with MatplotlibMTShell as the internal shell.
887
887
888 Multi-threaded class, meant for the Qt* backends."""
888 Multi-threaded class, meant for the Qt* backends."""
889
889
890 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
890 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
891 IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug,
891 IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug,
892 shell_class=MatplotlibMTShell)
892 shell_class=MatplotlibMTShell)
893
893
894 #-----------------------------------------------------------------------------
894 #-----------------------------------------------------------------------------
895 # Factory functions to actually start the proper thread-aware shell
895 # Factory functions to actually start the proper thread-aware shell
896
896
897 def _matplotlib_shell_class():
897 def _matplotlib_shell_class():
898 """Factory function to handle shell class selection for matplotlib.
898 """Factory function to handle shell class selection for matplotlib.
899
899
900 The proper shell class to use depends on the matplotlib backend, since
900 The proper shell class to use depends on the matplotlib backend, since
901 each backend requires a different threading strategy."""
901 each backend requires a different threading strategy."""
902
902
903 try:
903 try:
904 import matplotlib
904 import matplotlib
905 except ImportError:
905 except ImportError:
906 error('matplotlib could NOT be imported! Starting normal IPython.')
906 error('matplotlib could NOT be imported! Starting normal IPython.')
907 sh_class = IPShell
907 sh_class = IPShell
908 else:
908 else:
909 backend = matplotlib.rcParams['backend']
909 backend = matplotlib.rcParams['backend']
910 if backend.startswith('GTK'):
910 if backend.startswith('GTK'):
911 sh_class = IPShellMatplotlibGTK
911 sh_class = IPShellMatplotlibGTK
912 elif backend.startswith('WX'):
912 elif backend.startswith('WX'):
913 sh_class = IPShellMatplotlibWX
913 sh_class = IPShellMatplotlibWX
914 elif backend.startswith('Qt'):
914 elif backend.startswith('Qt'):
915 sh_class = IPShellMatplotlibQt
915 sh_class = IPShellMatplotlibQt
916 else:
916 else:
917 sh_class = IPShellMatplotlib
917 sh_class = IPShellMatplotlib
918 #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg
918 #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg
919 return sh_class
919 return sh_class
920
920
921 # This is the one which should be called by external code.
921 # This is the one which should be called by external code.
922 def start():
922 def start(user_ns = None):
923 """Return a running shell instance, dealing with threading options.
923 """Return a running shell instance, dealing with threading options.
924
924
925 This is a factory function which will instantiate the proper IPython shell
925 This is a factory function which will instantiate the proper IPython shell
926 based on the user's threading choice. Such a selector is needed because
926 based on the user's threading choice. Such a selector is needed because
927 different GUI toolkits require different thread handling details."""
927 different GUI toolkits require different thread handling details."""
928
928
929 global USE_TK
929 global USE_TK
930 # Crude sys.argv hack to extract the threading options.
930 # Crude sys.argv hack to extract the threading options.
931 argv = sys.argv
931 argv = sys.argv
932 if len(argv) > 1:
932 if len(argv) > 1:
933 if len(argv) > 2:
933 if len(argv) > 2:
934 arg2 = argv[2]
934 arg2 = argv[2]
935 if arg2.endswith('-tk'):
935 if arg2.endswith('-tk'):
936 USE_TK = True
936 USE_TK = True
937 arg1 = argv[1]
937 arg1 = argv[1]
938 if arg1.endswith('-gthread'):
938 if arg1.endswith('-gthread'):
939 shell = IPShellGTK
939 shell = IPShellGTK
940 elif arg1.endswith( '-qthread' ):
940 elif arg1.endswith( '-qthread' ):
941 shell = IPShellQt
941 shell = IPShellQt
942 elif arg1.endswith('-wthread'):
942 elif arg1.endswith('-wthread'):
943 shell = IPShellWX
943 shell = IPShellWX
944 elif arg1.endswith('-pylab'):
944 elif arg1.endswith('-pylab'):
945 shell = _matplotlib_shell_class()
945 shell = _matplotlib_shell_class()
946 else:
946 else:
947 shell = IPShell
947 shell = IPShell
948 else:
948 else:
949 shell = IPShell
949 shell = IPShell
950 return shell()
950 return shell(user_ns = user_ns)
951
951
952 # Some aliases for backwards compatibility
952 # Some aliases for backwards compatibility
953 IPythonShell = IPShell
953 IPythonShell = IPShell
954 IPythonShellEmbed = IPShellEmbed
954 IPythonShellEmbed = IPShellEmbed
955 #************************ End of file <Shell.py> ***************************
955 #************************ End of file <Shell.py> ***************************
@@ -1,50 +1,50 b''
1 """ User configuration file for IPython
1 """ User configuration file for IPython
2
2
3 This is a more flexible and safe way to configure ipython than *rc files
3 This is a more flexible and safe way to configure ipython than *rc files
4 (ipythonrc, ipythonrc-pysh etc.)
4 (ipythonrc, ipythonrc-pysh etc.)
5
5
6 This file is always imported on ipython startup. You should import all the
6 This file is always imported on ipython startup. You should import all the
7 ipython extensions you need here (see IPython/Extensions directory).
7 ipython extensions you need here (see IPython/Extensions directory).
8
8
9 Feel free to edit this file to customize your ipython experience. If
9 Feel free to edit this file to customize your ipython experience. If
10 you wish to only use the old config system, it's perfectly ok to make this file
10 you wish to only use the old config system, it's perfectly ok to make this file
11 empty.
11 empty.
12
12
13 """
13 """
14
14
15 # Most of your config files and extensions will probably start with this import
15 # Most of your config files and extensions will probably start with this import
16
16
17 import IPython.ipapi as ip
17 from IPython import ipapi
18
18 ip = ipapi.get()
19 import os
19 import os
20
20
21 o = ip.options()
21 o = ip.options()
22 # autocall 1 ('smart') is default anyway, this is just an
22 # autocall 1 ('smart') is default anyway, this is just an
23 # example on how to set an option
23 # example on how to set an option
24 o.autocall = 1
24 o.autocall = 1
25
25
26 if o.profile == 'pysh':
26 if o.profile == 'pysh':
27 # Jason Orendorff's path class is handy to have in user namespace
27 # Jason Orendorff's path class is handy to have in user namespace
28 # if you are doing shell-like stuff
28 # if you are doing shell-like stuff
29 ip.ex("from IPython.path import path" )
29 ip.ex("from IPython.path import path" )
30
30
31 # Uncomment these lines to get pysh-like prompt for all profiles.
31 # Uncomment these lines to get pysh-like prompt for all profiles.
32
32
33 #o.prompt_in1= '\C_LightBlue[\C_LightCyan\Y1\C_LightBlue]\C_Green|\#> '
33 #o.prompt_in1= '\C_LightBlue[\C_LightCyan\Y1\C_LightBlue]\C_Green|\#> '
34 #o.prompt_in2= '\C_Green|\C_LightGreen\D\C_Green> '
34 #o.prompt_in2= '\C_Green|\C_LightGreen\D\C_Green> '
35 #o.prompt_out= '<\#> '
35 #o.prompt_out= '<\#> '
36
36
37 # make 'd' an alias for ls -F
37 # make 'd' an alias for ls -F
38
38
39 ip.magic('alias d ls -F --color=auto')
39 ip.magic('alias d ls -F --color=auto')
40
40
41 # Make available all system commands through "rehashing" immediately.
41 # Make available all system commands through "rehashing" immediately.
42 # You can comment these lines out to speed up startup on very slow
42 # You can comment these lines out to speed up startup on very slow
43 # machines, and to conserve a bit of memory. Note that pysh profile does this
43 # machines, and to conserve a bit of memory. Note that pysh profile does this
44 # automatically
44 # automatically
45
45
46 #if os.name=='posix':
46 #if os.name=='posix':
47 # ip.magic('rehash')
47 # ip.magic('rehash')
48 #else:
48 #else:
49 # #slightly slower, but better results esp. with Windows
49 # #slightly slower, but better results esp. with Windows
50 # ip.magic('rehashx')
50 # ip.magic('rehashx')
@@ -1,174 +1,168 b''
1 ''' IPython customization API
1 ''' IPython customization API
2
2
3 Your one-stop module for configuring & extending ipython
3 Your one-stop module for configuring & extending ipython
4
4
5 The API will probably break when ipython 1.0 is released, but so
5 The API will probably break when ipython 1.0 is released, but so
6 will the other configuration method (rc files).
6 will the other configuration method (rc files).
7
7
8 All names prefixed by underscores are for internal use, not part
8 All names prefixed by underscores are for internal use, not part
9 of the public api.
9 of the public api.
10
10
11 Below is an example that you can just put to a module and import from ipython.
11 Below is an example that you can just put to a module and import from ipython.
12
12
13 A good practice is to install the config script below as e.g.
13 A good practice is to install the config script below as e.g.
14
14
15 ~/.ipython/my_private_conf.py
15 ~/.ipython/my_private_conf.py
16
16
17 And do
17 And do
18
18
19 import_mod my_private_conf
19 import_mod my_private_conf
20
20
21 in ~/.ipython/ipythonrc
21 in ~/.ipython/ipythonrc
22
22
23 That way the module is imported at startup and you can have all your
23 That way the module is imported at startup and you can have all your
24 personal configuration (as opposed to boilerplate ipythonrc-PROFILENAME
24 personal configuration (as opposed to boilerplate ipythonrc-PROFILENAME
25 stuff) in there.
25 stuff) in there.
26
26
27 -----------------------------------------------
27 -----------------------------------------------
28 import IPython.ipapi as ip
28 import IPython.ipapi as ip
29
29
30 def ankka_f(self, arg):
30 def ankka_f(self, arg):
31 print "Ankka",self,"says uppercase:",arg.upper()
31 print "Ankka",self,"says uppercase:",arg.upper()
32
32
33 ip.expose_magic("ankka",ankka_f)
33 ip.expose_magic("ankka",ankka_f)
34
34
35 ip.magic('alias sayhi echo "Testing, hi ok"')
35 ip.magic('alias sayhi echo "Testing, hi ok"')
36 ip.magic('alias helloworld echo "Hello world"')
36 ip.magic('alias helloworld echo "Hello world"')
37 ip.system('pwd')
37 ip.system('pwd')
38
38
39 ip.ex('import re')
39 ip.ex('import re')
40 ip.ex("""
40 ip.ex("""
41 def funcci(a,b):
41 def funcci(a,b):
42 print a+b
42 print a+b
43 print funcci(3,4)
43 print funcci(3,4)
44 """)
44 """)
45 ip.ex("funcci(348,9)")
45 ip.ex("funcci(348,9)")
46
46
47 def jed_editor(self,filename, linenum=None):
47 def jed_editor(self,filename, linenum=None):
48 print "Calling my own editor, jed ... via hook!"
48 print "Calling my own editor, jed ... via hook!"
49 import os
49 import os
50 if linenum is None: linenum = 0
50 if linenum is None: linenum = 0
51 os.system('jed +%d %s' % (linenum, filename))
51 os.system('jed +%d %s' % (linenum, filename))
52 print "exiting jed"
52 print "exiting jed"
53
53
54 ip.set_hook('editor',jed_editor)
54 ip.set_hook('editor',jed_editor)
55
55
56 o = ip.options()
56 o = ip.options()
57 o.autocall = 2 # FULL autocall mode
57 o.autocall = 2 # FULL autocall mode
58
58
59 print "done!"
59 print "done!"
60
60
61 '''
61 '''
62
62
63
63
64 class TryNext(Exception):
64 class TryNext(Exception):
65 """ Try next hook exception.
65 """ Try next hook exception.
66
66
67 Raise this in your hook function to indicate that the next
67 Raise this in your hook function to indicate that the next
68 hook handler should be used to handle the operation.
68 hook handler should be used to handle the operation.
69 """
69 """
70
70
71
71
72
72 # contains the most recently instantiated IPApi
73 __IP = None
73 _recent = None
74
75 def _init_with_shell(ip):
76 global magic
77 magic = ip.ipmagic
78 global system
79 system = ip.ipsystem
80 global set_hook
81 set_hook = ip.set_hook
82
83 global __IP
84 __IP = ip
85
86 def options():
87 """ All configurable variables """
88 return __IP.rc
89
74
90 def user_ns():
75 def get():
91 return __IP.user_ns
76 """ Get an IPApi object, or None if not running under ipython
92
77
93 def expose_magic(magicname, func):
78 Running this should be the first thing you do when writing
94 ''' Expose own function as magic function for ipython
79 extensions that can be imported as normal modules. You can then
80 direct all the configuration operations against the returned
81 object.
95
82
96 def foo_impl(self,parameter_s=''):
83 """
97 """My very own magic!. (Use docstrings, IPython reads them)."""
98 print 'Magic function. Passed parameter is between < >: <'+parameter_s+'>'
99 print 'The self object is:',self
100
84
101 ipapi.expose_magic("foo",foo_impl)
85 return _recent
102 '''
103
104 from IPython import Magic
105 import new
106 im = new.instancemethod(func,__IP, __IP.__class__)
107 setattr(__IP, "magic_" + magicname, im)
108
86
109 class asmagic:
87
110 """ Decorator for exposing magics in a friendly 2.4 decorator form
88
89 class IPApi:
90 """ The actual API class for configuring IPython
111
91
112 @ip.asmagic("foo")
92 You should do all of the IPython configuration by getting
113 def f(self,arg):
93 an IPApi object with IPython.ipapi.get() and using the provided
114 pring "arg given:",arg
94 methods.
115
95
116 After this, %foo is a magic function.
117 """
96 """
118
97 def __init__(self,ip):
119 def __init__(self,magicname):
98
120 self.name = magicname
99 self.magic = ip.ipmagic
100
101 self.system = ip.ipsystem
102
103 self.set_hook = ip.set_hook
121
104
122 def __call__(self,f):
105 self.IP = ip
123 expose_magic(self.name, f)
106 global _recent
124 return f
107 _recent = self
125
108
126 class ashook:
109
127 """ Decorator for exposing magics in a friendly 2.4 decorator form
128
110
129 @ip.ashook("editor")
111 def options(self):
130 def jed_editor(self,filename, linenum=None):
112 """ All configurable variables """
131 import os
113 return self.IP.rc
132 if linenum is None: linenum = 0
133 os.system('jed +%d %s' % (linenum, filename))
134
114
135 """
115 def user_ns(self):
116 return self.IP.user_ns
136
117
137 def __init__(self,name,priority=50):
118 def expose_magic(self,magicname, func):
138 self.name = name
119 ''' Expose own function as magic function for ipython
139 self.prio = priority
120
140
121 def foo_impl(self,parameter_s=''):
141 def __call__(self,f):
122 """My very own magic!. (Use docstrings, IPython reads them)."""
142 set_hook(self.name, f, self.prio)
123 print 'Magic function. Passed parameter is between < >: <'+parameter_s+'>'
143 return f
124 print 'The self object is:',self
144
125
145
126 ipapi.expose_magic("foo",foo_impl)
146 def ex(cmd):
127 '''
147 """ Execute a normal python statement in user namespace """
128
148 exec cmd in user_ns()
129 import new
149
130 im = new.instancemethod(func,self.IP, self.IP.__class__)
150 def ev(expr):
131 setattr(self.IP, "magic_" + magicname, im)
151 """ Evaluate python expression expr in user namespace
132
133
134 def ex(self,cmd):
135 """ Execute a normal python statement in user namespace """
136 exec cmd in self.user_ns()
152
137
153 Returns the result """
138 def ev(self,expr):
154 return eval(expr,user_ns())
139 """ Evaluate python expression expr in user namespace
140
141 Returns the result of evaluation"""
142 return eval(expr,self.user_ns())
155
143
156 def launch_new_instance():
144 def launch_new_instance(user_ns = None):
157 """ Create and start a new ipython instance.
145 """ Create and start a new ipython instance.
158
146
159 This can be called even without having an already initialized
147 This can be called even without having an already initialized
160 ipython session running.
148 ipython session running.
161
149
150 This is also used as the egg entry point for the 'ipython' script.
151
162 """
152 """
163 import IPython
153 ses = create_session(user_ns)
154 ses.mainloop()
164
155
165 IPython.Shell.start().mainloop()
166
156
167 def is_ipython_session():
157 def create_session(user_ns = None):
168 """ Return a true value if running inside IPython.
158 """ Creates, but does not launch an IPython session.
169
159
170 """
160 Later on you can call obj.mainloop() on the returned object.
171
161
172 # Yes, this is the shell object or None - however, it's an implementation
162 This should *not* be run when a session exists already.
173 # detail and should not be relied on, only truth value matters.
163
174 return __IP
164 """
165 if user_ns is not None:
166 user_ns["__name__"] = user_ns.get("__name__",'ipy_session')
167 import IPython
168 return IPython.Shell.start(user_ns = user_ns) No newline at end of file
@@ -1,2234 +1,2235 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.3 or newer.
5 Requires Python 2.3 or newer.
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 1077 2006-01-24 18:15:27Z vivainio $
9 $Id: iplib.py 1079 2006-01-24 21:52:31Z vivainio $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
18 #
18 #
19 # Note: this code originally subclassed code.InteractiveConsole from the
19 # Note: this code originally subclassed code.InteractiveConsole from the
20 # Python standard library. Over time, all of that class has been copied
20 # Python standard library. Over time, all of that class has been copied
21 # verbatim here for modifications which could not be accomplished by
21 # verbatim here for modifications which could not be accomplished by
22 # subclassing. At this point, there are no dependencies at all on the code
22 # subclassing. At this point, there are no dependencies at all on the code
23 # module anymore (it is not even imported). The Python License (sec. 2)
23 # module anymore (it is not even imported). The Python License (sec. 2)
24 # allows for this, but it's always nice to acknowledge credit where credit is
24 # allows for this, but it's always nice to acknowledge credit where credit is
25 # due.
25 # due.
26 #*****************************************************************************
26 #*****************************************************************************
27
27
28 #****************************************************************************
28 #****************************************************************************
29 # Modules and globals
29 # Modules and globals
30
30
31 from __future__ import generators # for 2.2 backwards-compatibility
31 from __future__ import generators # for 2.2 backwards-compatibility
32
32
33 from IPython import Release
33 from IPython import Release
34 __author__ = '%s <%s>\n%s <%s>' % \
34 __author__ = '%s <%s>\n%s <%s>' % \
35 ( Release.authors['Janko'] + Release.authors['Fernando'] )
35 ( Release.authors['Janko'] + Release.authors['Fernando'] )
36 __license__ = Release.license
36 __license__ = Release.license
37 __version__ = Release.version
37 __version__ = Release.version
38
38
39 # Python standard modules
39 # Python standard modules
40 import __main__
40 import __main__
41 import __builtin__
41 import __builtin__
42 import StringIO
42 import StringIO
43 import bdb
43 import bdb
44 import cPickle as pickle
44 import cPickle as pickle
45 import codeop
45 import codeop
46 import exceptions
46 import exceptions
47 import glob
47 import glob
48 import inspect
48 import inspect
49 import keyword
49 import keyword
50 import new
50 import new
51 import os
51 import os
52 import pdb
52 import pdb
53 import pydoc
53 import pydoc
54 import re
54 import re
55 import shutil
55 import shutil
56 import string
56 import string
57 import sys
57 import sys
58 import tempfile
58 import tempfile
59 import traceback
59 import traceback
60 import types
60 import types
61
61
62 from pprint import pprint, pformat
62 from pprint import pprint, pformat
63
63
64 # IPython's own modules
64 # IPython's own modules
65 import IPython
65 import IPython
66 from IPython import OInspect,PyColorize,ultraTB
66 from IPython import OInspect,PyColorize,ultraTB
67 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
67 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
68 from IPython.FakeModule import FakeModule
68 from IPython.FakeModule import FakeModule
69 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
69 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
70 from IPython.Logger import Logger
70 from IPython.Logger import Logger
71 from IPython.Magic import Magic
71 from IPython.Magic import Magic
72 from IPython.Prompts import CachedOutput
72 from IPython.Prompts import CachedOutput
73 from IPython.ipstruct import Struct
73 from IPython.ipstruct import Struct
74 from IPython.background_jobs import BackgroundJobManager
74 from IPython.background_jobs import BackgroundJobManager
75 from IPython.usage import cmd_line_usage,interactive_usage
75 from IPython.usage import cmd_line_usage,interactive_usage
76 from IPython.genutils import *
76 from IPython.genutils import *
77 import IPython.ipapi
77 import IPython.ipapi
78
78
79 # Globals
79 # Globals
80
80
81 # store the builtin raw_input globally, and use this always, in case user code
81 # store the builtin raw_input globally, and use this always, in case user code
82 # overwrites it (like wx.py.PyShell does)
82 # overwrites it (like wx.py.PyShell does)
83 raw_input_original = raw_input
83 raw_input_original = raw_input
84
84
85 # compiled regexps for autoindent management
85 # compiled regexps for autoindent management
86 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
86 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
87
87
88
88
89 #****************************************************************************
89 #****************************************************************************
90 # Some utility function definitions
90 # Some utility function definitions
91
91
92 ini_spaces_re = re.compile(r'^(\s+)')
92 ini_spaces_re = re.compile(r'^(\s+)')
93
93
94 def num_ini_spaces(strng):
94 def num_ini_spaces(strng):
95 """Return the number of initial spaces in a string"""
95 """Return the number of initial spaces in a string"""
96
96
97 ini_spaces = ini_spaces_re.match(strng)
97 ini_spaces = ini_spaces_re.match(strng)
98 if ini_spaces:
98 if ini_spaces:
99 return ini_spaces.end()
99 return ini_spaces.end()
100 else:
100 else:
101 return 0
101 return 0
102
102
103 def softspace(file, newvalue):
103 def softspace(file, newvalue):
104 """Copied from code.py, to remove the dependency"""
104 """Copied from code.py, to remove the dependency"""
105
105
106 oldvalue = 0
106 oldvalue = 0
107 try:
107 try:
108 oldvalue = file.softspace
108 oldvalue = file.softspace
109 except AttributeError:
109 except AttributeError:
110 pass
110 pass
111 try:
111 try:
112 file.softspace = newvalue
112 file.softspace = newvalue
113 except (AttributeError, TypeError):
113 except (AttributeError, TypeError):
114 # "attribute-less object" or "read-only attributes"
114 # "attribute-less object" or "read-only attributes"
115 pass
115 pass
116 return oldvalue
116 return oldvalue
117
117
118
118
119 #****************************************************************************
119 #****************************************************************************
120 # Local use exceptions
120 # Local use exceptions
121 class SpaceInInput(exceptions.Exception): pass
121 class SpaceInInput(exceptions.Exception): pass
122
122
123
123
124 #****************************************************************************
124 #****************************************************************************
125 # Local use classes
125 # Local use classes
126 class Bunch: pass
126 class Bunch: pass
127
127
128 class Undefined: pass
128 class Undefined: pass
129
129
130 class InputList(list):
130 class InputList(list):
131 """Class to store user input.
131 """Class to store user input.
132
132
133 It's basically a list, but slices return a string instead of a list, thus
133 It's basically a list, but slices return a string instead of a list, thus
134 allowing things like (assuming 'In' is an instance):
134 allowing things like (assuming 'In' is an instance):
135
135
136 exec In[4:7]
136 exec In[4:7]
137
137
138 or
138 or
139
139
140 exec In[5:9] + In[14] + In[21:25]"""
140 exec In[5:9] + In[14] + In[21:25]"""
141
141
142 def __getslice__(self,i,j):
142 def __getslice__(self,i,j):
143 return ''.join(list.__getslice__(self,i,j))
143 return ''.join(list.__getslice__(self,i,j))
144
144
145 class SyntaxTB(ultraTB.ListTB):
145 class SyntaxTB(ultraTB.ListTB):
146 """Extension which holds some state: the last exception value"""
146 """Extension which holds some state: the last exception value"""
147
147
148 def __init__(self,color_scheme = 'NoColor'):
148 def __init__(self,color_scheme = 'NoColor'):
149 ultraTB.ListTB.__init__(self,color_scheme)
149 ultraTB.ListTB.__init__(self,color_scheme)
150 self.last_syntax_error = None
150 self.last_syntax_error = None
151
151
152 def __call__(self, etype, value, elist):
152 def __call__(self, etype, value, elist):
153 self.last_syntax_error = value
153 self.last_syntax_error = value
154 ultraTB.ListTB.__call__(self,etype,value,elist)
154 ultraTB.ListTB.__call__(self,etype,value,elist)
155
155
156 def clear_err_state(self):
156 def clear_err_state(self):
157 """Return the current error state and clear it"""
157 """Return the current error state and clear it"""
158 e = self.last_syntax_error
158 e = self.last_syntax_error
159 self.last_syntax_error = None
159 self.last_syntax_error = None
160 return e
160 return e
161
161
162 #****************************************************************************
162 #****************************************************************************
163 # Main IPython class
163 # Main IPython class
164
164
165 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
165 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
166 # until a full rewrite is made. I've cleaned all cross-class uses of
166 # until a full rewrite is made. I've cleaned all cross-class uses of
167 # attributes and methods, but too much user code out there relies on the
167 # attributes and methods, but too much user code out there relies on the
168 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
168 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
169 #
169 #
170 # But at least now, all the pieces have been separated and we could, in
170 # But at least now, all the pieces have been separated and we could, in
171 # principle, stop using the mixin. This will ease the transition to the
171 # principle, stop using the mixin. This will ease the transition to the
172 # chainsaw branch.
172 # chainsaw branch.
173
173
174 # For reference, the following is the list of 'self.foo' uses in the Magic
174 # For reference, the following is the list of 'self.foo' uses in the Magic
175 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
175 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
176 # class, to prevent clashes.
176 # class, to prevent clashes.
177
177
178 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
178 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
179 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
179 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
180 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
180 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
181 # 'self.value']
181 # 'self.value']
182
182
183 class InteractiveShell(object,Magic):
183 class InteractiveShell(object,Magic):
184 """An enhanced console for Python."""
184 """An enhanced console for Python."""
185
185
186 # class attribute to indicate whether the class supports threads or not.
186 # class attribute to indicate whether the class supports threads or not.
187 # Subclasses with thread support should override this as needed.
187 # Subclasses with thread support should override this as needed.
188 isthreaded = False
188 isthreaded = False
189
189
190 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
190 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
191 user_ns = None,user_global_ns=None,banner2='',
191 user_ns = None,user_global_ns=None,banner2='',
192 custom_exceptions=((),None),embedded=False):
192 custom_exceptions=((),None),embedded=False):
193
193
194 # log system
194 # log system
195 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
195 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
196
196
197 # introduce ourselves to IPython.ipapi which is uncallable
197 # Produce a public API instance
198 # before it knows an InteractiveShell object.
198
199 IPython.ipapi._init_with_shell(self)
199 self.api = IPython.ipapi.IPApi(self)
200
200
201
201 # some minimal strict typechecks. For some core data structures, I
202 # some minimal strict typechecks. For some core data structures, I
202 # want actual basic python types, not just anything that looks like
203 # want actual basic python types, not just anything that looks like
203 # one. This is especially true for namespaces.
204 # one. This is especially true for namespaces.
204 for ns in (user_ns,user_global_ns):
205 for ns in (user_ns,user_global_ns):
205 if ns is not None and type(ns) != types.DictType:
206 if ns is not None and type(ns) != types.DictType:
206 raise TypeError,'namespace must be a dictionary'
207 raise TypeError,'namespace must be a dictionary'
207
208
208 # Job manager (for jobs run as background threads)
209 # Job manager (for jobs run as background threads)
209 self.jobs = BackgroundJobManager()
210 self.jobs = BackgroundJobManager()
210
211
211 # track which builtins we add, so we can clean up later
212 # track which builtins we add, so we can clean up later
212 self.builtins_added = {}
213 self.builtins_added = {}
213 # This method will add the necessary builtins for operation, but
214 # This method will add the necessary builtins for operation, but
214 # tracking what it did via the builtins_added dict.
215 # tracking what it did via the builtins_added dict.
215 self.add_builtins()
216 self.add_builtins()
216
217
217 # Do the intuitively correct thing for quit/exit: we remove the
218 # Do the intuitively correct thing for quit/exit: we remove the
218 # builtins if they exist, and our own magics will deal with this
219 # builtins if they exist, and our own magics will deal with this
219 try:
220 try:
220 del __builtin__.exit, __builtin__.quit
221 del __builtin__.exit, __builtin__.quit
221 except AttributeError:
222 except AttributeError:
222 pass
223 pass
223
224
224 # Store the actual shell's name
225 # Store the actual shell's name
225 self.name = name
226 self.name = name
226
227
227 # We need to know whether the instance is meant for embedding, since
228 # We need to know whether the instance is meant for embedding, since
228 # global/local namespaces need to be handled differently in that case
229 # global/local namespaces need to be handled differently in that case
229 self.embedded = embedded
230 self.embedded = embedded
230
231
231 # command compiler
232 # command compiler
232 self.compile = codeop.CommandCompiler()
233 self.compile = codeop.CommandCompiler()
233
234
234 # User input buffer
235 # User input buffer
235 self.buffer = []
236 self.buffer = []
236
237
237 # Default name given in compilation of code
238 # Default name given in compilation of code
238 self.filename = '<ipython console>'
239 self.filename = '<ipython console>'
239
240
240 # Make an empty namespace, which extension writers can rely on both
241 # Make an empty namespace, which extension writers can rely on both
241 # existing and NEVER being used by ipython itself. This gives them a
242 # existing and NEVER being used by ipython itself. This gives them a
242 # convenient location for storing additional information and state
243 # convenient location for storing additional information and state
243 # their extensions may require, without fear of collisions with other
244 # their extensions may require, without fear of collisions with other
244 # ipython names that may develop later.
245 # ipython names that may develop later.
245 self.meta = Bunch()
246 self.meta = Bunch()
246
247
247 # Create the namespace where the user will operate. user_ns is
248 # Create the namespace where the user will operate. user_ns is
248 # normally the only one used, and it is passed to the exec calls as
249 # normally the only one used, and it is passed to the exec calls as
249 # the locals argument. But we do carry a user_global_ns namespace
250 # the locals argument. But we do carry a user_global_ns namespace
250 # given as the exec 'globals' argument, This is useful in embedding
251 # given as the exec 'globals' argument, This is useful in embedding
251 # situations where the ipython shell opens in a context where the
252 # situations where the ipython shell opens in a context where the
252 # distinction between locals and globals is meaningful.
253 # distinction between locals and globals is meaningful.
253
254
254 # FIXME. For some strange reason, __builtins__ is showing up at user
255 # FIXME. For some strange reason, __builtins__ is showing up at user
255 # level as a dict instead of a module. This is a manual fix, but I
256 # level as a dict instead of a module. This is a manual fix, but I
256 # should really track down where the problem is coming from. Alex
257 # should really track down where the problem is coming from. Alex
257 # Schmolck reported this problem first.
258 # Schmolck reported this problem first.
258
259
259 # A useful post by Alex Martelli on this topic:
260 # A useful post by Alex Martelli on this topic:
260 # Re: inconsistent value from __builtins__
261 # Re: inconsistent value from __builtins__
261 # Von: Alex Martelli <aleaxit@yahoo.com>
262 # Von: Alex Martelli <aleaxit@yahoo.com>
262 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
263 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
263 # Gruppen: comp.lang.python
264 # Gruppen: comp.lang.python
264
265
265 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
266 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
266 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
267 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
267 # > <type 'dict'>
268 # > <type 'dict'>
268 # > >>> print type(__builtins__)
269 # > >>> print type(__builtins__)
269 # > <type 'module'>
270 # > <type 'module'>
270 # > Is this difference in return value intentional?
271 # > Is this difference in return value intentional?
271
272
272 # Well, it's documented that '__builtins__' can be either a dictionary
273 # Well, it's documented that '__builtins__' can be either a dictionary
273 # or a module, and it's been that way for a long time. Whether it's
274 # or a module, and it's been that way for a long time. Whether it's
274 # intentional (or sensible), I don't know. In any case, the idea is
275 # intentional (or sensible), I don't know. In any case, the idea is
275 # that if you need to access the built-in namespace directly, you
276 # that if you need to access the built-in namespace directly, you
276 # should start with "import __builtin__" (note, no 's') which will
277 # should start with "import __builtin__" (note, no 's') which will
277 # definitely give you a module. Yeah, it's somewhat confusing:-(.
278 # definitely give you a module. Yeah, it's somewhat confusing:-(.
278
279
279 if user_ns is None:
280 if user_ns is None:
280 # Set __name__ to __main__ to better match the behavior of the
281 # Set __name__ to __main__ to better match the behavior of the
281 # normal interpreter.
282 # normal interpreter.
282 user_ns = {'__name__' :'__main__',
283 user_ns = {'__name__' :'__main__',
283 '__builtins__' : __builtin__,
284 '__builtins__' : __builtin__,
284 }
285 }
285
286
286 if user_global_ns is None:
287 if user_global_ns is None:
287 user_global_ns = {}
288 user_global_ns = {}
288
289
289 # Assign namespaces
290 # Assign namespaces
290 # This is the namespace where all normal user variables live
291 # This is the namespace where all normal user variables live
291 self.user_ns = user_ns
292 self.user_ns = user_ns
292 # Embedded instances require a separate namespace for globals.
293 # Embedded instances require a separate namespace for globals.
293 # Normally this one is unused by non-embedded instances.
294 # Normally this one is unused by non-embedded instances.
294 self.user_global_ns = user_global_ns
295 self.user_global_ns = user_global_ns
295 # A namespace to keep track of internal data structures to prevent
296 # A namespace to keep track of internal data structures to prevent
296 # them from cluttering user-visible stuff. Will be updated later
297 # them from cluttering user-visible stuff. Will be updated later
297 self.internal_ns = {}
298 self.internal_ns = {}
298
299
299 # Namespace of system aliases. Each entry in the alias
300 # Namespace of system aliases. Each entry in the alias
300 # table must be a 2-tuple of the form (N,name), where N is the number
301 # table must be a 2-tuple of the form (N,name), where N is the number
301 # of positional arguments of the alias.
302 # of positional arguments of the alias.
302 self.alias_table = {}
303 self.alias_table = {}
303
304
304 # A table holding all the namespaces IPython deals with, so that
305 # A table holding all the namespaces IPython deals with, so that
305 # introspection facilities can search easily.
306 # introspection facilities can search easily.
306 self.ns_table = {'user':user_ns,
307 self.ns_table = {'user':user_ns,
307 'user_global':user_global_ns,
308 'user_global':user_global_ns,
308 'alias':self.alias_table,
309 'alias':self.alias_table,
309 'internal':self.internal_ns,
310 'internal':self.internal_ns,
310 'builtin':__builtin__.__dict__
311 'builtin':__builtin__.__dict__
311 }
312 }
312
313
313 # The user namespace MUST have a pointer to the shell itself.
314 # The user namespace MUST have a pointer to the shell itself.
314 self.user_ns[name] = self
315 self.user_ns[name] = self
315
316
316 # We need to insert into sys.modules something that looks like a
317 # We need to insert into sys.modules something that looks like a
317 # module but which accesses the IPython namespace, for shelve and
318 # module but which accesses the IPython namespace, for shelve and
318 # pickle to work interactively. Normally they rely on getting
319 # pickle to work interactively. Normally they rely on getting
319 # everything out of __main__, but for embedding purposes each IPython
320 # everything out of __main__, but for embedding purposes each IPython
320 # instance has its own private namespace, so we can't go shoving
321 # instance has its own private namespace, so we can't go shoving
321 # everything into __main__.
322 # everything into __main__.
322
323
323 # note, however, that we should only do this for non-embedded
324 # note, however, that we should only do this for non-embedded
324 # ipythons, which really mimic the __main__.__dict__ with their own
325 # ipythons, which really mimic the __main__.__dict__ with their own
325 # namespace. Embedded instances, on the other hand, should not do
326 # namespace. Embedded instances, on the other hand, should not do
326 # this because they need to manage the user local/global namespaces
327 # this because they need to manage the user local/global namespaces
327 # only, but they live within a 'normal' __main__ (meaning, they
328 # only, but they live within a 'normal' __main__ (meaning, they
328 # shouldn't overtake the execution environment of the script they're
329 # shouldn't overtake the execution environment of the script they're
329 # embedded in).
330 # embedded in).
330
331
331 if not embedded:
332 if not embedded:
332 try:
333 try:
333 main_name = self.user_ns['__name__']
334 main_name = self.user_ns['__name__']
334 except KeyError:
335 except KeyError:
335 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
336 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
336 else:
337 else:
337 #print "pickle hack in place" # dbg
338 #print "pickle hack in place" # dbg
338 #print 'main_name:',main_name # dbg
339 #print 'main_name:',main_name # dbg
339 sys.modules[main_name] = FakeModule(self.user_ns)
340 sys.modules[main_name] = FakeModule(self.user_ns)
340
341
341 # List of input with multi-line handling.
342 # List of input with multi-line handling.
342 # Fill its zero entry, user counter starts at 1
343 # Fill its zero entry, user counter starts at 1
343 self.input_hist = InputList(['\n'])
344 self.input_hist = InputList(['\n'])
344 # This one will hold the 'raw' input history, without any
345 # This one will hold the 'raw' input history, without any
345 # pre-processing. This will allow users to retrieve the input just as
346 # pre-processing. This will allow users to retrieve the input just as
346 # it was exactly typed in by the user, with %hist -r.
347 # it was exactly typed in by the user, with %hist -r.
347 self.input_hist_raw = InputList(['\n'])
348 self.input_hist_raw = InputList(['\n'])
348
349
349 # list of visited directories
350 # list of visited directories
350 try:
351 try:
351 self.dir_hist = [os.getcwd()]
352 self.dir_hist = [os.getcwd()]
352 except IOError, e:
353 except IOError, e:
353 self.dir_hist = []
354 self.dir_hist = []
354
355
355 # dict of output history
356 # dict of output history
356 self.output_hist = {}
357 self.output_hist = {}
357
358
358 # dict of things NOT to alias (keywords, builtins and some magics)
359 # dict of things NOT to alias (keywords, builtins and some magics)
359 no_alias = {}
360 no_alias = {}
360 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
361 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
361 for key in keyword.kwlist + no_alias_magics:
362 for key in keyword.kwlist + no_alias_magics:
362 no_alias[key] = 1
363 no_alias[key] = 1
363 no_alias.update(__builtin__.__dict__)
364 no_alias.update(__builtin__.__dict__)
364 self.no_alias = no_alias
365 self.no_alias = no_alias
365
366
366 # make global variables for user access to these
367 # make global variables for user access to these
367 self.user_ns['_ih'] = self.input_hist
368 self.user_ns['_ih'] = self.input_hist
368 self.user_ns['_oh'] = self.output_hist
369 self.user_ns['_oh'] = self.output_hist
369 self.user_ns['_dh'] = self.dir_hist
370 self.user_ns['_dh'] = self.dir_hist
370
371
371 # user aliases to input and output histories
372 # user aliases to input and output histories
372 self.user_ns['In'] = self.input_hist
373 self.user_ns['In'] = self.input_hist
373 self.user_ns['Out'] = self.output_hist
374 self.user_ns['Out'] = self.output_hist
374
375
375 # Object variable to store code object waiting execution. This is
376 # Object variable to store code object waiting execution. This is
376 # used mainly by the multithreaded shells, but it can come in handy in
377 # used mainly by the multithreaded shells, but it can come in handy in
377 # other situations. No need to use a Queue here, since it's a single
378 # other situations. No need to use a Queue here, since it's a single
378 # item which gets cleared once run.
379 # item which gets cleared once run.
379 self.code_to_run = None
380 self.code_to_run = None
380
381
381 # escapes for automatic behavior on the command line
382 # escapes for automatic behavior on the command line
382 self.ESC_SHELL = '!'
383 self.ESC_SHELL = '!'
383 self.ESC_HELP = '?'
384 self.ESC_HELP = '?'
384 self.ESC_MAGIC = '%'
385 self.ESC_MAGIC = '%'
385 self.ESC_QUOTE = ','
386 self.ESC_QUOTE = ','
386 self.ESC_QUOTE2 = ';'
387 self.ESC_QUOTE2 = ';'
387 self.ESC_PAREN = '/'
388 self.ESC_PAREN = '/'
388
389
389 # And their associated handlers
390 # And their associated handlers
390 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
391 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
391 self.ESC_QUOTE : self.handle_auto,
392 self.ESC_QUOTE : self.handle_auto,
392 self.ESC_QUOTE2 : self.handle_auto,
393 self.ESC_QUOTE2 : self.handle_auto,
393 self.ESC_MAGIC : self.handle_magic,
394 self.ESC_MAGIC : self.handle_magic,
394 self.ESC_HELP : self.handle_help,
395 self.ESC_HELP : self.handle_help,
395 self.ESC_SHELL : self.handle_shell_escape,
396 self.ESC_SHELL : self.handle_shell_escape,
396 }
397 }
397
398
398 # class initializations
399 # class initializations
399 Magic.__init__(self,self)
400 Magic.__init__(self,self)
400
401
401 # Python source parser/formatter for syntax highlighting
402 # Python source parser/formatter for syntax highlighting
402 pyformat = PyColorize.Parser().format
403 pyformat = PyColorize.Parser().format
403 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
404 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
404
405
405 # hooks holds pointers used for user-side customizations
406 # hooks holds pointers used for user-side customizations
406 self.hooks = Struct()
407 self.hooks = Struct()
407
408
408 # Set all default hooks, defined in the IPython.hooks module.
409 # Set all default hooks, defined in the IPython.hooks module.
409 hooks = IPython.hooks
410 hooks = IPython.hooks
410 for hook_name in hooks.__all__:
411 for hook_name in hooks.__all__:
411 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
412 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
412 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
413 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
413
414
414 # Flag to mark unconditional exit
415 # Flag to mark unconditional exit
415 self.exit_now = False
416 self.exit_now = False
416
417
417 self.usage_min = """\
418 self.usage_min = """\
418 An enhanced console for Python.
419 An enhanced console for Python.
419 Some of its features are:
420 Some of its features are:
420 - Readline support if the readline library is present.
421 - Readline support if the readline library is present.
421 - Tab completion in the local namespace.
422 - Tab completion in the local namespace.
422 - Logging of input, see command-line options.
423 - Logging of input, see command-line options.
423 - System shell escape via ! , eg !ls.
424 - System shell escape via ! , eg !ls.
424 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
425 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
425 - Keeps track of locally defined variables via %who, %whos.
426 - Keeps track of locally defined variables via %who, %whos.
426 - Show object information with a ? eg ?x or x? (use ?? for more info).
427 - Show object information with a ? eg ?x or x? (use ?? for more info).
427 """
428 """
428 if usage: self.usage = usage
429 if usage: self.usage = usage
429 else: self.usage = self.usage_min
430 else: self.usage = self.usage_min
430
431
431 # Storage
432 # Storage
432 self.rc = rc # This will hold all configuration information
433 self.rc = rc # This will hold all configuration information
433 self.pager = 'less'
434 self.pager = 'less'
434 # temporary files used for various purposes. Deleted at exit.
435 # temporary files used for various purposes. Deleted at exit.
435 self.tempfiles = []
436 self.tempfiles = []
436
437
437 # Keep track of readline usage (later set by init_readline)
438 # Keep track of readline usage (later set by init_readline)
438 self.has_readline = False
439 self.has_readline = False
439
440
440 # template for logfile headers. It gets resolved at runtime by the
441 # template for logfile headers. It gets resolved at runtime by the
441 # logstart method.
442 # logstart method.
442 self.loghead_tpl = \
443 self.loghead_tpl = \
443 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
444 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
444 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
445 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
445 #log# opts = %s
446 #log# opts = %s
446 #log# args = %s
447 #log# args = %s
447 #log# It is safe to make manual edits below here.
448 #log# It is safe to make manual edits below here.
448 #log#-----------------------------------------------------------------------
449 #log#-----------------------------------------------------------------------
449 """
450 """
450 # for pushd/popd management
451 # for pushd/popd management
451 try:
452 try:
452 self.home_dir = get_home_dir()
453 self.home_dir = get_home_dir()
453 except HomeDirError,msg:
454 except HomeDirError,msg:
454 fatal(msg)
455 fatal(msg)
455
456
456 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
457 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
457
458
458 # Functions to call the underlying shell.
459 # Functions to call the underlying shell.
459
460
460 # utility to expand user variables via Itpl
461 # utility to expand user variables via Itpl
461 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
462 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
462 self.user_ns))
463 self.user_ns))
463 # The first is similar to os.system, but it doesn't return a value,
464 # The first is similar to os.system, but it doesn't return a value,
464 # and it allows interpolation of variables in the user's namespace.
465 # and it allows interpolation of variables in the user's namespace.
465 self.system = lambda cmd: shell(self.var_expand(cmd),
466 self.system = lambda cmd: shell(self.var_expand(cmd),
466 header='IPython system call: ',
467 header='IPython system call: ',
467 verbose=self.rc.system_verbose)
468 verbose=self.rc.system_verbose)
468 # These are for getoutput and getoutputerror:
469 # These are for getoutput and getoutputerror:
469 self.getoutput = lambda cmd: \
470 self.getoutput = lambda cmd: \
470 getoutput(self.var_expand(cmd),
471 getoutput(self.var_expand(cmd),
471 header='IPython system call: ',
472 header='IPython system call: ',
472 verbose=self.rc.system_verbose)
473 verbose=self.rc.system_verbose)
473 self.getoutputerror = lambda cmd: \
474 self.getoutputerror = lambda cmd: \
474 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
475 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
475 self.user_ns)),
476 self.user_ns)),
476 header='IPython system call: ',
477 header='IPython system call: ',
477 verbose=self.rc.system_verbose)
478 verbose=self.rc.system_verbose)
478
479
479 # RegExp for splitting line contents into pre-char//first
480 # RegExp for splitting line contents into pre-char//first
480 # word-method//rest. For clarity, each group in on one line.
481 # word-method//rest. For clarity, each group in on one line.
481
482
482 # WARNING: update the regexp if the above escapes are changed, as they
483 # WARNING: update the regexp if the above escapes are changed, as they
483 # are hardwired in.
484 # are hardwired in.
484
485
485 # Don't get carried away with trying to make the autocalling catch too
486 # Don't get carried away with trying to make the autocalling catch too
486 # much: it's better to be conservative rather than to trigger hidden
487 # much: it's better to be conservative rather than to trigger hidden
487 # evals() somewhere and end up causing side effects.
488 # evals() somewhere and end up causing side effects.
488
489
489 self.line_split = re.compile(r'^([\s*,;/])'
490 self.line_split = re.compile(r'^([\s*,;/])'
490 r'([\?\w\.]+\w*\s*)'
491 r'([\?\w\.]+\w*\s*)'
491 r'(\(?.*$)')
492 r'(\(?.*$)')
492
493
493 # Original re, keep around for a while in case changes break something
494 # Original re, keep around for a while in case changes break something
494 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
495 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
495 # r'(\s*[\?\w\.]+\w*\s*)'
496 # r'(\s*[\?\w\.]+\w*\s*)'
496 # r'(\(?.*$)')
497 # r'(\(?.*$)')
497
498
498 # RegExp to identify potential function names
499 # RegExp to identify potential function names
499 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
500 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
500
501
501 # RegExp to exclude strings with this start from autocalling. In
502 # RegExp to exclude strings with this start from autocalling. In
502 # particular, all binary operators should be excluded, so that if foo
503 # particular, all binary operators should be excluded, so that if foo
503 # is callable, foo OP bar doesn't become foo(OP bar), which is
504 # is callable, foo OP bar doesn't become foo(OP bar), which is
504 # invalid. The characters '!=()' don't need to be checked for, as the
505 # invalid. The characters '!=()' don't need to be checked for, as the
505 # _prefilter routine explicitely does so, to catch direct calls and
506 # _prefilter routine explicitely does so, to catch direct calls and
506 # rebindings of existing names.
507 # rebindings of existing names.
507
508
508 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
509 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
509 # it affects the rest of the group in square brackets.
510 # it affects the rest of the group in square brackets.
510 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
511 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
511 '|^is |^not |^in |^and |^or ')
512 '|^is |^not |^in |^and |^or ')
512
513
513 # try to catch also methods for stuff in lists/tuples/dicts: off
514 # try to catch also methods for stuff in lists/tuples/dicts: off
514 # (experimental). For this to work, the line_split regexp would need
515 # (experimental). For this to work, the line_split regexp would need
515 # to be modified so it wouldn't break things at '['. That line is
516 # to be modified so it wouldn't break things at '['. That line is
516 # nasty enough that I shouldn't change it until I can test it _well_.
517 # nasty enough that I shouldn't change it until I can test it _well_.
517 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
518 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
518
519
519 # keep track of where we started running (mainly for crash post-mortem)
520 # keep track of where we started running (mainly for crash post-mortem)
520 self.starting_dir = os.getcwd()
521 self.starting_dir = os.getcwd()
521
522
522 # Various switches which can be set
523 # Various switches which can be set
523 self.CACHELENGTH = 5000 # this is cheap, it's just text
524 self.CACHELENGTH = 5000 # this is cheap, it's just text
524 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
525 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
525 self.banner2 = banner2
526 self.banner2 = banner2
526
527
527 # TraceBack handlers:
528 # TraceBack handlers:
528
529
529 # Syntax error handler.
530 # Syntax error handler.
530 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
531 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
531
532
532 # The interactive one is initialized with an offset, meaning we always
533 # The interactive one is initialized with an offset, meaning we always
533 # want to remove the topmost item in the traceback, which is our own
534 # want to remove the topmost item in the traceback, which is our own
534 # internal code. Valid modes: ['Plain','Context','Verbose']
535 # internal code. Valid modes: ['Plain','Context','Verbose']
535 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
536 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
536 color_scheme='NoColor',
537 color_scheme='NoColor',
537 tb_offset = 1)
538 tb_offset = 1)
538
539
539 # IPython itself shouldn't crash. This will produce a detailed
540 # IPython itself shouldn't crash. This will produce a detailed
540 # post-mortem if it does. But we only install the crash handler for
541 # post-mortem if it does. But we only install the crash handler for
541 # non-threaded shells, the threaded ones use a normal verbose reporter
542 # non-threaded shells, the threaded ones use a normal verbose reporter
542 # and lose the crash handler. This is because exceptions in the main
543 # and lose the crash handler. This is because exceptions in the main
543 # thread (such as in GUI code) propagate directly to sys.excepthook,
544 # thread (such as in GUI code) propagate directly to sys.excepthook,
544 # and there's no point in printing crash dumps for every user exception.
545 # and there's no point in printing crash dumps for every user exception.
545 if self.isthreaded:
546 if self.isthreaded:
546 sys.excepthook = ultraTB.FormattedTB()
547 sys.excepthook = ultraTB.FormattedTB()
547 else:
548 else:
548 from IPython import CrashHandler
549 from IPython import CrashHandler
549 sys.excepthook = CrashHandler.CrashHandler(self)
550 sys.excepthook = CrashHandler.CrashHandler(self)
550
551
551 # The instance will store a pointer to this, so that runtime code
552 # The instance will store a pointer to this, so that runtime code
552 # (such as magics) can access it. This is because during the
553 # (such as magics) can access it. This is because during the
553 # read-eval loop, it gets temporarily overwritten (to deal with GUI
554 # read-eval loop, it gets temporarily overwritten (to deal with GUI
554 # frameworks).
555 # frameworks).
555 self.sys_excepthook = sys.excepthook
556 self.sys_excepthook = sys.excepthook
556
557
557 # and add any custom exception handlers the user may have specified
558 # and add any custom exception handlers the user may have specified
558 self.set_custom_exc(*custom_exceptions)
559 self.set_custom_exc(*custom_exceptions)
559
560
560 # Object inspector
561 # Object inspector
561 self.inspector = OInspect.Inspector(OInspect.InspectColors,
562 self.inspector = OInspect.Inspector(OInspect.InspectColors,
562 PyColorize.ANSICodeColors,
563 PyColorize.ANSICodeColors,
563 'NoColor')
564 'NoColor')
564 # indentation management
565 # indentation management
565 self.autoindent = False
566 self.autoindent = False
566 self.indent_current_nsp = 0
567 self.indent_current_nsp = 0
567
568
568 # Make some aliases automatically
569 # Make some aliases automatically
569 # Prepare list of shell aliases to auto-define
570 # Prepare list of shell aliases to auto-define
570 if os.name == 'posix':
571 if os.name == 'posix':
571 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
572 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
572 'mv mv -i','rm rm -i','cp cp -i',
573 'mv mv -i','rm rm -i','cp cp -i',
573 'cat cat','less less','clear clear',
574 'cat cat','less less','clear clear',
574 # a better ls
575 # a better ls
575 'ls ls -F',
576 'ls ls -F',
576 # long ls
577 # long ls
577 'll ls -lF',
578 'll ls -lF',
578 # color ls
579 # color ls
579 'lc ls -F -o --color',
580 'lc ls -F -o --color',
580 # ls normal files only
581 # ls normal files only
581 'lf ls -F -o --color %l | grep ^-',
582 'lf ls -F -o --color %l | grep ^-',
582 # ls symbolic links
583 # ls symbolic links
583 'lk ls -F -o --color %l | grep ^l',
584 'lk ls -F -o --color %l | grep ^l',
584 # directories or links to directories,
585 # directories or links to directories,
585 'ldir ls -F -o --color %l | grep /$',
586 'ldir ls -F -o --color %l | grep /$',
586 # things which are executable
587 # things which are executable
587 'lx ls -F -o --color %l | grep ^-..x',
588 'lx ls -F -o --color %l | grep ^-..x',
588 )
589 )
589 elif os.name in ['nt','dos']:
590 elif os.name in ['nt','dos']:
590 auto_alias = ('dir dir /on', 'ls dir /on',
591 auto_alias = ('dir dir /on', 'ls dir /on',
591 'ddir dir /ad /on', 'ldir dir /ad /on',
592 'ddir dir /ad /on', 'ldir dir /ad /on',
592 'mkdir mkdir','rmdir rmdir','echo echo',
593 'mkdir mkdir','rmdir rmdir','echo echo',
593 'ren ren','cls cls','copy copy')
594 'ren ren','cls cls','copy copy')
594 else:
595 else:
595 auto_alias = ()
596 auto_alias = ()
596 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
597 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
597 # Call the actual (public) initializer
598 # Call the actual (public) initializer
598 self.init_auto_alias()
599 self.init_auto_alias()
599 # end __init__
600 # end __init__
600
601
601 def post_config_initialization(self):
602 def post_config_initialization(self):
602 """Post configuration init method
603 """Post configuration init method
603
604
604 This is called after the configuration files have been processed to
605 This is called after the configuration files have been processed to
605 'finalize' the initialization."""
606 'finalize' the initialization."""
606
607
607 rc = self.rc
608 rc = self.rc
608
609
609 # Load readline proper
610 # Load readline proper
610 if rc.readline:
611 if rc.readline:
611 self.init_readline()
612 self.init_readline()
612
613
613 # local shortcut, this is used a LOT
614 # local shortcut, this is used a LOT
614 self.log = self.logger.log
615 self.log = self.logger.log
615
616
616 # Initialize cache, set in/out prompts and printing system
617 # Initialize cache, set in/out prompts and printing system
617 self.outputcache = CachedOutput(self,
618 self.outputcache = CachedOutput(self,
618 rc.cache_size,
619 rc.cache_size,
619 rc.pprint,
620 rc.pprint,
620 input_sep = rc.separate_in,
621 input_sep = rc.separate_in,
621 output_sep = rc.separate_out,
622 output_sep = rc.separate_out,
622 output_sep2 = rc.separate_out2,
623 output_sep2 = rc.separate_out2,
623 ps1 = rc.prompt_in1,
624 ps1 = rc.prompt_in1,
624 ps2 = rc.prompt_in2,
625 ps2 = rc.prompt_in2,
625 ps_out = rc.prompt_out,
626 ps_out = rc.prompt_out,
626 pad_left = rc.prompts_pad_left)
627 pad_left = rc.prompts_pad_left)
627
628
628 # user may have over-ridden the default print hook:
629 # user may have over-ridden the default print hook:
629 try:
630 try:
630 self.outputcache.__class__.display = self.hooks.display
631 self.outputcache.__class__.display = self.hooks.display
631 except AttributeError:
632 except AttributeError:
632 pass
633 pass
633
634
634 # I don't like assigning globally to sys, because it means when embedding
635 # I don't like assigning globally to sys, because it means when embedding
635 # instances, each embedded instance overrides the previous choice. But
636 # instances, each embedded instance overrides the previous choice. But
636 # sys.displayhook seems to be called internally by exec, so I don't see a
637 # sys.displayhook seems to be called internally by exec, so I don't see a
637 # way around it.
638 # way around it.
638 sys.displayhook = self.outputcache
639 sys.displayhook = self.outputcache
639
640
640 # Set user colors (don't do it in the constructor above so that it
641 # Set user colors (don't do it in the constructor above so that it
641 # doesn't crash if colors option is invalid)
642 # doesn't crash if colors option is invalid)
642 self.magic_colors(rc.colors)
643 self.magic_colors(rc.colors)
643
644
644 # Set calling of pdb on exceptions
645 # Set calling of pdb on exceptions
645 self.call_pdb = rc.pdb
646 self.call_pdb = rc.pdb
646
647
647 # Load user aliases
648 # Load user aliases
648 for alias in rc.alias:
649 for alias in rc.alias:
649 self.magic_alias(alias)
650 self.magic_alias(alias)
650
651
651 # dynamic data that survives through sessions
652 # dynamic data that survives through sessions
652 # XXX make the filename a config option?
653 # XXX make the filename a config option?
653 persist_base = 'persist'
654 persist_base = 'persist'
654 if rc.profile:
655 if rc.profile:
655 persist_base += '_%s' % rc.profile
656 persist_base += '_%s' % rc.profile
656 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
657 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
657
658
658 try:
659 try:
659 self.persist = pickle.load(file(self.persist_fname))
660 self.persist = pickle.load(file(self.persist_fname))
660 except:
661 except:
661 self.persist = {}
662 self.persist = {}
662
663
663
664
664 for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]:
665 for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]:
665 try:
666 try:
666 obj = pickle.loads(value)
667 obj = pickle.loads(value)
667 except:
668 except:
668
669
669 print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key
670 print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key
670 print "The error was:",sys.exc_info()[0]
671 print "The error was:",sys.exc_info()[0]
671 continue
672 continue
672
673
673
674
674 self.user_ns[key] = obj
675 self.user_ns[key] = obj
675
676
676 def add_builtins(self):
677 def add_builtins(self):
677 """Store ipython references into the builtin namespace.
678 """Store ipython references into the builtin namespace.
678
679
679 Some parts of ipython operate via builtins injected here, which hold a
680 Some parts of ipython operate via builtins injected here, which hold a
680 reference to IPython itself."""
681 reference to IPython itself."""
681
682
682 builtins_new = dict(__IPYTHON__ = self,
683 builtins_new = dict(__IPYTHON__ = self,
683 ip_set_hook = self.set_hook,
684 ip_set_hook = self.set_hook,
684 jobs = self.jobs,
685 jobs = self.jobs,
685 ipmagic = self.ipmagic,
686 ipmagic = self.ipmagic,
686 ipalias = self.ipalias,
687 ipalias = self.ipalias,
687 ipsystem = self.ipsystem,
688 ipsystem = self.ipsystem,
688 )
689 )
689 for biname,bival in builtins_new.items():
690 for biname,bival in builtins_new.items():
690 try:
691 try:
691 # store the orignal value so we can restore it
692 # store the orignal value so we can restore it
692 self.builtins_added[biname] = __builtin__.__dict__[biname]
693 self.builtins_added[biname] = __builtin__.__dict__[biname]
693 except KeyError:
694 except KeyError:
694 # or mark that it wasn't defined, and we'll just delete it at
695 # or mark that it wasn't defined, and we'll just delete it at
695 # cleanup
696 # cleanup
696 self.builtins_added[biname] = Undefined
697 self.builtins_added[biname] = Undefined
697 __builtin__.__dict__[biname] = bival
698 __builtin__.__dict__[biname] = bival
698
699
699 # Keep in the builtins a flag for when IPython is active. We set it
700 # Keep in the builtins a flag for when IPython is active. We set it
700 # with setdefault so that multiple nested IPythons don't clobber one
701 # with setdefault so that multiple nested IPythons don't clobber one
701 # another. Each will increase its value by one upon being activated,
702 # another. Each will increase its value by one upon being activated,
702 # which also gives us a way to determine the nesting level.
703 # which also gives us a way to determine the nesting level.
703 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
704 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
704
705
705 def clean_builtins(self):
706 def clean_builtins(self):
706 """Remove any builtins which might have been added by add_builtins, or
707 """Remove any builtins which might have been added by add_builtins, or
707 restore overwritten ones to their previous values."""
708 restore overwritten ones to their previous values."""
708 for biname,bival in self.builtins_added.items():
709 for biname,bival in self.builtins_added.items():
709 if bival is Undefined:
710 if bival is Undefined:
710 del __builtin__.__dict__[biname]
711 del __builtin__.__dict__[biname]
711 else:
712 else:
712 __builtin__.__dict__[biname] = bival
713 __builtin__.__dict__[biname] = bival
713 self.builtins_added.clear()
714 self.builtins_added.clear()
714
715
715 def set_hook(self,name,hook, priority = 50):
716 def set_hook(self,name,hook, priority = 50):
716 """set_hook(name,hook) -> sets an internal IPython hook.
717 """set_hook(name,hook) -> sets an internal IPython hook.
717
718
718 IPython exposes some of its internal API as user-modifiable hooks. By
719 IPython exposes some of its internal API as user-modifiable hooks. By
719 adding your function to one of these hooks, you can modify IPython's
720 adding your function to one of these hooks, you can modify IPython's
720 behavior to call at runtime your own routines."""
721 behavior to call at runtime your own routines."""
721
722
722 # At some point in the future, this should validate the hook before it
723 # At some point in the future, this should validate the hook before it
723 # accepts it. Probably at least check that the hook takes the number
724 # accepts it. Probably at least check that the hook takes the number
724 # of args it's supposed to.
725 # of args it's supposed to.
725 dp = getattr(self.hooks, name, None)
726 dp = getattr(self.hooks, name, None)
726 if not dp:
727 if not dp:
727 dp = IPython.hooks.CommandChainDispatcher()
728 dp = IPython.hooks.CommandChainDispatcher()
728
729
729 f = new.instancemethod(hook,self,self.__class__)
730 f = new.instancemethod(hook,self,self.__class__)
730 try:
731 try:
731 dp.add(f,priority)
732 dp.add(f,priority)
732 except AttributeError:
733 except AttributeError:
733 # it was not commandchain, plain old func - replace
734 # it was not commandchain, plain old func - replace
734 dp = f
735 dp = f
735
736
736 setattr(self.hooks,name, dp)
737 setattr(self.hooks,name, dp)
737
738
738
739
739 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
740 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
740
741
741 def set_custom_exc(self,exc_tuple,handler):
742 def set_custom_exc(self,exc_tuple,handler):
742 """set_custom_exc(exc_tuple,handler)
743 """set_custom_exc(exc_tuple,handler)
743
744
744 Set a custom exception handler, which will be called if any of the
745 Set a custom exception handler, which will be called if any of the
745 exceptions in exc_tuple occur in the mainloop (specifically, in the
746 exceptions in exc_tuple occur in the mainloop (specifically, in the
746 runcode() method.
747 runcode() method.
747
748
748 Inputs:
749 Inputs:
749
750
750 - exc_tuple: a *tuple* of valid exceptions to call the defined
751 - exc_tuple: a *tuple* of valid exceptions to call the defined
751 handler for. It is very important that you use a tuple, and NOT A
752 handler for. It is very important that you use a tuple, and NOT A
752 LIST here, because of the way Python's except statement works. If
753 LIST here, because of the way Python's except statement works. If
753 you only want to trap a single exception, use a singleton tuple:
754 you only want to trap a single exception, use a singleton tuple:
754
755
755 exc_tuple == (MyCustomException,)
756 exc_tuple == (MyCustomException,)
756
757
757 - handler: this must be defined as a function with the following
758 - handler: this must be defined as a function with the following
758 basic interface: def my_handler(self,etype,value,tb).
759 basic interface: def my_handler(self,etype,value,tb).
759
760
760 This will be made into an instance method (via new.instancemethod)
761 This will be made into an instance method (via new.instancemethod)
761 of IPython itself, and it will be called if any of the exceptions
762 of IPython itself, and it will be called if any of the exceptions
762 listed in the exc_tuple are caught. If the handler is None, an
763 listed in the exc_tuple are caught. If the handler is None, an
763 internal basic one is used, which just prints basic info.
764 internal basic one is used, which just prints basic info.
764
765
765 WARNING: by putting in your own exception handler into IPython's main
766 WARNING: by putting in your own exception handler into IPython's main
766 execution loop, you run a very good chance of nasty crashes. This
767 execution loop, you run a very good chance of nasty crashes. This
767 facility should only be used if you really know what you are doing."""
768 facility should only be used if you really know what you are doing."""
768
769
769 assert type(exc_tuple)==type(()) , \
770 assert type(exc_tuple)==type(()) , \
770 "The custom exceptions must be given AS A TUPLE."
771 "The custom exceptions must be given AS A TUPLE."
771
772
772 def dummy_handler(self,etype,value,tb):
773 def dummy_handler(self,etype,value,tb):
773 print '*** Simple custom exception handler ***'
774 print '*** Simple custom exception handler ***'
774 print 'Exception type :',etype
775 print 'Exception type :',etype
775 print 'Exception value:',value
776 print 'Exception value:',value
776 print 'Traceback :',tb
777 print 'Traceback :',tb
777 print 'Source code :','\n'.join(self.buffer)
778 print 'Source code :','\n'.join(self.buffer)
778
779
779 if handler is None: handler = dummy_handler
780 if handler is None: handler = dummy_handler
780
781
781 self.CustomTB = new.instancemethod(handler,self,self.__class__)
782 self.CustomTB = new.instancemethod(handler,self,self.__class__)
782 self.custom_exceptions = exc_tuple
783 self.custom_exceptions = exc_tuple
783
784
784 def set_custom_completer(self,completer,pos=0):
785 def set_custom_completer(self,completer,pos=0):
785 """set_custom_completer(completer,pos=0)
786 """set_custom_completer(completer,pos=0)
786
787
787 Adds a new custom completer function.
788 Adds a new custom completer function.
788
789
789 The position argument (defaults to 0) is the index in the completers
790 The position argument (defaults to 0) is the index in the completers
790 list where you want the completer to be inserted."""
791 list where you want the completer to be inserted."""
791
792
792 newcomp = new.instancemethod(completer,self.Completer,
793 newcomp = new.instancemethod(completer,self.Completer,
793 self.Completer.__class__)
794 self.Completer.__class__)
794 self.Completer.matchers.insert(pos,newcomp)
795 self.Completer.matchers.insert(pos,newcomp)
795
796
796 def _get_call_pdb(self):
797 def _get_call_pdb(self):
797 return self._call_pdb
798 return self._call_pdb
798
799
799 def _set_call_pdb(self,val):
800 def _set_call_pdb(self,val):
800
801
801 if val not in (0,1,False,True):
802 if val not in (0,1,False,True):
802 raise ValueError,'new call_pdb value must be boolean'
803 raise ValueError,'new call_pdb value must be boolean'
803
804
804 # store value in instance
805 # store value in instance
805 self._call_pdb = val
806 self._call_pdb = val
806
807
807 # notify the actual exception handlers
808 # notify the actual exception handlers
808 self.InteractiveTB.call_pdb = val
809 self.InteractiveTB.call_pdb = val
809 if self.isthreaded:
810 if self.isthreaded:
810 try:
811 try:
811 self.sys_excepthook.call_pdb = val
812 self.sys_excepthook.call_pdb = val
812 except:
813 except:
813 warn('Failed to activate pdb for threaded exception handler')
814 warn('Failed to activate pdb for threaded exception handler')
814
815
815 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
816 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
816 'Control auto-activation of pdb at exceptions')
817 'Control auto-activation of pdb at exceptions')
817
818
818
819
819 # These special functions get installed in the builtin namespace, to
820 # These special functions get installed in the builtin namespace, to
820 # provide programmatic (pure python) access to magics, aliases and system
821 # provide programmatic (pure python) access to magics, aliases and system
821 # calls. This is important for logging, user scripting, and more.
822 # calls. This is important for logging, user scripting, and more.
822
823
823 # We are basically exposing, via normal python functions, the three
824 # We are basically exposing, via normal python functions, the three
824 # mechanisms in which ipython offers special call modes (magics for
825 # mechanisms in which ipython offers special call modes (magics for
825 # internal control, aliases for direct system access via pre-selected
826 # internal control, aliases for direct system access via pre-selected
826 # names, and !cmd for calling arbitrary system commands).
827 # names, and !cmd for calling arbitrary system commands).
827
828
828 def ipmagic(self,arg_s):
829 def ipmagic(self,arg_s):
829 """Call a magic function by name.
830 """Call a magic function by name.
830
831
831 Input: a string containing the name of the magic function to call and any
832 Input: a string containing the name of the magic function to call and any
832 additional arguments to be passed to the magic.
833 additional arguments to be passed to the magic.
833
834
834 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
835 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
835 prompt:
836 prompt:
836
837
837 In[1]: %name -opt foo bar
838 In[1]: %name -opt foo bar
838
839
839 To call a magic without arguments, simply use ipmagic('name').
840 To call a magic without arguments, simply use ipmagic('name').
840
841
841 This provides a proper Python function to call IPython's magics in any
842 This provides a proper Python function to call IPython's magics in any
842 valid Python code you can type at the interpreter, including loops and
843 valid Python code you can type at the interpreter, including loops and
843 compound statements. It is added by IPython to the Python builtin
844 compound statements. It is added by IPython to the Python builtin
844 namespace upon initialization."""
845 namespace upon initialization."""
845
846
846 args = arg_s.split(' ',1)
847 args = arg_s.split(' ',1)
847 magic_name = args[0]
848 magic_name = args[0]
848 magic_name = magic_name.lstrip(self.ESC_MAGIC)
849 magic_name = magic_name.lstrip(self.ESC_MAGIC)
849
850
850 try:
851 try:
851 magic_args = args[1]
852 magic_args = args[1]
852 except IndexError:
853 except IndexError:
853 magic_args = ''
854 magic_args = ''
854 fn = getattr(self,'magic_'+magic_name,None)
855 fn = getattr(self,'magic_'+magic_name,None)
855 if fn is None:
856 if fn is None:
856 error("Magic function `%s` not found." % magic_name)
857 error("Magic function `%s` not found." % magic_name)
857 else:
858 else:
858 magic_args = self.var_expand(magic_args)
859 magic_args = self.var_expand(magic_args)
859 return fn(magic_args)
860 return fn(magic_args)
860
861
861 def ipalias(self,arg_s):
862 def ipalias(self,arg_s):
862 """Call an alias by name.
863 """Call an alias by name.
863
864
864 Input: a string containing the name of the alias to call and any
865 Input: a string containing the name of the alias to call and any
865 additional arguments to be passed to the magic.
866 additional arguments to be passed to the magic.
866
867
867 ipalias('name -opt foo bar') is equivalent to typing at the ipython
868 ipalias('name -opt foo bar') is equivalent to typing at the ipython
868 prompt:
869 prompt:
869
870
870 In[1]: name -opt foo bar
871 In[1]: name -opt foo bar
871
872
872 To call an alias without arguments, simply use ipalias('name').
873 To call an alias without arguments, simply use ipalias('name').
873
874
874 This provides a proper Python function to call IPython's aliases in any
875 This provides a proper Python function to call IPython's aliases in any
875 valid Python code you can type at the interpreter, including loops and
876 valid Python code you can type at the interpreter, including loops and
876 compound statements. It is added by IPython to the Python builtin
877 compound statements. It is added by IPython to the Python builtin
877 namespace upon initialization."""
878 namespace upon initialization."""
878
879
879 args = arg_s.split(' ',1)
880 args = arg_s.split(' ',1)
880 alias_name = args[0]
881 alias_name = args[0]
881 try:
882 try:
882 alias_args = args[1]
883 alias_args = args[1]
883 except IndexError:
884 except IndexError:
884 alias_args = ''
885 alias_args = ''
885 if alias_name in self.alias_table:
886 if alias_name in self.alias_table:
886 self.call_alias(alias_name,alias_args)
887 self.call_alias(alias_name,alias_args)
887 else:
888 else:
888 error("Alias `%s` not found." % alias_name)
889 error("Alias `%s` not found." % alias_name)
889
890
890 def ipsystem(self,arg_s):
891 def ipsystem(self,arg_s):
891 """Make a system call, using IPython."""
892 """Make a system call, using IPython."""
892
893
893 self.system(arg_s)
894 self.system(arg_s)
894
895
895 def complete(self,text):
896 def complete(self,text):
896 """Return a sorted list of all possible completions on text.
897 """Return a sorted list of all possible completions on text.
897
898
898 Inputs:
899 Inputs:
899
900
900 - text: a string of text to be completed on.
901 - text: a string of text to be completed on.
901
902
902 This is a wrapper around the completion mechanism, similar to what
903 This is a wrapper around the completion mechanism, similar to what
903 readline does at the command line when the TAB key is hit. By
904 readline does at the command line when the TAB key is hit. By
904 exposing it as a method, it can be used by other non-readline
905 exposing it as a method, it can be used by other non-readline
905 environments (such as GUIs) for text completion.
906 environments (such as GUIs) for text completion.
906
907
907 Simple usage example:
908 Simple usage example:
908
909
909 In [1]: x = 'hello'
910 In [1]: x = 'hello'
910
911
911 In [2]: __IP.complete('x.l')
912 In [2]: __IP.complete('x.l')
912 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
913 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
913
914
914 complete = self.Completer.complete
915 complete = self.Completer.complete
915 state = 0
916 state = 0
916 # use a dict so we get unique keys, since ipyhton's multiple
917 # use a dict so we get unique keys, since ipyhton's multiple
917 # completers can return duplicates.
918 # completers can return duplicates.
918 comps = {}
919 comps = {}
919 while True:
920 while True:
920 newcomp = complete(text,state)
921 newcomp = complete(text,state)
921 if newcomp is None:
922 if newcomp is None:
922 break
923 break
923 comps[newcomp] = 1
924 comps[newcomp] = 1
924 state += 1
925 state += 1
925 outcomps = comps.keys()
926 outcomps = comps.keys()
926 outcomps.sort()
927 outcomps.sort()
927 return outcomps
928 return outcomps
928
929
929 def set_completer_frame(self, frame=None):
930 def set_completer_frame(self, frame=None):
930 if frame:
931 if frame:
931 self.Completer.namespace = frame.f_locals
932 self.Completer.namespace = frame.f_locals
932 self.Completer.global_namespace = frame.f_globals
933 self.Completer.global_namespace = frame.f_globals
933 else:
934 else:
934 self.Completer.namespace = self.user_ns
935 self.Completer.namespace = self.user_ns
935 self.Completer.global_namespace = self.user_global_ns
936 self.Completer.global_namespace = self.user_global_ns
936
937
937 def init_auto_alias(self):
938 def init_auto_alias(self):
938 """Define some aliases automatically.
939 """Define some aliases automatically.
939
940
940 These are ALL parameter-less aliases"""
941 These are ALL parameter-less aliases"""
941
942
942 for alias,cmd in self.auto_alias:
943 for alias,cmd in self.auto_alias:
943 self.alias_table[alias] = (0,cmd)
944 self.alias_table[alias] = (0,cmd)
944
945
945 def alias_table_validate(self,verbose=0):
946 def alias_table_validate(self,verbose=0):
946 """Update information about the alias table.
947 """Update information about the alias table.
947
948
948 In particular, make sure no Python keywords/builtins are in it."""
949 In particular, make sure no Python keywords/builtins are in it."""
949
950
950 no_alias = self.no_alias
951 no_alias = self.no_alias
951 for k in self.alias_table.keys():
952 for k in self.alias_table.keys():
952 if k in no_alias:
953 if k in no_alias:
953 del self.alias_table[k]
954 del self.alias_table[k]
954 if verbose:
955 if verbose:
955 print ("Deleting alias <%s>, it's a Python "
956 print ("Deleting alias <%s>, it's a Python "
956 "keyword or builtin." % k)
957 "keyword or builtin." % k)
957
958
958 def set_autoindent(self,value=None):
959 def set_autoindent(self,value=None):
959 """Set the autoindent flag, checking for readline support.
960 """Set the autoindent flag, checking for readline support.
960
961
961 If called with no arguments, it acts as a toggle."""
962 If called with no arguments, it acts as a toggle."""
962
963
963 if not self.has_readline:
964 if not self.has_readline:
964 if os.name == 'posix':
965 if os.name == 'posix':
965 warn("The auto-indent feature requires the readline library")
966 warn("The auto-indent feature requires the readline library")
966 self.autoindent = 0
967 self.autoindent = 0
967 return
968 return
968 if value is None:
969 if value is None:
969 self.autoindent = not self.autoindent
970 self.autoindent = not self.autoindent
970 else:
971 else:
971 self.autoindent = value
972 self.autoindent = value
972
973
973 def rc_set_toggle(self,rc_field,value=None):
974 def rc_set_toggle(self,rc_field,value=None):
974 """Set or toggle a field in IPython's rc config. structure.
975 """Set or toggle a field in IPython's rc config. structure.
975
976
976 If called with no arguments, it acts as a toggle.
977 If called with no arguments, it acts as a toggle.
977
978
978 If called with a non-existent field, the resulting AttributeError
979 If called with a non-existent field, the resulting AttributeError
979 exception will propagate out."""
980 exception will propagate out."""
980
981
981 rc_val = getattr(self.rc,rc_field)
982 rc_val = getattr(self.rc,rc_field)
982 if value is None:
983 if value is None:
983 value = not rc_val
984 value = not rc_val
984 setattr(self.rc,rc_field,value)
985 setattr(self.rc,rc_field,value)
985
986
986 def user_setup(self,ipythondir,rc_suffix,mode='install'):
987 def user_setup(self,ipythondir,rc_suffix,mode='install'):
987 """Install the user configuration directory.
988 """Install the user configuration directory.
988
989
989 Can be called when running for the first time or to upgrade the user's
990 Can be called when running for the first time or to upgrade the user's
990 .ipython/ directory with the mode parameter. Valid modes are 'install'
991 .ipython/ directory with the mode parameter. Valid modes are 'install'
991 and 'upgrade'."""
992 and 'upgrade'."""
992
993
993 def wait():
994 def wait():
994 try:
995 try:
995 raw_input("Please press <RETURN> to start IPython.")
996 raw_input("Please press <RETURN> to start IPython.")
996 except EOFError:
997 except EOFError:
997 print >> Term.cout
998 print >> Term.cout
998 print '*'*70
999 print '*'*70
999
1000
1000 cwd = os.getcwd() # remember where we started
1001 cwd = os.getcwd() # remember where we started
1001 glb = glob.glob
1002 glb = glob.glob
1002 print '*'*70
1003 print '*'*70
1003 if mode == 'install':
1004 if mode == 'install':
1004 print \
1005 print \
1005 """Welcome to IPython. I will try to create a personal configuration directory
1006 """Welcome to IPython. I will try to create a personal configuration directory
1006 where you can customize many aspects of IPython's functionality in:\n"""
1007 where you can customize many aspects of IPython's functionality in:\n"""
1007 else:
1008 else:
1008 print 'I am going to upgrade your configuration in:'
1009 print 'I am going to upgrade your configuration in:'
1009
1010
1010 print ipythondir
1011 print ipythondir
1011
1012
1012 rcdirend = os.path.join('IPython','UserConfig')
1013 rcdirend = os.path.join('IPython','UserConfig')
1013 cfg = lambda d: os.path.join(d,rcdirend)
1014 cfg = lambda d: os.path.join(d,rcdirend)
1014 try:
1015 try:
1015 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1016 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1016 except IOError:
1017 except IOError:
1017 warning = """
1018 warning = """
1018 Installation error. IPython's directory was not found.
1019 Installation error. IPython's directory was not found.
1019
1020
1020 Check the following:
1021 Check the following:
1021
1022
1022 The ipython/IPython directory should be in a directory belonging to your
1023 The ipython/IPython directory should be in a directory belonging to your
1023 PYTHONPATH environment variable (that is, it should be in a directory
1024 PYTHONPATH environment variable (that is, it should be in a directory
1024 belonging to sys.path). You can copy it explicitly there or just link to it.
1025 belonging to sys.path). You can copy it explicitly there or just link to it.
1025
1026
1026 IPython will proceed with builtin defaults.
1027 IPython will proceed with builtin defaults.
1027 """
1028 """
1028 warn(warning)
1029 warn(warning)
1029 wait()
1030 wait()
1030 return
1031 return
1031
1032
1032 if mode == 'install':
1033 if mode == 'install':
1033 try:
1034 try:
1034 shutil.copytree(rcdir,ipythondir)
1035 shutil.copytree(rcdir,ipythondir)
1035 os.chdir(ipythondir)
1036 os.chdir(ipythondir)
1036 rc_files = glb("ipythonrc*")
1037 rc_files = glb("ipythonrc*")
1037 for rc_file in rc_files:
1038 for rc_file in rc_files:
1038 os.rename(rc_file,rc_file+rc_suffix)
1039 os.rename(rc_file,rc_file+rc_suffix)
1039 except:
1040 except:
1040 warning = """
1041 warning = """
1041
1042
1042 There was a problem with the installation:
1043 There was a problem with the installation:
1043 %s
1044 %s
1044 Try to correct it or contact the developers if you think it's a bug.
1045 Try to correct it or contact the developers if you think it's a bug.
1045 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1046 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1046 warn(warning)
1047 warn(warning)
1047 wait()
1048 wait()
1048 return
1049 return
1049
1050
1050 elif mode == 'upgrade':
1051 elif mode == 'upgrade':
1051 try:
1052 try:
1052 os.chdir(ipythondir)
1053 os.chdir(ipythondir)
1053 except:
1054 except:
1054 print """
1055 print """
1055 Can not upgrade: changing to directory %s failed. Details:
1056 Can not upgrade: changing to directory %s failed. Details:
1056 %s
1057 %s
1057 """ % (ipythondir,sys.exc_info()[1])
1058 """ % (ipythondir,sys.exc_info()[1])
1058 wait()
1059 wait()
1059 return
1060 return
1060 else:
1061 else:
1061 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1062 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1062 for new_full_path in sources:
1063 for new_full_path in sources:
1063 new_filename = os.path.basename(new_full_path)
1064 new_filename = os.path.basename(new_full_path)
1064 if new_filename.startswith('ipythonrc'):
1065 if new_filename.startswith('ipythonrc'):
1065 new_filename = new_filename + rc_suffix
1066 new_filename = new_filename + rc_suffix
1066 # The config directory should only contain files, skip any
1067 # The config directory should only contain files, skip any
1067 # directories which may be there (like CVS)
1068 # directories which may be there (like CVS)
1068 if os.path.isdir(new_full_path):
1069 if os.path.isdir(new_full_path):
1069 continue
1070 continue
1070 if os.path.exists(new_filename):
1071 if os.path.exists(new_filename):
1071 old_file = new_filename+'.old'
1072 old_file = new_filename+'.old'
1072 if os.path.exists(old_file):
1073 if os.path.exists(old_file):
1073 os.remove(old_file)
1074 os.remove(old_file)
1074 os.rename(new_filename,old_file)
1075 os.rename(new_filename,old_file)
1075 shutil.copy(new_full_path,new_filename)
1076 shutil.copy(new_full_path,new_filename)
1076 else:
1077 else:
1077 raise ValueError,'unrecognized mode for install:',`mode`
1078 raise ValueError,'unrecognized mode for install:',`mode`
1078
1079
1079 # Fix line-endings to those native to each platform in the config
1080 # Fix line-endings to those native to each platform in the config
1080 # directory.
1081 # directory.
1081 try:
1082 try:
1082 os.chdir(ipythondir)
1083 os.chdir(ipythondir)
1083 except:
1084 except:
1084 print """
1085 print """
1085 Problem: changing to directory %s failed.
1086 Problem: changing to directory %s failed.
1086 Details:
1087 Details:
1087 %s
1088 %s
1088
1089
1089 Some configuration files may have incorrect line endings. This should not
1090 Some configuration files may have incorrect line endings. This should not
1090 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1091 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1091 wait()
1092 wait()
1092 else:
1093 else:
1093 for fname in glb('ipythonrc*'):
1094 for fname in glb('ipythonrc*'):
1094 try:
1095 try:
1095 native_line_ends(fname,backup=0)
1096 native_line_ends(fname,backup=0)
1096 except IOError:
1097 except IOError:
1097 pass
1098 pass
1098
1099
1099 if mode == 'install':
1100 if mode == 'install':
1100 print """
1101 print """
1101 Successful installation!
1102 Successful installation!
1102
1103
1103 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1104 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1104 IPython manual (there are both HTML and PDF versions supplied with the
1105 IPython manual (there are both HTML and PDF versions supplied with the
1105 distribution) to make sure that your system environment is properly configured
1106 distribution) to make sure that your system environment is properly configured
1106 to take advantage of IPython's features.
1107 to take advantage of IPython's features.
1107
1108
1108 Important note: the configuration system has changed! The old system is
1109 Important note: the configuration system has changed! The old system is
1109 still in place, but its setting may be partly overridden by the settings in
1110 still in place, but its setting may be partly overridden by the settings in
1110 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1111 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1111 if some of the new settings bother you.
1112 if some of the new settings bother you.
1112
1113
1113 """
1114 """
1114 else:
1115 else:
1115 print """
1116 print """
1116 Successful upgrade!
1117 Successful upgrade!
1117
1118
1118 All files in your directory:
1119 All files in your directory:
1119 %(ipythondir)s
1120 %(ipythondir)s
1120 which would have been overwritten by the upgrade were backed up with a .old
1121 which would have been overwritten by the upgrade were backed up with a .old
1121 extension. If you had made particular customizations in those files you may
1122 extension. If you had made particular customizations in those files you may
1122 want to merge them back into the new files.""" % locals()
1123 want to merge them back into the new files.""" % locals()
1123 wait()
1124 wait()
1124 os.chdir(cwd)
1125 os.chdir(cwd)
1125 # end user_setup()
1126 # end user_setup()
1126
1127
1127 def atexit_operations(self):
1128 def atexit_operations(self):
1128 """This will be executed at the time of exit.
1129 """This will be executed at the time of exit.
1129
1130
1130 Saving of persistent data should be performed here. """
1131 Saving of persistent data should be performed here. """
1131
1132
1132 #print '*** IPython exit cleanup ***' # dbg
1133 #print '*** IPython exit cleanup ***' # dbg
1133 # input history
1134 # input history
1134 self.savehist()
1135 self.savehist()
1135
1136
1136 # Cleanup all tempfiles left around
1137 # Cleanup all tempfiles left around
1137 for tfile in self.tempfiles:
1138 for tfile in self.tempfiles:
1138 try:
1139 try:
1139 os.unlink(tfile)
1140 os.unlink(tfile)
1140 except OSError:
1141 except OSError:
1141 pass
1142 pass
1142
1143
1143 # save the "persistent data" catch-all dictionary
1144 # save the "persistent data" catch-all dictionary
1144 try:
1145 try:
1145 pickle.dump(self.persist, open(self.persist_fname,"w"))
1146 pickle.dump(self.persist, open(self.persist_fname,"w"))
1146 except:
1147 except:
1147 print "*** ERROR *** persistent data saving failed."
1148 print "*** ERROR *** persistent data saving failed."
1148
1149
1149 def savehist(self):
1150 def savehist(self):
1150 """Save input history to a file (via readline library)."""
1151 """Save input history to a file (via readline library)."""
1151 try:
1152 try:
1152 self.readline.write_history_file(self.histfile)
1153 self.readline.write_history_file(self.histfile)
1153 except:
1154 except:
1154 print 'Unable to save IPython command history to file: ' + \
1155 print 'Unable to save IPython command history to file: ' + \
1155 `self.histfile`
1156 `self.histfile`
1156
1157
1157 def pre_readline(self):
1158 def pre_readline(self):
1158 """readline hook to be used at the start of each line.
1159 """readline hook to be used at the start of each line.
1159
1160
1160 Currently it handles auto-indent only."""
1161 Currently it handles auto-indent only."""
1161
1162
1162 #debugx('self.indent_current_nsp','pre_readline:')
1163 #debugx('self.indent_current_nsp','pre_readline:')
1163 self.readline.insert_text(self.indent_current_str())
1164 self.readline.insert_text(self.indent_current_str())
1164
1165
1165 def init_readline(self):
1166 def init_readline(self):
1166 """Command history completion/saving/reloading."""
1167 """Command history completion/saving/reloading."""
1167 try:
1168 try:
1168 import readline
1169 import readline
1169 except ImportError:
1170 except ImportError:
1170 self.has_readline = 0
1171 self.has_readline = 0
1171 self.readline = None
1172 self.readline = None
1172 # no point in bugging windows users with this every time:
1173 # no point in bugging windows users with this every time:
1173 if os.name == 'posix':
1174 if os.name == 'posix':
1174 warn('Readline services not available on this platform.')
1175 warn('Readline services not available on this platform.')
1175 else:
1176 else:
1176 import atexit
1177 import atexit
1177 from IPython.completer import IPCompleter
1178 from IPython.completer import IPCompleter
1178 self.Completer = IPCompleter(self,
1179 self.Completer = IPCompleter(self,
1179 self.user_ns,
1180 self.user_ns,
1180 self.user_global_ns,
1181 self.user_global_ns,
1181 self.rc.readline_omit__names,
1182 self.rc.readline_omit__names,
1182 self.alias_table)
1183 self.alias_table)
1183
1184
1184 # Platform-specific configuration
1185 # Platform-specific configuration
1185 if os.name == 'nt':
1186 if os.name == 'nt':
1186 self.readline_startup_hook = readline.set_pre_input_hook
1187 self.readline_startup_hook = readline.set_pre_input_hook
1187 else:
1188 else:
1188 self.readline_startup_hook = readline.set_startup_hook
1189 self.readline_startup_hook = readline.set_startup_hook
1189
1190
1190 # Load user's initrc file (readline config)
1191 # Load user's initrc file (readline config)
1191 inputrc_name = os.environ.get('INPUTRC')
1192 inputrc_name = os.environ.get('INPUTRC')
1192 if inputrc_name is None:
1193 if inputrc_name is None:
1193 home_dir = get_home_dir()
1194 home_dir = get_home_dir()
1194 if home_dir is not None:
1195 if home_dir is not None:
1195 inputrc_name = os.path.join(home_dir,'.inputrc')
1196 inputrc_name = os.path.join(home_dir,'.inputrc')
1196 if os.path.isfile(inputrc_name):
1197 if os.path.isfile(inputrc_name):
1197 try:
1198 try:
1198 readline.read_init_file(inputrc_name)
1199 readline.read_init_file(inputrc_name)
1199 except:
1200 except:
1200 warn('Problems reading readline initialization file <%s>'
1201 warn('Problems reading readline initialization file <%s>'
1201 % inputrc_name)
1202 % inputrc_name)
1202
1203
1203 self.has_readline = 1
1204 self.has_readline = 1
1204 self.readline = readline
1205 self.readline = readline
1205 # save this in sys so embedded copies can restore it properly
1206 # save this in sys so embedded copies can restore it properly
1206 sys.ipcompleter = self.Completer.complete
1207 sys.ipcompleter = self.Completer.complete
1207 readline.set_completer(self.Completer.complete)
1208 readline.set_completer(self.Completer.complete)
1208
1209
1209 # Configure readline according to user's prefs
1210 # Configure readline according to user's prefs
1210 for rlcommand in self.rc.readline_parse_and_bind:
1211 for rlcommand in self.rc.readline_parse_and_bind:
1211 readline.parse_and_bind(rlcommand)
1212 readline.parse_and_bind(rlcommand)
1212
1213
1213 # remove some chars from the delimiters list
1214 # remove some chars from the delimiters list
1214 delims = readline.get_completer_delims()
1215 delims = readline.get_completer_delims()
1215 delims = delims.translate(string._idmap,
1216 delims = delims.translate(string._idmap,
1216 self.rc.readline_remove_delims)
1217 self.rc.readline_remove_delims)
1217 readline.set_completer_delims(delims)
1218 readline.set_completer_delims(delims)
1218 # otherwise we end up with a monster history after a while:
1219 # otherwise we end up with a monster history after a while:
1219 readline.set_history_length(1000)
1220 readline.set_history_length(1000)
1220 try:
1221 try:
1221 #print '*** Reading readline history' # dbg
1222 #print '*** Reading readline history' # dbg
1222 readline.read_history_file(self.histfile)
1223 readline.read_history_file(self.histfile)
1223 except IOError:
1224 except IOError:
1224 pass # It doesn't exist yet.
1225 pass # It doesn't exist yet.
1225
1226
1226 atexit.register(self.atexit_operations)
1227 atexit.register(self.atexit_operations)
1227 del atexit
1228 del atexit
1228
1229
1229 # Configure auto-indent for all platforms
1230 # Configure auto-indent for all platforms
1230 self.set_autoindent(self.rc.autoindent)
1231 self.set_autoindent(self.rc.autoindent)
1231
1232
1232 def _should_recompile(self,e):
1233 def _should_recompile(self,e):
1233 """Utility routine for edit_syntax_error"""
1234 """Utility routine for edit_syntax_error"""
1234
1235
1235 if e.filename in ('<ipython console>','<input>','<string>',
1236 if e.filename in ('<ipython console>','<input>','<string>',
1236 '<console>',None):
1237 '<console>',None):
1237
1238
1238 return False
1239 return False
1239 try:
1240 try:
1240 if not ask_yes_no('Return to editor to correct syntax error? '
1241 if not ask_yes_no('Return to editor to correct syntax error? '
1241 '[Y/n] ','y'):
1242 '[Y/n] ','y'):
1242 return False
1243 return False
1243 except EOFError:
1244 except EOFError:
1244 return False
1245 return False
1245
1246
1246 def int0(x):
1247 def int0(x):
1247 try:
1248 try:
1248 return int(x)
1249 return int(x)
1249 except TypeError:
1250 except TypeError:
1250 return 0
1251 return 0
1251 # always pass integer line and offset values to editor hook
1252 # always pass integer line and offset values to editor hook
1252 self.hooks.fix_error_editor(e.filename,
1253 self.hooks.fix_error_editor(e.filename,
1253 int0(e.lineno),int0(e.offset),e.msg)
1254 int0(e.lineno),int0(e.offset),e.msg)
1254 return True
1255 return True
1255
1256
1256 def edit_syntax_error(self):
1257 def edit_syntax_error(self):
1257 """The bottom half of the syntax error handler called in the main loop.
1258 """The bottom half of the syntax error handler called in the main loop.
1258
1259
1259 Loop until syntax error is fixed or user cancels.
1260 Loop until syntax error is fixed or user cancels.
1260 """
1261 """
1261
1262
1262 while self.SyntaxTB.last_syntax_error:
1263 while self.SyntaxTB.last_syntax_error:
1263 # copy and clear last_syntax_error
1264 # copy and clear last_syntax_error
1264 err = self.SyntaxTB.clear_err_state()
1265 err = self.SyntaxTB.clear_err_state()
1265 if not self._should_recompile(err):
1266 if not self._should_recompile(err):
1266 return
1267 return
1267 try:
1268 try:
1268 # may set last_syntax_error again if a SyntaxError is raised
1269 # may set last_syntax_error again if a SyntaxError is raised
1269 self.safe_execfile(err.filename,self.shell.user_ns)
1270 self.safe_execfile(err.filename,self.shell.user_ns)
1270 except:
1271 except:
1271 self.showtraceback()
1272 self.showtraceback()
1272 else:
1273 else:
1273 f = file(err.filename)
1274 f = file(err.filename)
1274 try:
1275 try:
1275 sys.displayhook(f.read())
1276 sys.displayhook(f.read())
1276 finally:
1277 finally:
1277 f.close()
1278 f.close()
1278
1279
1279 def showsyntaxerror(self, filename=None):
1280 def showsyntaxerror(self, filename=None):
1280 """Display the syntax error that just occurred.
1281 """Display the syntax error that just occurred.
1281
1282
1282 This doesn't display a stack trace because there isn't one.
1283 This doesn't display a stack trace because there isn't one.
1283
1284
1284 If a filename is given, it is stuffed in the exception instead
1285 If a filename is given, it is stuffed in the exception instead
1285 of what was there before (because Python's parser always uses
1286 of what was there before (because Python's parser always uses
1286 "<string>" when reading from a string).
1287 "<string>" when reading from a string).
1287 """
1288 """
1288 etype, value, last_traceback = sys.exc_info()
1289 etype, value, last_traceback = sys.exc_info()
1289 if filename and etype is SyntaxError:
1290 if filename and etype is SyntaxError:
1290 # Work hard to stuff the correct filename in the exception
1291 # Work hard to stuff the correct filename in the exception
1291 try:
1292 try:
1292 msg, (dummy_filename, lineno, offset, line) = value
1293 msg, (dummy_filename, lineno, offset, line) = value
1293 except:
1294 except:
1294 # Not the format we expect; leave it alone
1295 # Not the format we expect; leave it alone
1295 pass
1296 pass
1296 else:
1297 else:
1297 # Stuff in the right filename
1298 # Stuff in the right filename
1298 try:
1299 try:
1299 # Assume SyntaxError is a class exception
1300 # Assume SyntaxError is a class exception
1300 value = SyntaxError(msg, (filename, lineno, offset, line))
1301 value = SyntaxError(msg, (filename, lineno, offset, line))
1301 except:
1302 except:
1302 # If that failed, assume SyntaxError is a string
1303 # If that failed, assume SyntaxError is a string
1303 value = msg, (filename, lineno, offset, line)
1304 value = msg, (filename, lineno, offset, line)
1304 self.SyntaxTB(etype,value,[])
1305 self.SyntaxTB(etype,value,[])
1305
1306
1306 def debugger(self):
1307 def debugger(self):
1307 """Call the pdb debugger."""
1308 """Call the pdb debugger."""
1308
1309
1309 if not self.rc.pdb:
1310 if not self.rc.pdb:
1310 return
1311 return
1311 pdb.pm()
1312 pdb.pm()
1312
1313
1313 def showtraceback(self,exc_tuple = None,filename=None):
1314 def showtraceback(self,exc_tuple = None,filename=None):
1314 """Display the exception that just occurred."""
1315 """Display the exception that just occurred."""
1315
1316
1316 # Though this won't be called by syntax errors in the input line,
1317 # Though this won't be called by syntax errors in the input line,
1317 # there may be SyntaxError cases whith imported code.
1318 # there may be SyntaxError cases whith imported code.
1318 if exc_tuple is None:
1319 if exc_tuple is None:
1319 type, value, tb = sys.exc_info()
1320 type, value, tb = sys.exc_info()
1320 else:
1321 else:
1321 type, value, tb = exc_tuple
1322 type, value, tb = exc_tuple
1322 if type is SyntaxError:
1323 if type is SyntaxError:
1323 self.showsyntaxerror(filename)
1324 self.showsyntaxerror(filename)
1324 else:
1325 else:
1325 self.InteractiveTB()
1326 self.InteractiveTB()
1326 if self.InteractiveTB.call_pdb and self.has_readline:
1327 if self.InteractiveTB.call_pdb and self.has_readline:
1327 # pdb mucks up readline, fix it back
1328 # pdb mucks up readline, fix it back
1328 self.readline.set_completer(self.Completer.complete)
1329 self.readline.set_completer(self.Completer.complete)
1329
1330
1330 def mainloop(self,banner=None):
1331 def mainloop(self,banner=None):
1331 """Creates the local namespace and starts the mainloop.
1332 """Creates the local namespace and starts the mainloop.
1332
1333
1333 If an optional banner argument is given, it will override the
1334 If an optional banner argument is given, it will override the
1334 internally created default banner."""
1335 internally created default banner."""
1335
1336
1336 if self.rc.c: # Emulate Python's -c option
1337 if self.rc.c: # Emulate Python's -c option
1337 self.exec_init_cmd()
1338 self.exec_init_cmd()
1338 if banner is None:
1339 if banner is None:
1339 if self.rc.banner:
1340 if self.rc.banner:
1340 banner = self.BANNER+self.banner2
1341 banner = self.BANNER+self.banner2
1341 else:
1342 else:
1342 banner = ''
1343 banner = ''
1343 self.interact(banner)
1344 self.interact(banner)
1344
1345
1345 def exec_init_cmd(self):
1346 def exec_init_cmd(self):
1346 """Execute a command given at the command line.
1347 """Execute a command given at the command line.
1347
1348
1348 This emulates Python's -c option."""
1349 This emulates Python's -c option."""
1349
1350
1350 sys.argv = ['-c']
1351 sys.argv = ['-c']
1351 self.push(self.rc.c)
1352 self.push(self.rc.c)
1352
1353
1353 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1354 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1354 """Embeds IPython into a running python program.
1355 """Embeds IPython into a running python program.
1355
1356
1356 Input:
1357 Input:
1357
1358
1358 - header: An optional header message can be specified.
1359 - header: An optional header message can be specified.
1359
1360
1360 - local_ns, global_ns: working namespaces. If given as None, the
1361 - local_ns, global_ns: working namespaces. If given as None, the
1361 IPython-initialized one is updated with __main__.__dict__, so that
1362 IPython-initialized one is updated with __main__.__dict__, so that
1362 program variables become visible but user-specific configuration
1363 program variables become visible but user-specific configuration
1363 remains possible.
1364 remains possible.
1364
1365
1365 - stack_depth: specifies how many levels in the stack to go to
1366 - stack_depth: specifies how many levels in the stack to go to
1366 looking for namespaces (when local_ns and global_ns are None). This
1367 looking for namespaces (when local_ns and global_ns are None). This
1367 allows an intermediate caller to make sure that this function gets
1368 allows an intermediate caller to make sure that this function gets
1368 the namespace from the intended level in the stack. By default (0)
1369 the namespace from the intended level in the stack. By default (0)
1369 it will get its locals and globals from the immediate caller.
1370 it will get its locals and globals from the immediate caller.
1370
1371
1371 Warning: it's possible to use this in a program which is being run by
1372 Warning: it's possible to use this in a program which is being run by
1372 IPython itself (via %run), but some funny things will happen (a few
1373 IPython itself (via %run), but some funny things will happen (a few
1373 globals get overwritten). In the future this will be cleaned up, as
1374 globals get overwritten). In the future this will be cleaned up, as
1374 there is no fundamental reason why it can't work perfectly."""
1375 there is no fundamental reason why it can't work perfectly."""
1375
1376
1376 # Get locals and globals from caller
1377 # Get locals and globals from caller
1377 if local_ns is None or global_ns is None:
1378 if local_ns is None or global_ns is None:
1378 call_frame = sys._getframe(stack_depth).f_back
1379 call_frame = sys._getframe(stack_depth).f_back
1379
1380
1380 if local_ns is None:
1381 if local_ns is None:
1381 local_ns = call_frame.f_locals
1382 local_ns = call_frame.f_locals
1382 if global_ns is None:
1383 if global_ns is None:
1383 global_ns = call_frame.f_globals
1384 global_ns = call_frame.f_globals
1384
1385
1385 # Update namespaces and fire up interpreter
1386 # Update namespaces and fire up interpreter
1386
1387
1387 # The global one is easy, we can just throw it in
1388 # The global one is easy, we can just throw it in
1388 self.user_global_ns = global_ns
1389 self.user_global_ns = global_ns
1389
1390
1390 # but the user/local one is tricky: ipython needs it to store internal
1391 # but the user/local one is tricky: ipython needs it to store internal
1391 # data, but we also need the locals. We'll copy locals in the user
1392 # data, but we also need the locals. We'll copy locals in the user
1392 # one, but will track what got copied so we can delete them at exit.
1393 # one, but will track what got copied so we can delete them at exit.
1393 # This is so that a later embedded call doesn't see locals from a
1394 # This is so that a later embedded call doesn't see locals from a
1394 # previous call (which most likely existed in a separate scope).
1395 # previous call (which most likely existed in a separate scope).
1395 local_varnames = local_ns.keys()
1396 local_varnames = local_ns.keys()
1396 self.user_ns.update(local_ns)
1397 self.user_ns.update(local_ns)
1397
1398
1398 # Patch for global embedding to make sure that things don't overwrite
1399 # Patch for global embedding to make sure that things don't overwrite
1399 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1400 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1400 # FIXME. Test this a bit more carefully (the if.. is new)
1401 # FIXME. Test this a bit more carefully (the if.. is new)
1401 if local_ns is None and global_ns is None:
1402 if local_ns is None and global_ns is None:
1402 self.user_global_ns.update(__main__.__dict__)
1403 self.user_global_ns.update(__main__.__dict__)
1403
1404
1404 # make sure the tab-completer has the correct frame information, so it
1405 # make sure the tab-completer has the correct frame information, so it
1405 # actually completes using the frame's locals/globals
1406 # actually completes using the frame's locals/globals
1406 self.set_completer_frame()
1407 self.set_completer_frame()
1407
1408
1408 # before activating the interactive mode, we need to make sure that
1409 # before activating the interactive mode, we need to make sure that
1409 # all names in the builtin namespace needed by ipython point to
1410 # all names in the builtin namespace needed by ipython point to
1410 # ourselves, and not to other instances.
1411 # ourselves, and not to other instances.
1411 self.add_builtins()
1412 self.add_builtins()
1412
1413
1413 self.interact(header)
1414 self.interact(header)
1414
1415
1415 # now, purge out the user namespace from anything we might have added
1416 # now, purge out the user namespace from anything we might have added
1416 # from the caller's local namespace
1417 # from the caller's local namespace
1417 delvar = self.user_ns.pop
1418 delvar = self.user_ns.pop
1418 for var in local_varnames:
1419 for var in local_varnames:
1419 delvar(var,None)
1420 delvar(var,None)
1420 # and clean builtins we may have overridden
1421 # and clean builtins we may have overridden
1421 self.clean_builtins()
1422 self.clean_builtins()
1422
1423
1423 def interact(self, banner=None):
1424 def interact(self, banner=None):
1424 """Closely emulate the interactive Python console.
1425 """Closely emulate the interactive Python console.
1425
1426
1426 The optional banner argument specify the banner to print
1427 The optional banner argument specify the banner to print
1427 before the first interaction; by default it prints a banner
1428 before the first interaction; by default it prints a banner
1428 similar to the one printed by the real Python interpreter,
1429 similar to the one printed by the real Python interpreter,
1429 followed by the current class name in parentheses (so as not
1430 followed by the current class name in parentheses (so as not
1430 to confuse this with the real interpreter -- since it's so
1431 to confuse this with the real interpreter -- since it's so
1431 close!).
1432 close!).
1432
1433
1433 """
1434 """
1434 cprt = 'Type "copyright", "credits" or "license" for more information.'
1435 cprt = 'Type "copyright", "credits" or "license" for more information.'
1435 if banner is None:
1436 if banner is None:
1436 self.write("Python %s on %s\n%s\n(%s)\n" %
1437 self.write("Python %s on %s\n%s\n(%s)\n" %
1437 (sys.version, sys.platform, cprt,
1438 (sys.version, sys.platform, cprt,
1438 self.__class__.__name__))
1439 self.__class__.__name__))
1439 else:
1440 else:
1440 self.write(banner)
1441 self.write(banner)
1441
1442
1442 more = 0
1443 more = 0
1443
1444
1444 # Mark activity in the builtins
1445 # Mark activity in the builtins
1445 __builtin__.__dict__['__IPYTHON__active'] += 1
1446 __builtin__.__dict__['__IPYTHON__active'] += 1
1446
1447
1447 # exit_now is set by a call to %Exit or %Quit
1448 # exit_now is set by a call to %Exit or %Quit
1448 self.exit_now = False
1449 self.exit_now = False
1449 while not self.exit_now:
1450 while not self.exit_now:
1450
1451
1451 try:
1452 try:
1452 if more:
1453 if more:
1453 prompt = self.outputcache.prompt2
1454 prompt = self.outputcache.prompt2
1454 if self.autoindent:
1455 if self.autoindent:
1455 self.readline_startup_hook(self.pre_readline)
1456 self.readline_startup_hook(self.pre_readline)
1456 else:
1457 else:
1457 prompt = self.outputcache.prompt1
1458 prompt = self.outputcache.prompt1
1458 try:
1459 try:
1459 line = self.raw_input(prompt,more)
1460 line = self.raw_input(prompt,more)
1460 if self.autoindent:
1461 if self.autoindent:
1461 self.readline_startup_hook(None)
1462 self.readline_startup_hook(None)
1462 except EOFError:
1463 except EOFError:
1463 if self.autoindent:
1464 if self.autoindent:
1464 self.readline_startup_hook(None)
1465 self.readline_startup_hook(None)
1465 self.write("\n")
1466 self.write("\n")
1466 self.exit()
1467 self.exit()
1467 except:
1468 except:
1468 # exceptions here are VERY RARE, but they can be triggered
1469 # exceptions here are VERY RARE, but they can be triggered
1469 # asynchronously by signal handlers, for example.
1470 # asynchronously by signal handlers, for example.
1470 self.showtraceback()
1471 self.showtraceback()
1471 else:
1472 else:
1472 more = self.push(line)
1473 more = self.push(line)
1473
1474
1474 if (self.SyntaxTB.last_syntax_error and
1475 if (self.SyntaxTB.last_syntax_error and
1475 self.rc.autoedit_syntax):
1476 self.rc.autoedit_syntax):
1476 self.edit_syntax_error()
1477 self.edit_syntax_error()
1477
1478
1478 except KeyboardInterrupt:
1479 except KeyboardInterrupt:
1479 self.write("\nKeyboardInterrupt\n")
1480 self.write("\nKeyboardInterrupt\n")
1480 self.resetbuffer()
1481 self.resetbuffer()
1481 more = 0
1482 more = 0
1482 # keep cache in sync with the prompt counter:
1483 # keep cache in sync with the prompt counter:
1483 self.outputcache.prompt_count -= 1
1484 self.outputcache.prompt_count -= 1
1484
1485
1485 if self.autoindent:
1486 if self.autoindent:
1486 self.indent_current_nsp = 0
1487 self.indent_current_nsp = 0
1487
1488
1488 except bdb.BdbQuit:
1489 except bdb.BdbQuit:
1489 warn("The Python debugger has exited with a BdbQuit exception.\n"
1490 warn("The Python debugger has exited with a BdbQuit exception.\n"
1490 "Because of how pdb handles the stack, it is impossible\n"
1491 "Because of how pdb handles the stack, it is impossible\n"
1491 "for IPython to properly format this particular exception.\n"
1492 "for IPython to properly format this particular exception.\n"
1492 "IPython will resume normal operation.")
1493 "IPython will resume normal operation.")
1493
1494
1494 # We are off again...
1495 # We are off again...
1495 __builtin__.__dict__['__IPYTHON__active'] -= 1
1496 __builtin__.__dict__['__IPYTHON__active'] -= 1
1496
1497
1497 def excepthook(self, type, value, tb):
1498 def excepthook(self, type, value, tb):
1498 """One more defense for GUI apps that call sys.excepthook.
1499 """One more defense for GUI apps that call sys.excepthook.
1499
1500
1500 GUI frameworks like wxPython trap exceptions and call
1501 GUI frameworks like wxPython trap exceptions and call
1501 sys.excepthook themselves. I guess this is a feature that
1502 sys.excepthook themselves. I guess this is a feature that
1502 enables them to keep running after exceptions that would
1503 enables them to keep running after exceptions that would
1503 otherwise kill their mainloop. This is a bother for IPython
1504 otherwise kill their mainloop. This is a bother for IPython
1504 which excepts to catch all of the program exceptions with a try:
1505 which excepts to catch all of the program exceptions with a try:
1505 except: statement.
1506 except: statement.
1506
1507
1507 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1508 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1508 any app directly invokes sys.excepthook, it will look to the user like
1509 any app directly invokes sys.excepthook, it will look to the user like
1509 IPython crashed. In order to work around this, we can disable the
1510 IPython crashed. In order to work around this, we can disable the
1510 CrashHandler and replace it with this excepthook instead, which prints a
1511 CrashHandler and replace it with this excepthook instead, which prints a
1511 regular traceback using our InteractiveTB. In this fashion, apps which
1512 regular traceback using our InteractiveTB. In this fashion, apps which
1512 call sys.excepthook will generate a regular-looking exception from
1513 call sys.excepthook will generate a regular-looking exception from
1513 IPython, and the CrashHandler will only be triggered by real IPython
1514 IPython, and the CrashHandler will only be triggered by real IPython
1514 crashes.
1515 crashes.
1515
1516
1516 This hook should be used sparingly, only in places which are not likely
1517 This hook should be used sparingly, only in places which are not likely
1517 to be true IPython errors.
1518 to be true IPython errors.
1518 """
1519 """
1519
1520
1520 self.InteractiveTB(type, value, tb, tb_offset=0)
1521 self.InteractiveTB(type, value, tb, tb_offset=0)
1521 if self.InteractiveTB.call_pdb and self.has_readline:
1522 if self.InteractiveTB.call_pdb and self.has_readline:
1522 self.readline.set_completer(self.Completer.complete)
1523 self.readline.set_completer(self.Completer.complete)
1523
1524
1524 def call_alias(self,alias,rest=''):
1525 def call_alias(self,alias,rest=''):
1525 """Call an alias given its name and the rest of the line.
1526 """Call an alias given its name and the rest of the line.
1526
1527
1527 This function MUST be given a proper alias, because it doesn't make
1528 This function MUST be given a proper alias, because it doesn't make
1528 any checks when looking up into the alias table. The caller is
1529 any checks when looking up into the alias table. The caller is
1529 responsible for invoking it only with a valid alias."""
1530 responsible for invoking it only with a valid alias."""
1530
1531
1531 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1532 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1532 nargs,cmd = self.alias_table[alias]
1533 nargs,cmd = self.alias_table[alias]
1533 # Expand the %l special to be the user's input line
1534 # Expand the %l special to be the user's input line
1534 if cmd.find('%l') >= 0:
1535 if cmd.find('%l') >= 0:
1535 cmd = cmd.replace('%l',rest)
1536 cmd = cmd.replace('%l',rest)
1536 rest = ''
1537 rest = ''
1537 if nargs==0:
1538 if nargs==0:
1538 # Simple, argument-less aliases
1539 # Simple, argument-less aliases
1539 cmd = '%s %s' % (cmd,rest)
1540 cmd = '%s %s' % (cmd,rest)
1540 else:
1541 else:
1541 # Handle aliases with positional arguments
1542 # Handle aliases with positional arguments
1542 args = rest.split(None,nargs)
1543 args = rest.split(None,nargs)
1543 if len(args)< nargs:
1544 if len(args)< nargs:
1544 error('Alias <%s> requires %s arguments, %s given.' %
1545 error('Alias <%s> requires %s arguments, %s given.' %
1545 (alias,nargs,len(args)))
1546 (alias,nargs,len(args)))
1546 return
1547 return
1547 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1548 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1548 # Now call the macro, evaluating in the user's namespace
1549 # Now call the macro, evaluating in the user's namespace
1549 try:
1550 try:
1550 self.system(cmd)
1551 self.system(cmd)
1551 except:
1552 except:
1552 self.showtraceback()
1553 self.showtraceback()
1553
1554
1554 def indent_current_str(self):
1555 def indent_current_str(self):
1555 """return the current level of indentation as a string"""
1556 """return the current level of indentation as a string"""
1556 return self.indent_current_nsp * ' '
1557 return self.indent_current_nsp * ' '
1557
1558
1558 def autoindent_update(self,line):
1559 def autoindent_update(self,line):
1559 """Keep track of the indent level."""
1560 """Keep track of the indent level."""
1560
1561
1561 #debugx('line')
1562 #debugx('line')
1562 #debugx('self.indent_current_nsp')
1563 #debugx('self.indent_current_nsp')
1563 if self.autoindent:
1564 if self.autoindent:
1564 if line:
1565 if line:
1565 inisp = num_ini_spaces(line)
1566 inisp = num_ini_spaces(line)
1566 if inisp < self.indent_current_nsp:
1567 if inisp < self.indent_current_nsp:
1567 self.indent_current_nsp = inisp
1568 self.indent_current_nsp = inisp
1568
1569
1569 if line[-1] == ':':
1570 if line[-1] == ':':
1570 self.indent_current_nsp += 4
1571 self.indent_current_nsp += 4
1571 elif dedent_re.match(line):
1572 elif dedent_re.match(line):
1572 self.indent_current_nsp -= 4
1573 self.indent_current_nsp -= 4
1573 else:
1574 else:
1574 self.indent_current_nsp = 0
1575 self.indent_current_nsp = 0
1575
1576
1576 def runlines(self,lines):
1577 def runlines(self,lines):
1577 """Run a string of one or more lines of source.
1578 """Run a string of one or more lines of source.
1578
1579
1579 This method is capable of running a string containing multiple source
1580 This method is capable of running a string containing multiple source
1580 lines, as if they had been entered at the IPython prompt. Since it
1581 lines, as if they had been entered at the IPython prompt. Since it
1581 exposes IPython's processing machinery, the given strings can contain
1582 exposes IPython's processing machinery, the given strings can contain
1582 magic calls (%magic), special shell access (!cmd), etc."""
1583 magic calls (%magic), special shell access (!cmd), etc."""
1583
1584
1584 # We must start with a clean buffer, in case this is run from an
1585 # We must start with a clean buffer, in case this is run from an
1585 # interactive IPython session (via a magic, for example).
1586 # interactive IPython session (via a magic, for example).
1586 self.resetbuffer()
1587 self.resetbuffer()
1587 lines = lines.split('\n')
1588 lines = lines.split('\n')
1588 more = 0
1589 more = 0
1589 for line in lines:
1590 for line in lines:
1590 # skip blank lines so we don't mess up the prompt counter, but do
1591 # skip blank lines so we don't mess up the prompt counter, but do
1591 # NOT skip even a blank line if we are in a code block (more is
1592 # NOT skip even a blank line if we are in a code block (more is
1592 # true)
1593 # true)
1593 if line or more:
1594 if line or more:
1594 more = self.push(self.prefilter(line,more))
1595 more = self.push(self.prefilter(line,more))
1595 # IPython's runsource returns None if there was an error
1596 # IPython's runsource returns None if there was an error
1596 # compiling the code. This allows us to stop processing right
1597 # compiling the code. This allows us to stop processing right
1597 # away, so the user gets the error message at the right place.
1598 # away, so the user gets the error message at the right place.
1598 if more is None:
1599 if more is None:
1599 break
1600 break
1600 # final newline in case the input didn't have it, so that the code
1601 # final newline in case the input didn't have it, so that the code
1601 # actually does get executed
1602 # actually does get executed
1602 if more:
1603 if more:
1603 self.push('\n')
1604 self.push('\n')
1604
1605
1605 def runsource(self, source, filename='<input>', symbol='single'):
1606 def runsource(self, source, filename='<input>', symbol='single'):
1606 """Compile and run some source in the interpreter.
1607 """Compile and run some source in the interpreter.
1607
1608
1608 Arguments are as for compile_command().
1609 Arguments are as for compile_command().
1609
1610
1610 One several things can happen:
1611 One several things can happen:
1611
1612
1612 1) The input is incorrect; compile_command() raised an
1613 1) The input is incorrect; compile_command() raised an
1613 exception (SyntaxError or OverflowError). A syntax traceback
1614 exception (SyntaxError or OverflowError). A syntax traceback
1614 will be printed by calling the showsyntaxerror() method.
1615 will be printed by calling the showsyntaxerror() method.
1615
1616
1616 2) The input is incomplete, and more input is required;
1617 2) The input is incomplete, and more input is required;
1617 compile_command() returned None. Nothing happens.
1618 compile_command() returned None. Nothing happens.
1618
1619
1619 3) The input is complete; compile_command() returned a code
1620 3) The input is complete; compile_command() returned a code
1620 object. The code is executed by calling self.runcode() (which
1621 object. The code is executed by calling self.runcode() (which
1621 also handles run-time exceptions, except for SystemExit).
1622 also handles run-time exceptions, except for SystemExit).
1622
1623
1623 The return value is:
1624 The return value is:
1624
1625
1625 - True in case 2
1626 - True in case 2
1626
1627
1627 - False in the other cases, unless an exception is raised, where
1628 - False in the other cases, unless an exception is raised, where
1628 None is returned instead. This can be used by external callers to
1629 None is returned instead. This can be used by external callers to
1629 know whether to continue feeding input or not.
1630 know whether to continue feeding input or not.
1630
1631
1631 The return value can be used to decide whether to use sys.ps1 or
1632 The return value can be used to decide whether to use sys.ps1 or
1632 sys.ps2 to prompt the next line."""
1633 sys.ps2 to prompt the next line."""
1633
1634
1634 try:
1635 try:
1635 code = self.compile(source,filename,symbol)
1636 code = self.compile(source,filename,symbol)
1636 except (OverflowError, SyntaxError, ValueError):
1637 except (OverflowError, SyntaxError, ValueError):
1637 # Case 1
1638 # Case 1
1638 self.showsyntaxerror(filename)
1639 self.showsyntaxerror(filename)
1639 return None
1640 return None
1640
1641
1641 if code is None:
1642 if code is None:
1642 # Case 2
1643 # Case 2
1643 return True
1644 return True
1644
1645
1645 # Case 3
1646 # Case 3
1646 # We store the code object so that threaded shells and
1647 # We store the code object so that threaded shells and
1647 # custom exception handlers can access all this info if needed.
1648 # custom exception handlers can access all this info if needed.
1648 # The source corresponding to this can be obtained from the
1649 # The source corresponding to this can be obtained from the
1649 # buffer attribute as '\n'.join(self.buffer).
1650 # buffer attribute as '\n'.join(self.buffer).
1650 self.code_to_run = code
1651 self.code_to_run = code
1651 # now actually execute the code object
1652 # now actually execute the code object
1652 if self.runcode(code) == 0:
1653 if self.runcode(code) == 0:
1653 return False
1654 return False
1654 else:
1655 else:
1655 return None
1656 return None
1656
1657
1657 def runcode(self,code_obj):
1658 def runcode(self,code_obj):
1658 """Execute a code object.
1659 """Execute a code object.
1659
1660
1660 When an exception occurs, self.showtraceback() is called to display a
1661 When an exception occurs, self.showtraceback() is called to display a
1661 traceback.
1662 traceback.
1662
1663
1663 Return value: a flag indicating whether the code to be run completed
1664 Return value: a flag indicating whether the code to be run completed
1664 successfully:
1665 successfully:
1665
1666
1666 - 0: successful execution.
1667 - 0: successful execution.
1667 - 1: an error occurred.
1668 - 1: an error occurred.
1668 """
1669 """
1669
1670
1670 # Set our own excepthook in case the user code tries to call it
1671 # Set our own excepthook in case the user code tries to call it
1671 # directly, so that the IPython crash handler doesn't get triggered
1672 # directly, so that the IPython crash handler doesn't get triggered
1672 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1673 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1673
1674
1674 # we save the original sys.excepthook in the instance, in case config
1675 # we save the original sys.excepthook in the instance, in case config
1675 # code (such as magics) needs access to it.
1676 # code (such as magics) needs access to it.
1676 self.sys_excepthook = old_excepthook
1677 self.sys_excepthook = old_excepthook
1677 outflag = 1 # happens in more places, so it's easier as default
1678 outflag = 1 # happens in more places, so it's easier as default
1678 try:
1679 try:
1679 try:
1680 try:
1680 # Embedded instances require separate global/local namespaces
1681 # Embedded instances require separate global/local namespaces
1681 # so they can see both the surrounding (local) namespace and
1682 # so they can see both the surrounding (local) namespace and
1682 # the module-level globals when called inside another function.
1683 # the module-level globals when called inside another function.
1683 if self.embedded:
1684 if self.embedded:
1684 exec code_obj in self.user_global_ns, self.user_ns
1685 exec code_obj in self.user_global_ns, self.user_ns
1685 # Normal (non-embedded) instances should only have a single
1686 # Normal (non-embedded) instances should only have a single
1686 # namespace for user code execution, otherwise functions won't
1687 # namespace for user code execution, otherwise functions won't
1687 # see interactive top-level globals.
1688 # see interactive top-level globals.
1688 else:
1689 else:
1689 exec code_obj in self.user_ns
1690 exec code_obj in self.user_ns
1690 finally:
1691 finally:
1691 # Reset our crash handler in place
1692 # Reset our crash handler in place
1692 sys.excepthook = old_excepthook
1693 sys.excepthook = old_excepthook
1693 except SystemExit:
1694 except SystemExit:
1694 self.resetbuffer()
1695 self.resetbuffer()
1695 self.showtraceback()
1696 self.showtraceback()
1696 warn("Type exit or quit to exit IPython "
1697 warn("Type exit or quit to exit IPython "
1697 "(%Exit or %Quit do so unconditionally).",level=1)
1698 "(%Exit or %Quit do so unconditionally).",level=1)
1698 except self.custom_exceptions:
1699 except self.custom_exceptions:
1699 etype,value,tb = sys.exc_info()
1700 etype,value,tb = sys.exc_info()
1700 self.CustomTB(etype,value,tb)
1701 self.CustomTB(etype,value,tb)
1701 except:
1702 except:
1702 self.showtraceback()
1703 self.showtraceback()
1703 else:
1704 else:
1704 outflag = 0
1705 outflag = 0
1705 if softspace(sys.stdout, 0):
1706 if softspace(sys.stdout, 0):
1706 print
1707 print
1707 # Flush out code object which has been run (and source)
1708 # Flush out code object which has been run (and source)
1708 self.code_to_run = None
1709 self.code_to_run = None
1709 return outflag
1710 return outflag
1710
1711
1711 def push(self, line):
1712 def push(self, line):
1712 """Push a line to the interpreter.
1713 """Push a line to the interpreter.
1713
1714
1714 The line should not have a trailing newline; it may have
1715 The line should not have a trailing newline; it may have
1715 internal newlines. The line is appended to a buffer and the
1716 internal newlines. The line is appended to a buffer and the
1716 interpreter's runsource() method is called with the
1717 interpreter's runsource() method is called with the
1717 concatenated contents of the buffer as source. If this
1718 concatenated contents of the buffer as source. If this
1718 indicates that the command was executed or invalid, the buffer
1719 indicates that the command was executed or invalid, the buffer
1719 is reset; otherwise, the command is incomplete, and the buffer
1720 is reset; otherwise, the command is incomplete, and the buffer
1720 is left as it was after the line was appended. The return
1721 is left as it was after the line was appended. The return
1721 value is 1 if more input is required, 0 if the line was dealt
1722 value is 1 if more input is required, 0 if the line was dealt
1722 with in some way (this is the same as runsource()).
1723 with in some way (this is the same as runsource()).
1723 """
1724 """
1724
1725
1725 # autoindent management should be done here, and not in the
1726 # autoindent management should be done here, and not in the
1726 # interactive loop, since that one is only seen by keyboard input. We
1727 # interactive loop, since that one is only seen by keyboard input. We
1727 # need this done correctly even for code run via runlines (which uses
1728 # need this done correctly even for code run via runlines (which uses
1728 # push).
1729 # push).
1729
1730
1730 #print 'push line: <%s>' % line # dbg
1731 #print 'push line: <%s>' % line # dbg
1731 self.autoindent_update(line)
1732 self.autoindent_update(line)
1732
1733
1733 self.buffer.append(line)
1734 self.buffer.append(line)
1734 more = self.runsource('\n'.join(self.buffer), self.filename)
1735 more = self.runsource('\n'.join(self.buffer), self.filename)
1735 if not more:
1736 if not more:
1736 self.resetbuffer()
1737 self.resetbuffer()
1737 return more
1738 return more
1738
1739
1739 def resetbuffer(self):
1740 def resetbuffer(self):
1740 """Reset the input buffer."""
1741 """Reset the input buffer."""
1741 self.buffer[:] = []
1742 self.buffer[:] = []
1742
1743
1743 def raw_input(self,prompt='',continue_prompt=False):
1744 def raw_input(self,prompt='',continue_prompt=False):
1744 """Write a prompt and read a line.
1745 """Write a prompt and read a line.
1745
1746
1746 The returned line does not include the trailing newline.
1747 The returned line does not include the trailing newline.
1747 When the user enters the EOF key sequence, EOFError is raised.
1748 When the user enters the EOF key sequence, EOFError is raised.
1748
1749
1749 Optional inputs:
1750 Optional inputs:
1750
1751
1751 - prompt(''): a string to be printed to prompt the user.
1752 - prompt(''): a string to be printed to prompt the user.
1752
1753
1753 - continue_prompt(False): whether this line is the first one or a
1754 - continue_prompt(False): whether this line is the first one or a
1754 continuation in a sequence of inputs.
1755 continuation in a sequence of inputs.
1755 """
1756 """
1756
1757
1757 line = raw_input_original(prompt)
1758 line = raw_input_original(prompt)
1758 # Try to be reasonably smart about not re-indenting pasted input more
1759 # Try to be reasonably smart about not re-indenting pasted input more
1759 # than necessary. We do this by trimming out the auto-indent initial
1760 # than necessary. We do this by trimming out the auto-indent initial
1760 # spaces, if the user's actual input started itself with whitespace.
1761 # spaces, if the user's actual input started itself with whitespace.
1761 #debugx('self.buffer[-1]')
1762 #debugx('self.buffer[-1]')
1762
1763
1763 if self.autoindent:
1764 if self.autoindent:
1764 if num_ini_spaces(line) > self.indent_current_nsp:
1765 if num_ini_spaces(line) > self.indent_current_nsp:
1765 line = line[self.indent_current_nsp:]
1766 line = line[self.indent_current_nsp:]
1766 self.indent_current_nsp = 0
1767 self.indent_current_nsp = 0
1767
1768
1768 # store the unfiltered input before the user has any chance to modify
1769 # store the unfiltered input before the user has any chance to modify
1769 # it.
1770 # it.
1770 if line.strip():
1771 if line.strip():
1771 if continue_prompt:
1772 if continue_prompt:
1772 self.input_hist_raw[-1] += '%s\n' % line
1773 self.input_hist_raw[-1] += '%s\n' % line
1773 else:
1774 else:
1774 self.input_hist_raw.append('%s\n' % line)
1775 self.input_hist_raw.append('%s\n' % line)
1775
1776
1776 lineout = self.prefilter(line,continue_prompt)
1777 lineout = self.prefilter(line,continue_prompt)
1777 return lineout
1778 return lineout
1778
1779
1779 def split_user_input(self,line):
1780 def split_user_input(self,line):
1780 """Split user input into pre-char, function part and rest."""
1781 """Split user input into pre-char, function part and rest."""
1781
1782
1782 lsplit = self.line_split.match(line)
1783 lsplit = self.line_split.match(line)
1783 if lsplit is None: # no regexp match returns None
1784 if lsplit is None: # no regexp match returns None
1784 try:
1785 try:
1785 iFun,theRest = line.split(None,1)
1786 iFun,theRest = line.split(None,1)
1786 except ValueError:
1787 except ValueError:
1787 iFun,theRest = line,''
1788 iFun,theRest = line,''
1788 pre = re.match('^(\s*)(.*)',line).groups()[0]
1789 pre = re.match('^(\s*)(.*)',line).groups()[0]
1789 else:
1790 else:
1790 pre,iFun,theRest = lsplit.groups()
1791 pre,iFun,theRest = lsplit.groups()
1791
1792
1792 #print 'line:<%s>' % line # dbg
1793 #print 'line:<%s>' % line # dbg
1793 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1794 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1794 return pre,iFun.strip(),theRest
1795 return pre,iFun.strip(),theRest
1795
1796
1796 def _prefilter(self, line, continue_prompt):
1797 def _prefilter(self, line, continue_prompt):
1797 """Calls different preprocessors, depending on the form of line."""
1798 """Calls different preprocessors, depending on the form of line."""
1798
1799
1799 # All handlers *must* return a value, even if it's blank ('').
1800 # All handlers *must* return a value, even if it's blank ('').
1800
1801
1801 # Lines are NOT logged here. Handlers should process the line as
1802 # Lines are NOT logged here. Handlers should process the line as
1802 # needed, update the cache AND log it (so that the input cache array
1803 # needed, update the cache AND log it (so that the input cache array
1803 # stays synced).
1804 # stays synced).
1804
1805
1805 # This function is _very_ delicate, and since it's also the one which
1806 # This function is _very_ delicate, and since it's also the one which
1806 # determines IPython's response to user input, it must be as efficient
1807 # determines IPython's response to user input, it must be as efficient
1807 # as possible. For this reason it has _many_ returns in it, trying
1808 # as possible. For this reason it has _many_ returns in it, trying
1808 # always to exit as quickly as it can figure out what it needs to do.
1809 # always to exit as quickly as it can figure out what it needs to do.
1809
1810
1810 # This function is the main responsible for maintaining IPython's
1811 # This function is the main responsible for maintaining IPython's
1811 # behavior respectful of Python's semantics. So be _very_ careful if
1812 # behavior respectful of Python's semantics. So be _very_ careful if
1812 # making changes to anything here.
1813 # making changes to anything here.
1813
1814
1814 #.....................................................................
1815 #.....................................................................
1815 # Code begins
1816 # Code begins
1816
1817
1817 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1818 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1818
1819
1819 # save the line away in case we crash, so the post-mortem handler can
1820 # save the line away in case we crash, so the post-mortem handler can
1820 # record it
1821 # record it
1821 self._last_input_line = line
1822 self._last_input_line = line
1822
1823
1823 #print '***line: <%s>' % line # dbg
1824 #print '***line: <%s>' % line # dbg
1824
1825
1825 # the input history needs to track even empty lines
1826 # the input history needs to track even empty lines
1826 if not line.strip():
1827 if not line.strip():
1827 if not continue_prompt:
1828 if not continue_prompt:
1828 self.outputcache.prompt_count -= 1
1829 self.outputcache.prompt_count -= 1
1829 return self.handle_normal(line,continue_prompt)
1830 return self.handle_normal(line,continue_prompt)
1830 #return self.handle_normal('',continue_prompt)
1831 #return self.handle_normal('',continue_prompt)
1831
1832
1832 # print '***cont',continue_prompt # dbg
1833 # print '***cont',continue_prompt # dbg
1833 # special handlers are only allowed for single line statements
1834 # special handlers are only allowed for single line statements
1834 if continue_prompt and not self.rc.multi_line_specials:
1835 if continue_prompt and not self.rc.multi_line_specials:
1835 return self.handle_normal(line,continue_prompt)
1836 return self.handle_normal(line,continue_prompt)
1836
1837
1837 # For the rest, we need the structure of the input
1838 # For the rest, we need the structure of the input
1838 pre,iFun,theRest = self.split_user_input(line)
1839 pre,iFun,theRest = self.split_user_input(line)
1839 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1840 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1840
1841
1841 # First check for explicit escapes in the last/first character
1842 # First check for explicit escapes in the last/first character
1842 handler = None
1843 handler = None
1843 if line[-1] == self.ESC_HELP:
1844 if line[-1] == self.ESC_HELP:
1844 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1845 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1845 if handler is None:
1846 if handler is None:
1846 # look at the first character of iFun, NOT of line, so we skip
1847 # look at the first character of iFun, NOT of line, so we skip
1847 # leading whitespace in multiline input
1848 # leading whitespace in multiline input
1848 handler = self.esc_handlers.get(iFun[0:1])
1849 handler = self.esc_handlers.get(iFun[0:1])
1849 if handler is not None:
1850 if handler is not None:
1850 return handler(line,continue_prompt,pre,iFun,theRest)
1851 return handler(line,continue_prompt,pre,iFun,theRest)
1851 # Emacs ipython-mode tags certain input lines
1852 # Emacs ipython-mode tags certain input lines
1852 if line.endswith('# PYTHON-MODE'):
1853 if line.endswith('# PYTHON-MODE'):
1853 return self.handle_emacs(line,continue_prompt)
1854 return self.handle_emacs(line,continue_prompt)
1854
1855
1855 # Next, check if we can automatically execute this thing
1856 # Next, check if we can automatically execute this thing
1856
1857
1857 # Allow ! in multi-line statements if multi_line_specials is on:
1858 # Allow ! in multi-line statements if multi_line_specials is on:
1858 if continue_prompt and self.rc.multi_line_specials and \
1859 if continue_prompt and self.rc.multi_line_specials and \
1859 iFun.startswith(self.ESC_SHELL):
1860 iFun.startswith(self.ESC_SHELL):
1860 return self.handle_shell_escape(line,continue_prompt,
1861 return self.handle_shell_escape(line,continue_prompt,
1861 pre=pre,iFun=iFun,
1862 pre=pre,iFun=iFun,
1862 theRest=theRest)
1863 theRest=theRest)
1863
1864
1864 # Let's try to find if the input line is a magic fn
1865 # Let's try to find if the input line is a magic fn
1865 oinfo = None
1866 oinfo = None
1866 if hasattr(self,'magic_'+iFun):
1867 if hasattr(self,'magic_'+iFun):
1867 # WARNING: _ofind uses getattr(), so it can consume generators and
1868 # WARNING: _ofind uses getattr(), so it can consume generators and
1868 # cause other side effects.
1869 # cause other side effects.
1869 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1870 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1870 if oinfo['ismagic']:
1871 if oinfo['ismagic']:
1871 # Be careful not to call magics when a variable assignment is
1872 # Be careful not to call magics when a variable assignment is
1872 # being made (ls='hi', for example)
1873 # being made (ls='hi', for example)
1873 if self.rc.automagic and \
1874 if self.rc.automagic and \
1874 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1875 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1875 (self.rc.multi_line_specials or not continue_prompt):
1876 (self.rc.multi_line_specials or not continue_prompt):
1876 return self.handle_magic(line,continue_prompt,
1877 return self.handle_magic(line,continue_prompt,
1877 pre,iFun,theRest)
1878 pre,iFun,theRest)
1878 else:
1879 else:
1879 return self.handle_normal(line,continue_prompt)
1880 return self.handle_normal(line,continue_prompt)
1880
1881
1881 # If the rest of the line begins with an (in)equality, assginment or
1882 # If the rest of the line begins with an (in)equality, assginment or
1882 # function call, we should not call _ofind but simply execute it.
1883 # function call, we should not call _ofind but simply execute it.
1883 # This avoids spurious geattr() accesses on objects upon assignment.
1884 # This avoids spurious geattr() accesses on objects upon assignment.
1884 #
1885 #
1885 # It also allows users to assign to either alias or magic names true
1886 # It also allows users to assign to either alias or magic names true
1886 # python variables (the magic/alias systems always take second seat to
1887 # python variables (the magic/alias systems always take second seat to
1887 # true python code).
1888 # true python code).
1888 if theRest and theRest[0] in '!=()':
1889 if theRest and theRest[0] in '!=()':
1889 return self.handle_normal(line,continue_prompt)
1890 return self.handle_normal(line,continue_prompt)
1890
1891
1891 if oinfo is None:
1892 if oinfo is None:
1892 # let's try to ensure that _oinfo is ONLY called when autocall is
1893 # let's try to ensure that _oinfo is ONLY called when autocall is
1893 # on. Since it has inevitable potential side effects, at least
1894 # on. Since it has inevitable potential side effects, at least
1894 # having autocall off should be a guarantee to the user that no
1895 # having autocall off should be a guarantee to the user that no
1895 # weird things will happen.
1896 # weird things will happen.
1896
1897
1897 if self.rc.autocall:
1898 if self.rc.autocall:
1898 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1899 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1899 else:
1900 else:
1900 # in this case, all that's left is either an alias or
1901 # in this case, all that's left is either an alias or
1901 # processing the line normally.
1902 # processing the line normally.
1902 if iFun in self.alias_table:
1903 if iFun in self.alias_table:
1903 return self.handle_alias(line,continue_prompt,
1904 return self.handle_alias(line,continue_prompt,
1904 pre,iFun,theRest)
1905 pre,iFun,theRest)
1905
1906
1906 else:
1907 else:
1907 return self.handle_normal(line,continue_prompt)
1908 return self.handle_normal(line,continue_prompt)
1908
1909
1909 if not oinfo['found']:
1910 if not oinfo['found']:
1910 return self.handle_normal(line,continue_prompt)
1911 return self.handle_normal(line,continue_prompt)
1911 else:
1912 else:
1912 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1913 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1913 if oinfo['isalias']:
1914 if oinfo['isalias']:
1914 return self.handle_alias(line,continue_prompt,
1915 return self.handle_alias(line,continue_prompt,
1915 pre,iFun,theRest)
1916 pre,iFun,theRest)
1916
1917
1917 if (self.rc.autocall
1918 if (self.rc.autocall
1918 and
1919 and
1919 (
1920 (
1920 #only consider exclusion re if not "," or ";" autoquoting
1921 #only consider exclusion re if not "," or ";" autoquoting
1921 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2) or
1922 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2) or
1922 (not self.re_exclude_auto.match(theRest)))
1923 (not self.re_exclude_auto.match(theRest)))
1923 and
1924 and
1924 self.re_fun_name.match(iFun) and
1925 self.re_fun_name.match(iFun) and
1925 callable(oinfo['obj'])) :
1926 callable(oinfo['obj'])) :
1926 #print 'going auto' # dbg
1927 #print 'going auto' # dbg
1927 return self.handle_auto(line,continue_prompt,
1928 return self.handle_auto(line,continue_prompt,
1928 pre,iFun,theRest,oinfo['obj'])
1929 pre,iFun,theRest,oinfo['obj'])
1929 else:
1930 else:
1930 #print 'was callable?', callable(oinfo['obj']) # dbg
1931 #print 'was callable?', callable(oinfo['obj']) # dbg
1931 return self.handle_normal(line,continue_prompt)
1932 return self.handle_normal(line,continue_prompt)
1932
1933
1933 # If we get here, we have a normal Python line. Log and return.
1934 # If we get here, we have a normal Python line. Log and return.
1934 return self.handle_normal(line,continue_prompt)
1935 return self.handle_normal(line,continue_prompt)
1935
1936
1936 def _prefilter_dumb(self, line, continue_prompt):
1937 def _prefilter_dumb(self, line, continue_prompt):
1937 """simple prefilter function, for debugging"""
1938 """simple prefilter function, for debugging"""
1938 return self.handle_normal(line,continue_prompt)
1939 return self.handle_normal(line,continue_prompt)
1939
1940
1940 # Set the default prefilter() function (this can be user-overridden)
1941 # Set the default prefilter() function (this can be user-overridden)
1941 prefilter = _prefilter
1942 prefilter = _prefilter
1942
1943
1943 def handle_normal(self,line,continue_prompt=None,
1944 def handle_normal(self,line,continue_prompt=None,
1944 pre=None,iFun=None,theRest=None):
1945 pre=None,iFun=None,theRest=None):
1945 """Handle normal input lines. Use as a template for handlers."""
1946 """Handle normal input lines. Use as a template for handlers."""
1946
1947
1947 # With autoindent on, we need some way to exit the input loop, and I
1948 # With autoindent on, we need some way to exit the input loop, and I
1948 # don't want to force the user to have to backspace all the way to
1949 # don't want to force the user to have to backspace all the way to
1949 # clear the line. The rule will be in this case, that either two
1950 # clear the line. The rule will be in this case, that either two
1950 # lines of pure whitespace in a row, or a line of pure whitespace but
1951 # lines of pure whitespace in a row, or a line of pure whitespace but
1951 # of a size different to the indent level, will exit the input loop.
1952 # of a size different to the indent level, will exit the input loop.
1952
1953
1953 if (continue_prompt and self.autoindent and line.isspace() and
1954 if (continue_prompt and self.autoindent and line.isspace() and
1954 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
1955 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
1955 (self.buffer[-1]).isspace() )):
1956 (self.buffer[-1]).isspace() )):
1956 line = ''
1957 line = ''
1957
1958
1958 self.log(line,continue_prompt)
1959 self.log(line,continue_prompt)
1959 return line
1960 return line
1960
1961
1961 def handle_alias(self,line,continue_prompt=None,
1962 def handle_alias(self,line,continue_prompt=None,
1962 pre=None,iFun=None,theRest=None):
1963 pre=None,iFun=None,theRest=None):
1963 """Handle alias input lines. """
1964 """Handle alias input lines. """
1964
1965
1965 # pre is needed, because it carries the leading whitespace. Otherwise
1966 # pre is needed, because it carries the leading whitespace. Otherwise
1966 # aliases won't work in indented sections.
1967 # aliases won't work in indented sections.
1967 line_out = '%sipalias(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1968 line_out = '%sipalias(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1968 self.log(line_out,continue_prompt)
1969 self.log(line_out,continue_prompt)
1969 return line_out
1970 return line_out
1970
1971
1971 def handle_shell_escape(self, line, continue_prompt=None,
1972 def handle_shell_escape(self, line, continue_prompt=None,
1972 pre=None,iFun=None,theRest=None):
1973 pre=None,iFun=None,theRest=None):
1973 """Execute the line in a shell, empty return value"""
1974 """Execute the line in a shell, empty return value"""
1974
1975
1975 #print 'line in :', `line` # dbg
1976 #print 'line in :', `line` # dbg
1976 # Example of a special handler. Others follow a similar pattern.
1977 # Example of a special handler. Others follow a similar pattern.
1977 if line.lstrip().startswith('!!'):
1978 if line.lstrip().startswith('!!'):
1978 # rewrite iFun/theRest to properly hold the call to %sx and
1979 # rewrite iFun/theRest to properly hold the call to %sx and
1979 # the actual command to be executed, so handle_magic can work
1980 # the actual command to be executed, so handle_magic can work
1980 # correctly
1981 # correctly
1981 theRest = '%s %s' % (iFun[2:],theRest)
1982 theRest = '%s %s' % (iFun[2:],theRest)
1982 iFun = 'sx'
1983 iFun = 'sx'
1983 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
1984 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
1984 line.lstrip()[2:]),
1985 line.lstrip()[2:]),
1985 continue_prompt,pre,iFun,theRest)
1986 continue_prompt,pre,iFun,theRest)
1986 else:
1987 else:
1987 cmd=line.lstrip().lstrip('!')
1988 cmd=line.lstrip().lstrip('!')
1988 line_out = '%sipsystem(%s)' % (pre,make_quoted_expr(cmd))
1989 line_out = '%sipsystem(%s)' % (pre,make_quoted_expr(cmd))
1989 # update cache/log and return
1990 # update cache/log and return
1990 self.log(line_out,continue_prompt)
1991 self.log(line_out,continue_prompt)
1991 return line_out
1992 return line_out
1992
1993
1993 def handle_magic(self, line, continue_prompt=None,
1994 def handle_magic(self, line, continue_prompt=None,
1994 pre=None,iFun=None,theRest=None):
1995 pre=None,iFun=None,theRest=None):
1995 """Execute magic functions."""
1996 """Execute magic functions."""
1996
1997
1997
1998
1998 cmd = '%sipmagic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1999 cmd = '%sipmagic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1999 self.log(cmd,continue_prompt)
2000 self.log(cmd,continue_prompt)
2000 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2001 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2001 return cmd
2002 return cmd
2002
2003
2003 def handle_auto(self, line, continue_prompt=None,
2004 def handle_auto(self, line, continue_prompt=None,
2004 pre=None,iFun=None,theRest=None,obj=None):
2005 pre=None,iFun=None,theRest=None,obj=None):
2005 """Hande lines which can be auto-executed, quoting if requested."""
2006 """Hande lines which can be auto-executed, quoting if requested."""
2006
2007
2007 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2008 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2008
2009
2009 # This should only be active for single-line input!
2010 # This should only be active for single-line input!
2010 if continue_prompt:
2011 if continue_prompt:
2011 self.log(line,continue_prompt)
2012 self.log(line,continue_prompt)
2012 return line
2013 return line
2013
2014
2014 auto_rewrite = True
2015 auto_rewrite = True
2015 if pre == self.ESC_QUOTE:
2016 if pre == self.ESC_QUOTE:
2016 # Auto-quote splitting on whitespace
2017 # Auto-quote splitting on whitespace
2017 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2018 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2018 elif pre == self.ESC_QUOTE2:
2019 elif pre == self.ESC_QUOTE2:
2019 # Auto-quote whole string
2020 # Auto-quote whole string
2020 newcmd = '%s("%s")' % (iFun,theRest)
2021 newcmd = '%s("%s")' % (iFun,theRest)
2021 else:
2022 else:
2022 # Auto-paren.
2023 # Auto-paren.
2023 # We only apply it to argument-less calls if the autocall
2024 # We only apply it to argument-less calls if the autocall
2024 # parameter is set to 2. We only need to check that autocall is <
2025 # parameter is set to 2. We only need to check that autocall is <
2025 # 2, since this function isn't called unless it's at least 1.
2026 # 2, since this function isn't called unless it's at least 1.
2026 if not theRest and (self.rc.autocall < 2):
2027 if not theRest and (self.rc.autocall < 2):
2027 newcmd = '%s %s' % (iFun,theRest)
2028 newcmd = '%s %s' % (iFun,theRest)
2028 auto_rewrite = False
2029 auto_rewrite = False
2029 else:
2030 else:
2030 if theRest.startswith('['):
2031 if theRest.startswith('['):
2031 if hasattr(obj,'__getitem__'):
2032 if hasattr(obj,'__getitem__'):
2032 # Don't autocall in this case: item access for an object
2033 # Don't autocall in this case: item access for an object
2033 # which is BOTH callable and implements __getitem__.
2034 # which is BOTH callable and implements __getitem__.
2034 newcmd = '%s %s' % (iFun,theRest)
2035 newcmd = '%s %s' % (iFun,theRest)
2035 auto_rewrite = False
2036 auto_rewrite = False
2036 else:
2037 else:
2037 # if the object doesn't support [] access, go ahead and
2038 # if the object doesn't support [] access, go ahead and
2038 # autocall
2039 # autocall
2039 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2040 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2040 elif theRest.endswith(';'):
2041 elif theRest.endswith(';'):
2041 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2042 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2042 else:
2043 else:
2043 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2044 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2044
2045
2045 if auto_rewrite:
2046 if auto_rewrite:
2046 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2047 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2047 # log what is now valid Python, not the actual user input (without the
2048 # log what is now valid Python, not the actual user input (without the
2048 # final newline)
2049 # final newline)
2049 self.log(newcmd,continue_prompt)
2050 self.log(newcmd,continue_prompt)
2050 return newcmd
2051 return newcmd
2051
2052
2052 def handle_help(self, line, continue_prompt=None,
2053 def handle_help(self, line, continue_prompt=None,
2053 pre=None,iFun=None,theRest=None):
2054 pre=None,iFun=None,theRest=None):
2054 """Try to get some help for the object.
2055 """Try to get some help for the object.
2055
2056
2056 obj? or ?obj -> basic information.
2057 obj? or ?obj -> basic information.
2057 obj?? or ??obj -> more details.
2058 obj?? or ??obj -> more details.
2058 """
2059 """
2059
2060
2060 # We need to make sure that we don't process lines which would be
2061 # We need to make sure that we don't process lines which would be
2061 # otherwise valid python, such as "x=1 # what?"
2062 # otherwise valid python, such as "x=1 # what?"
2062 try:
2063 try:
2063 codeop.compile_command(line)
2064 codeop.compile_command(line)
2064 except SyntaxError:
2065 except SyntaxError:
2065 # We should only handle as help stuff which is NOT valid syntax
2066 # We should only handle as help stuff which is NOT valid syntax
2066 if line[0]==self.ESC_HELP:
2067 if line[0]==self.ESC_HELP:
2067 line = line[1:]
2068 line = line[1:]
2068 elif line[-1]==self.ESC_HELP:
2069 elif line[-1]==self.ESC_HELP:
2069 line = line[:-1]
2070 line = line[:-1]
2070 self.log('#?'+line)
2071 self.log('#?'+line)
2071 if line:
2072 if line:
2072 self.magic_pinfo(line)
2073 self.magic_pinfo(line)
2073 else:
2074 else:
2074 page(self.usage,screen_lines=self.rc.screen_length)
2075 page(self.usage,screen_lines=self.rc.screen_length)
2075 return '' # Empty string is needed here!
2076 return '' # Empty string is needed here!
2076 except:
2077 except:
2077 # Pass any other exceptions through to the normal handler
2078 # Pass any other exceptions through to the normal handler
2078 return self.handle_normal(line,continue_prompt)
2079 return self.handle_normal(line,continue_prompt)
2079 else:
2080 else:
2080 # If the code compiles ok, we should handle it normally
2081 # If the code compiles ok, we should handle it normally
2081 return self.handle_normal(line,continue_prompt)
2082 return self.handle_normal(line,continue_prompt)
2082
2083
2083 def handle_emacs(self,line,continue_prompt=None,
2084 def handle_emacs(self,line,continue_prompt=None,
2084 pre=None,iFun=None,theRest=None):
2085 pre=None,iFun=None,theRest=None):
2085 """Handle input lines marked by python-mode."""
2086 """Handle input lines marked by python-mode."""
2086
2087
2087 # Currently, nothing is done. Later more functionality can be added
2088 # Currently, nothing is done. Later more functionality can be added
2088 # here if needed.
2089 # here if needed.
2089
2090
2090 # The input cache shouldn't be updated
2091 # The input cache shouldn't be updated
2091
2092
2092 return line
2093 return line
2093
2094
2094 def mktempfile(self,data=None):
2095 def mktempfile(self,data=None):
2095 """Make a new tempfile and return its filename.
2096 """Make a new tempfile and return its filename.
2096
2097
2097 This makes a call to tempfile.mktemp, but it registers the created
2098 This makes a call to tempfile.mktemp, but it registers the created
2098 filename internally so ipython cleans it up at exit time.
2099 filename internally so ipython cleans it up at exit time.
2099
2100
2100 Optional inputs:
2101 Optional inputs:
2101
2102
2102 - data(None): if data is given, it gets written out to the temp file
2103 - data(None): if data is given, it gets written out to the temp file
2103 immediately, and the file is closed again."""
2104 immediately, and the file is closed again."""
2104
2105
2105 filename = tempfile.mktemp('.py','ipython_edit_')
2106 filename = tempfile.mktemp('.py','ipython_edit_')
2106 self.tempfiles.append(filename)
2107 self.tempfiles.append(filename)
2107
2108
2108 if data:
2109 if data:
2109 tmp_file = open(filename,'w')
2110 tmp_file = open(filename,'w')
2110 tmp_file.write(data)
2111 tmp_file.write(data)
2111 tmp_file.close()
2112 tmp_file.close()
2112 return filename
2113 return filename
2113
2114
2114 def write(self,data):
2115 def write(self,data):
2115 """Write a string to the default output"""
2116 """Write a string to the default output"""
2116 Term.cout.write(data)
2117 Term.cout.write(data)
2117
2118
2118 def write_err(self,data):
2119 def write_err(self,data):
2119 """Write a string to the default error output"""
2120 """Write a string to the default error output"""
2120 Term.cerr.write(data)
2121 Term.cerr.write(data)
2121
2122
2122 def exit(self):
2123 def exit(self):
2123 """Handle interactive exit.
2124 """Handle interactive exit.
2124
2125
2125 This method sets the exit_now attribute."""
2126 This method sets the exit_now attribute."""
2126
2127
2127 if self.rc.confirm_exit:
2128 if self.rc.confirm_exit:
2128 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2129 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2129 self.exit_now = True
2130 self.exit_now = True
2130 else:
2131 else:
2131 self.exit_now = True
2132 self.exit_now = True
2132 return self.exit_now
2133 return self.exit_now
2133
2134
2134 def safe_execfile(self,fname,*where,**kw):
2135 def safe_execfile(self,fname,*where,**kw):
2135 fname = os.path.expanduser(fname)
2136 fname = os.path.expanduser(fname)
2136
2137
2137 # find things also in current directory
2138 # find things also in current directory
2138 dname = os.path.dirname(fname)
2139 dname = os.path.dirname(fname)
2139 if not sys.path.count(dname):
2140 if not sys.path.count(dname):
2140 sys.path.append(dname)
2141 sys.path.append(dname)
2141
2142
2142 try:
2143 try:
2143 xfile = open(fname)
2144 xfile = open(fname)
2144 except:
2145 except:
2145 print >> Term.cerr, \
2146 print >> Term.cerr, \
2146 'Could not open file <%s> for safe execution.' % fname
2147 'Could not open file <%s> for safe execution.' % fname
2147 return None
2148 return None
2148
2149
2149 kw.setdefault('islog',0)
2150 kw.setdefault('islog',0)
2150 kw.setdefault('quiet',1)
2151 kw.setdefault('quiet',1)
2151 kw.setdefault('exit_ignore',0)
2152 kw.setdefault('exit_ignore',0)
2152 first = xfile.readline()
2153 first = xfile.readline()
2153 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2154 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2154 xfile.close()
2155 xfile.close()
2155 # line by line execution
2156 # line by line execution
2156 if first.startswith(loghead) or kw['islog']:
2157 if first.startswith(loghead) or kw['islog']:
2157 print 'Loading log file <%s> one line at a time...' % fname
2158 print 'Loading log file <%s> one line at a time...' % fname
2158 if kw['quiet']:
2159 if kw['quiet']:
2159 stdout_save = sys.stdout
2160 stdout_save = sys.stdout
2160 sys.stdout = StringIO.StringIO()
2161 sys.stdout = StringIO.StringIO()
2161 try:
2162 try:
2162 globs,locs = where[0:2]
2163 globs,locs = where[0:2]
2163 except:
2164 except:
2164 try:
2165 try:
2165 globs = locs = where[0]
2166 globs = locs = where[0]
2166 except:
2167 except:
2167 globs = locs = globals()
2168 globs = locs = globals()
2168 badblocks = []
2169 badblocks = []
2169
2170
2170 # we also need to identify indented blocks of code when replaying
2171 # we also need to identify indented blocks of code when replaying
2171 # logs and put them together before passing them to an exec
2172 # logs and put them together before passing them to an exec
2172 # statement. This takes a bit of regexp and look-ahead work in the
2173 # statement. This takes a bit of regexp and look-ahead work in the
2173 # file. It's easiest if we swallow the whole thing in memory
2174 # file. It's easiest if we swallow the whole thing in memory
2174 # first, and manually walk through the lines list moving the
2175 # first, and manually walk through the lines list moving the
2175 # counter ourselves.
2176 # counter ourselves.
2176 indent_re = re.compile('\s+\S')
2177 indent_re = re.compile('\s+\S')
2177 xfile = open(fname)
2178 xfile = open(fname)
2178 filelines = xfile.readlines()
2179 filelines = xfile.readlines()
2179 xfile.close()
2180 xfile.close()
2180 nlines = len(filelines)
2181 nlines = len(filelines)
2181 lnum = 0
2182 lnum = 0
2182 while lnum < nlines:
2183 while lnum < nlines:
2183 line = filelines[lnum]
2184 line = filelines[lnum]
2184 lnum += 1
2185 lnum += 1
2185 # don't re-insert logger status info into cache
2186 # don't re-insert logger status info into cache
2186 if line.startswith('#log#'):
2187 if line.startswith('#log#'):
2187 continue
2188 continue
2188 else:
2189 else:
2189 # build a block of code (maybe a single line) for execution
2190 # build a block of code (maybe a single line) for execution
2190 block = line
2191 block = line
2191 try:
2192 try:
2192 next = filelines[lnum] # lnum has already incremented
2193 next = filelines[lnum] # lnum has already incremented
2193 except:
2194 except:
2194 next = None
2195 next = None
2195 while next and indent_re.match(next):
2196 while next and indent_re.match(next):
2196 block += next
2197 block += next
2197 lnum += 1
2198 lnum += 1
2198 try:
2199 try:
2199 next = filelines[lnum]
2200 next = filelines[lnum]
2200 except:
2201 except:
2201 next = None
2202 next = None
2202 # now execute the block of one or more lines
2203 # now execute the block of one or more lines
2203 try:
2204 try:
2204 exec block in globs,locs
2205 exec block in globs,locs
2205 except SystemExit:
2206 except SystemExit:
2206 pass
2207 pass
2207 except:
2208 except:
2208 badblocks.append(block.rstrip())
2209 badblocks.append(block.rstrip())
2209 if kw['quiet']: # restore stdout
2210 if kw['quiet']: # restore stdout
2210 sys.stdout.close()
2211 sys.stdout.close()
2211 sys.stdout = stdout_save
2212 sys.stdout = stdout_save
2212 print 'Finished replaying log file <%s>' % fname
2213 print 'Finished replaying log file <%s>' % fname
2213 if badblocks:
2214 if badblocks:
2214 print >> sys.stderr, ('\nThe following lines/blocks in file '
2215 print >> sys.stderr, ('\nThe following lines/blocks in file '
2215 '<%s> reported errors:' % fname)
2216 '<%s> reported errors:' % fname)
2216
2217
2217 for badline in badblocks:
2218 for badline in badblocks:
2218 print >> sys.stderr, badline
2219 print >> sys.stderr, badline
2219 else: # regular file execution
2220 else: # regular file execution
2220 try:
2221 try:
2221 execfile(fname,*where)
2222 execfile(fname,*where)
2222 except SyntaxError:
2223 except SyntaxError:
2223 etype,evalue = sys.exc_info()[:2]
2224 etype,evalue = sys.exc_info()[:2]
2224 self.SyntaxTB(etype,evalue,[])
2225 self.SyntaxTB(etype,evalue,[])
2225 warn('Failure executing file: <%s>' % fname)
2226 warn('Failure executing file: <%s>' % fname)
2226 except SystemExit,status:
2227 except SystemExit,status:
2227 if not kw['exit_ignore']:
2228 if not kw['exit_ignore']:
2228 self.InteractiveTB()
2229 self.InteractiveTB()
2229 warn('Failure executing file: <%s>' % fname)
2230 warn('Failure executing file: <%s>' % fname)
2230 except:
2231 except:
2231 self.InteractiveTB()
2232 self.InteractiveTB()
2232 warn('Failure executing file: <%s>' % fname)
2233 warn('Failure executing file: <%s>' % fname)
2233
2234
2234 #************************* end of file <iplib.py> *****************************
2235 #************************* end of file <iplib.py> *****************************
@@ -1,5066 +1,5067 b''
1 2006-01-24 Ville Vainio <vivainio@gmail.com>
1 2006-01-24 Ville Vainio <vivainio@gmail.com>
2
2
3 * iplib.py, hooks.py: 'result_display' hook can return a non-None
3 * iplib.py, hooks.py: 'result_display' hook can return a non-None
4 value to manipulate resulting history entry.
4 value to manipulate resulting history entry.
5
5
6 * ipapi.py: Moved TryNext here from hooks.py, added
6 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
7 is_ipython_session() to determine whether we are running
7 to instance methods of IPApi class, to make extending an embedded
8 inside an ipython session.
8 IPython feasible. See ext_rehashdir.py for example usage.
9
9
10 * Merged 1071-1076 from banches/0.7.1
10 * Merged 1071-1076 from banches/0.7.1
11
11
12
12 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
13 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
13
14
14 * tools/release (daystamp): Fix build tools to use the new
15 * tools/release (daystamp): Fix build tools to use the new
15 eggsetup.py script to build lightweight eggs.
16 eggsetup.py script to build lightweight eggs.
16
17
17 * Applied changesets 1062 and 1064 before 0.7.1 release.
18 * Applied changesets 1062 and 1064 before 0.7.1 release.
18
19
19 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
20 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
20 see the raw input history (without conversions like %ls ->
21 see the raw input history (without conversions like %ls ->
21 ipmagic("ls")). After a request from W. Stein, SAGE
22 ipmagic("ls")). After a request from W. Stein, SAGE
22 (http://modular.ucsd.edu/sage) developer. This information is
23 (http://modular.ucsd.edu/sage) developer. This information is
23 stored in the input_hist_raw attribute of the IPython instance, so
24 stored in the input_hist_raw attribute of the IPython instance, so
24 developers can access it if needed (it's an InputList instance).
25 developers can access it if needed (it's an InputList instance).
25
26
26 * Versionstring = 0.7.2.svn
27 * Versionstring = 0.7.2.svn
27
28
28 * eggsetup.py: A separate script for constructing eggs, creates
29 * eggsetup.py: A separate script for constructing eggs, creates
29 proper launch scripts even on Windows (an .exe file in
30 proper launch scripts even on Windows (an .exe file in
30 \python24\scripts).
31 \python24\scripts).
31
32
32 * ipapi.py: launch_new_instance, launch entry point needed for the
33 * ipapi.py: launch_new_instance, launch entry point needed for the
33 egg.
34 egg.
34
35
35 2006-01-23 Ville Vainio <vivainio@gmail.com>
36 2006-01-23 Ville Vainio <vivainio@gmail.com>
36
37
37 * Added %cpaste magic for pasting python code
38 * Added %cpaste magic for pasting python code
38
39
39 2006-01-22 Ville Vainio <vivainio@gmail.com>
40 2006-01-22 Ville Vainio <vivainio@gmail.com>
40
41
41 * Merge from branches/0.7.1 into trunk, revs 1052-1057
42 * Merge from branches/0.7.1 into trunk, revs 1052-1057
42
43
43 * Versionstring = 0.7.2.svn
44 * Versionstring = 0.7.2.svn
44
45
45 * eggsetup.py: A separate script for constructing eggs, creates
46 * eggsetup.py: A separate script for constructing eggs, creates
46 proper launch scripts even on Windows (an .exe file in
47 proper launch scripts even on Windows (an .exe file in
47 \python24\scripts).
48 \python24\scripts).
48
49
49 * ipapi.py: launch_new_instance, launch entry point needed for the
50 * ipapi.py: launch_new_instance, launch entry point needed for the
50 egg.
51 egg.
51
52
52 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
53 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
53
54
54 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
55 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
55 %pfile foo would print the file for foo even if it was a binary.
56 %pfile foo would print the file for foo even if it was a binary.
56 Now, extensions '.so' and '.dll' are skipped.
57 Now, extensions '.so' and '.dll' are skipped.
57
58
58 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
59 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
59 bug, where macros would fail in all threaded modes. I'm not 100%
60 bug, where macros would fail in all threaded modes. I'm not 100%
60 sure, so I'm going to put out an rc instead of making a release
61 sure, so I'm going to put out an rc instead of making a release
61 today, and wait for feedback for at least a few days.
62 today, and wait for feedback for at least a few days.
62
63
63 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
64 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
64 it...) the handling of pasting external code with autoindent on.
65 it...) the handling of pasting external code with autoindent on.
65 To get out of a multiline input, the rule will appear for most
66 To get out of a multiline input, the rule will appear for most
66 users unchanged: two blank lines or change the indent level
67 users unchanged: two blank lines or change the indent level
67 proposed by IPython. But there is a twist now: you can
68 proposed by IPython. But there is a twist now: you can
68 add/subtract only *one or two spaces*. If you add/subtract three
69 add/subtract only *one or two spaces*. If you add/subtract three
69 or more (unless you completely delete the line), IPython will
70 or more (unless you completely delete the line), IPython will
70 accept that line, and you'll need to enter a second one of pure
71 accept that line, and you'll need to enter a second one of pure
71 whitespace. I know it sounds complicated, but I can't find a
72 whitespace. I know it sounds complicated, but I can't find a
72 different solution that covers all the cases, with the right
73 different solution that covers all the cases, with the right
73 heuristics. Hopefully in actual use, nobody will really notice
74 heuristics. Hopefully in actual use, nobody will really notice
74 all these strange rules and things will 'just work'.
75 all these strange rules and things will 'just work'.
75
76
76 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
77 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
77
78
78 * IPython/iplib.py (interact): catch exceptions which can be
79 * IPython/iplib.py (interact): catch exceptions which can be
79 triggered asynchronously by signal handlers. Thanks to an
80 triggered asynchronously by signal handlers. Thanks to an
80 automatic crash report, submitted by Colin Kingsley
81 automatic crash report, submitted by Colin Kingsley
81 <tercel-AT-gentoo.org>.
82 <tercel-AT-gentoo.org>.
82
83
83 2006-01-20 Ville Vainio <vivainio@gmail.com>
84 2006-01-20 Ville Vainio <vivainio@gmail.com>
84
85
85 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
86 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
86 (%rehashdir, very useful, try it out) of how to extend ipython
87 (%rehashdir, very useful, try it out) of how to extend ipython
87 with new magics. Also added Extensions dir to pythonpath to make
88 with new magics. Also added Extensions dir to pythonpath to make
88 importing extensions easy.
89 importing extensions easy.
89
90
90 * %store now complains when trying to store interactively declared
91 * %store now complains when trying to store interactively declared
91 classes / instances of those classes.
92 classes / instances of those classes.
92
93
93 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
94 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
94 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
95 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
95 if they exist, and ipy_user_conf.py with some defaults is created for
96 if they exist, and ipy_user_conf.py with some defaults is created for
96 the user.
97 the user.
97
98
98 * Startup rehashing done by the config file, not InterpreterExec.
99 * Startup rehashing done by the config file, not InterpreterExec.
99 This means system commands are available even without selecting the
100 This means system commands are available even without selecting the
100 pysh profile. It's the sensible default after all.
101 pysh profile. It's the sensible default after all.
101
102
102 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
103 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
103
104
104 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
105 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
105 multiline code with autoindent on working. But I am really not
106 multiline code with autoindent on working. But I am really not
106 sure, so this needs more testing. Will commit a debug-enabled
107 sure, so this needs more testing. Will commit a debug-enabled
107 version for now, while I test it some more, so that Ville and
108 version for now, while I test it some more, so that Ville and
108 others may also catch any problems. Also made
109 others may also catch any problems. Also made
109 self.indent_current_str() a method, to ensure that there's no
110 self.indent_current_str() a method, to ensure that there's no
110 chance of the indent space count and the corresponding string
111 chance of the indent space count and the corresponding string
111 falling out of sync. All code needing the string should just call
112 falling out of sync. All code needing the string should just call
112 the method.
113 the method.
113
114
114 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
115 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
115
116
116 * IPython/Magic.py (magic_edit): fix check for when users don't
117 * IPython/Magic.py (magic_edit): fix check for when users don't
117 save their output files, the try/except was in the wrong section.
118 save their output files, the try/except was in the wrong section.
118
119
119 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
120 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
120
121
121 * IPython/Magic.py (magic_run): fix __file__ global missing from
122 * IPython/Magic.py (magic_run): fix __file__ global missing from
122 script's namespace when executed via %run. After a report by
123 script's namespace when executed via %run. After a report by
123 Vivian.
124 Vivian.
124
125
125 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
126 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
126 when using python 2.4. The parent constructor changed in 2.4, and
127 when using python 2.4. The parent constructor changed in 2.4, and
127 we need to track it directly (we can't call it, as it messes up
128 we need to track it directly (we can't call it, as it messes up
128 readline and tab-completion inside our pdb would stop working).
129 readline and tab-completion inside our pdb would stop working).
129 After a bug report by R. Bernstein <rocky-AT-panix.com>.
130 After a bug report by R. Bernstein <rocky-AT-panix.com>.
130
131
131 2006-01-16 Ville Vainio <vivainio@gmail.com>
132 2006-01-16 Ville Vainio <vivainio@gmail.com>
132
133
133 * Ipython/magic.py:Reverted back to old %edit functionality
134 * Ipython/magic.py:Reverted back to old %edit functionality
134 that returns file contents on exit.
135 that returns file contents on exit.
135
136
136 * IPython/path.py: Added Jason Orendorff's "path" module to
137 * IPython/path.py: Added Jason Orendorff's "path" module to
137 IPython tree, http://www.jorendorff.com/articles/python/path/.
138 IPython tree, http://www.jorendorff.com/articles/python/path/.
138 You can get path objects conveniently through %sc, and !!, e.g.:
139 You can get path objects conveniently through %sc, and !!, e.g.:
139 sc files=ls
140 sc files=ls
140 for p in files.paths: # or files.p
141 for p in files.paths: # or files.p
141 print p,p.mtime
142 print p,p.mtime
142
143
143 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
144 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
144 now work again without considering the exclusion regexp -
145 now work again without considering the exclusion regexp -
145 hence, things like ',foo my/path' turn to 'foo("my/path")'
146 hence, things like ',foo my/path' turn to 'foo("my/path")'
146 instead of syntax error.
147 instead of syntax error.
147
148
148
149
149 2006-01-14 Ville Vainio <vivainio@gmail.com>
150 2006-01-14 Ville Vainio <vivainio@gmail.com>
150
151
151 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
152 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
152 ipapi decorators for python 2.4 users, options() provides access to rc
153 ipapi decorators for python 2.4 users, options() provides access to rc
153 data.
154 data.
154
155
155 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
156 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
156 as path separators (even on Linux ;-). Space character after
157 as path separators (even on Linux ;-). Space character after
157 backslash (as yielded by tab completer) is still space;
158 backslash (as yielded by tab completer) is still space;
158 "%cd long\ name" works as expected.
159 "%cd long\ name" works as expected.
159
160
160 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
161 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
161 as "chain of command", with priority. API stays the same,
162 as "chain of command", with priority. API stays the same,
162 TryNext exception raised by a hook function signals that
163 TryNext exception raised by a hook function signals that
163 current hook failed and next hook should try handling it, as
164 current hook failed and next hook should try handling it, as
164 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
165 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
165 requested configurable display hook, which is now implemented.
166 requested configurable display hook, which is now implemented.
166
167
167 2006-01-13 Ville Vainio <vivainio@gmail.com>
168 2006-01-13 Ville Vainio <vivainio@gmail.com>
168
169
169 * IPython/platutils*.py: platform specific utility functions,
170 * IPython/platutils*.py: platform specific utility functions,
170 so far only set_term_title is implemented (change terminal
171 so far only set_term_title is implemented (change terminal
171 label in windowing systems). %cd now changes the title to
172 label in windowing systems). %cd now changes the title to
172 current dir.
173 current dir.
173
174
174 * IPython/Release.py: Added myself to "authors" list,
175 * IPython/Release.py: Added myself to "authors" list,
175 had to create new files.
176 had to create new files.
176
177
177 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
178 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
178 shell escape; not a known bug but had potential to be one in the
179 shell escape; not a known bug but had potential to be one in the
179 future.
180 future.
180
181
181 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
182 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
182 extension API for IPython! See the module for usage example. Fix
183 extension API for IPython! See the module for usage example. Fix
183 OInspect for docstring-less magic functions.
184 OInspect for docstring-less magic functions.
184
185
185
186
186 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
187 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
187
188
188 * IPython/iplib.py (raw_input): temporarily deactivate all
189 * IPython/iplib.py (raw_input): temporarily deactivate all
189 attempts at allowing pasting of code with autoindent on. It
190 attempts at allowing pasting of code with autoindent on. It
190 introduced bugs (reported by Prabhu) and I can't seem to find a
191 introduced bugs (reported by Prabhu) and I can't seem to find a
191 robust combination which works in all cases. Will have to revisit
192 robust combination which works in all cases. Will have to revisit
192 later.
193 later.
193
194
194 * IPython/genutils.py: remove isspace() function. We've dropped
195 * IPython/genutils.py: remove isspace() function. We've dropped
195 2.2 compatibility, so it's OK to use the string method.
196 2.2 compatibility, so it's OK to use the string method.
196
197
197 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
198 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
198
199
199 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
200 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
200 matching what NOT to autocall on, to include all python binary
201 matching what NOT to autocall on, to include all python binary
201 operators (including things like 'and', 'or', 'is' and 'in').
202 operators (including things like 'and', 'or', 'is' and 'in').
202 Prompted by a bug report on 'foo & bar', but I realized we had
203 Prompted by a bug report on 'foo & bar', but I realized we had
203 many more potential bug cases with other operators. The regexp is
204 many more potential bug cases with other operators. The regexp is
204 self.re_exclude_auto, it's fairly commented.
205 self.re_exclude_auto, it's fairly commented.
205
206
206 2006-01-12 Ville Vainio <vivainio@gmail.com>
207 2006-01-12 Ville Vainio <vivainio@gmail.com>
207
208
208 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
209 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
209 Prettified and hardened string/backslash quoting with ipsystem(),
210 Prettified and hardened string/backslash quoting with ipsystem(),
210 ipalias() and ipmagic(). Now even \ characters are passed to
211 ipalias() and ipmagic(). Now even \ characters are passed to
211 %magics, !shell escapes and aliases exactly as they are in the
212 %magics, !shell escapes and aliases exactly as they are in the
212 ipython command line. Should improve backslash experience,
213 ipython command line. Should improve backslash experience,
213 particularly in Windows (path delimiter for some commands that
214 particularly in Windows (path delimiter for some commands that
214 won't understand '/'), but Unix benefits as well (regexps). %cd
215 won't understand '/'), but Unix benefits as well (regexps). %cd
215 magic still doesn't support backslash path delimiters, though. Also
216 magic still doesn't support backslash path delimiters, though. Also
216 deleted all pretense of supporting multiline command strings in
217 deleted all pretense of supporting multiline command strings in
217 !system or %magic commands. Thanks to Jerry McRae for suggestions.
218 !system or %magic commands. Thanks to Jerry McRae for suggestions.
218
219
219 * doc/build_doc_instructions.txt added. Documentation on how to
220 * doc/build_doc_instructions.txt added. Documentation on how to
220 use doc/update_manual.py, added yesterday. Both files contributed
221 use doc/update_manual.py, added yesterday. Both files contributed
221 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
222 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
222 doc/*.sh for deprecation at a later date.
223 doc/*.sh for deprecation at a later date.
223
224
224 * /ipython.py Added ipython.py to root directory for
225 * /ipython.py Added ipython.py to root directory for
225 zero-installation (tar xzvf ipython.tgz; cd ipython; python
226 zero-installation (tar xzvf ipython.tgz; cd ipython; python
226 ipython.py) and development convenience (no need to kee doing
227 ipython.py) and development convenience (no need to kee doing
227 "setup.py install" between changes).
228 "setup.py install" between changes).
228
229
229 * Made ! and !! shell escapes work (again) in multiline expressions:
230 * Made ! and !! shell escapes work (again) in multiline expressions:
230 if 1:
231 if 1:
231 !ls
232 !ls
232 !!ls
233 !!ls
233
234
234 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
235 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
235
236
236 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
237 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
237 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
238 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
238 module in case-insensitive installation. Was causing crashes
239 module in case-insensitive installation. Was causing crashes
239 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
240 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
240
241
241 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
242 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
242 <marienz-AT-gentoo.org>, closes
243 <marienz-AT-gentoo.org>, closes
243 http://www.scipy.net/roundup/ipython/issue51.
244 http://www.scipy.net/roundup/ipython/issue51.
244
245
245 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
246 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
246
247
247 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the
248 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the
248 problem of excessive CPU usage under *nix and keyboard lag under
249 problem of excessive CPU usage under *nix and keyboard lag under
249 win32.
250 win32.
250
251
251 2006-01-10 *** Released version 0.7.0
252 2006-01-10 *** Released version 0.7.0
252
253
253 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
254 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
254
255
255 * IPython/Release.py (revision): tag version number to 0.7.0,
256 * IPython/Release.py (revision): tag version number to 0.7.0,
256 ready for release.
257 ready for release.
257
258
258 * IPython/Magic.py (magic_edit): Add print statement to %edit so
259 * IPython/Magic.py (magic_edit): Add print statement to %edit so
259 it informs the user of the name of the temp. file used. This can
260 it informs the user of the name of the temp. file used. This can
260 help if you decide later to reuse that same file, so you know
261 help if you decide later to reuse that same file, so you know
261 where to copy the info from.
262 where to copy the info from.
262
263
263 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
264 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
264
265
265 * setup_bdist_egg.py: little script to build an egg. Added
266 * setup_bdist_egg.py: little script to build an egg. Added
266 support in the release tools as well.
267 support in the release tools as well.
267
268
268 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
269 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
269
270
270 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
271 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
271 version selection (new -wxversion command line and ipythonrc
272 version selection (new -wxversion command line and ipythonrc
272 parameter). Patch contributed by Arnd Baecker
273 parameter). Patch contributed by Arnd Baecker
273 <arnd.baecker-AT-web.de>.
274 <arnd.baecker-AT-web.de>.
274
275
275 * IPython/iplib.py (embed_mainloop): fix tab-completion in
276 * IPython/iplib.py (embed_mainloop): fix tab-completion in
276 embedded instances, for variables defined at the interactive
277 embedded instances, for variables defined at the interactive
277 prompt of the embedded ipython. Reported by Arnd.
278 prompt of the embedded ipython. Reported by Arnd.
278
279
279 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
280 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
280 it can be used as a (stateful) toggle, or with a direct parameter.
281 it can be used as a (stateful) toggle, or with a direct parameter.
281
282
282 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
283 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
283 could be triggered in certain cases and cause the traceback
284 could be triggered in certain cases and cause the traceback
284 printer not to work.
285 printer not to work.
285
286
286 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
287 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
287
288
288 * IPython/iplib.py (_should_recompile): Small fix, closes
289 * IPython/iplib.py (_should_recompile): Small fix, closes
289 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
290 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
290
291
291 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
292 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
292
293
293 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
294 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
294 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
295 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
295 Moad for help with tracking it down.
296 Moad for help with tracking it down.
296
297
297 * IPython/iplib.py (handle_auto): fix autocall handling for
298 * IPython/iplib.py (handle_auto): fix autocall handling for
298 objects which support BOTH __getitem__ and __call__ (so that f [x]
299 objects which support BOTH __getitem__ and __call__ (so that f [x]
299 is left alone, instead of becoming f([x]) automatically).
300 is left alone, instead of becoming f([x]) automatically).
300
301
301 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
302 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
302 Ville's patch.
303 Ville's patch.
303
304
304 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
305 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
305
306
306 * IPython/iplib.py (handle_auto): changed autocall semantics to
307 * IPython/iplib.py (handle_auto): changed autocall semantics to
307 include 'smart' mode, where the autocall transformation is NOT
308 include 'smart' mode, where the autocall transformation is NOT
308 applied if there are no arguments on the line. This allows you to
309 applied if there are no arguments on the line. This allows you to
309 just type 'foo' if foo is a callable to see its internal form,
310 just type 'foo' if foo is a callable to see its internal form,
310 instead of having it called with no arguments (typically a
311 instead of having it called with no arguments (typically a
311 mistake). The old 'full' autocall still exists: for that, you
312 mistake). The old 'full' autocall still exists: for that, you
312 need to set the 'autocall' parameter to 2 in your ipythonrc file.
313 need to set the 'autocall' parameter to 2 in your ipythonrc file.
313
314
314 * IPython/completer.py (Completer.attr_matches): add
315 * IPython/completer.py (Completer.attr_matches): add
315 tab-completion support for Enthoughts' traits. After a report by
316 tab-completion support for Enthoughts' traits. After a report by
316 Arnd and a patch by Prabhu.
317 Arnd and a patch by Prabhu.
317
318
318 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
319 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
319
320
320 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
321 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
321 Schmolck's patch to fix inspect.getinnerframes().
322 Schmolck's patch to fix inspect.getinnerframes().
322
323
323 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
324 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
324 for embedded instances, regarding handling of namespaces and items
325 for embedded instances, regarding handling of namespaces and items
325 added to the __builtin__ one. Multiple embedded instances and
326 added to the __builtin__ one. Multiple embedded instances and
326 recursive embeddings should work better now (though I'm not sure
327 recursive embeddings should work better now (though I'm not sure
327 I've got all the corner cases fixed, that code is a bit of a brain
328 I've got all the corner cases fixed, that code is a bit of a brain
328 twister).
329 twister).
329
330
330 * IPython/Magic.py (magic_edit): added support to edit in-memory
331 * IPython/Magic.py (magic_edit): added support to edit in-memory
331 macros (automatically creates the necessary temp files). %edit
332 macros (automatically creates the necessary temp files). %edit
332 also doesn't return the file contents anymore, it's just noise.
333 also doesn't return the file contents anymore, it's just noise.
333
334
334 * IPython/completer.py (Completer.attr_matches): revert change to
335 * IPython/completer.py (Completer.attr_matches): revert change to
335 complete only on attributes listed in __all__. I realized it
336 complete only on attributes listed in __all__. I realized it
336 cripples the tab-completion system as a tool for exploring the
337 cripples the tab-completion system as a tool for exploring the
337 internals of unknown libraries (it renders any non-__all__
338 internals of unknown libraries (it renders any non-__all__
338 attribute off-limits). I got bit by this when trying to see
339 attribute off-limits). I got bit by this when trying to see
339 something inside the dis module.
340 something inside the dis module.
340
341
341 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
342 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
342
343
343 * IPython/iplib.py (InteractiveShell.__init__): add .meta
344 * IPython/iplib.py (InteractiveShell.__init__): add .meta
344 namespace for users and extension writers to hold data in. This
345 namespace for users and extension writers to hold data in. This
345 follows the discussion in
346 follows the discussion in
346 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
347 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
347
348
348 * IPython/completer.py (IPCompleter.complete): small patch to help
349 * IPython/completer.py (IPCompleter.complete): small patch to help
349 tab-completion under Emacs, after a suggestion by John Barnard
350 tab-completion under Emacs, after a suggestion by John Barnard
350 <barnarj-AT-ccf.org>.
351 <barnarj-AT-ccf.org>.
351
352
352 * IPython/Magic.py (Magic.extract_input_slices): added support for
353 * IPython/Magic.py (Magic.extract_input_slices): added support for
353 the slice notation in magics to use N-M to represent numbers N...M
354 the slice notation in magics to use N-M to represent numbers N...M
354 (closed endpoints). This is used by %macro and %save.
355 (closed endpoints). This is used by %macro and %save.
355
356
356 * IPython/completer.py (Completer.attr_matches): for modules which
357 * IPython/completer.py (Completer.attr_matches): for modules which
357 define __all__, complete only on those. After a patch by Jeffrey
358 define __all__, complete only on those. After a patch by Jeffrey
358 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
359 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
359 speed up this routine.
360 speed up this routine.
360
361
361 * IPython/Logger.py (Logger.log): fix a history handling bug. I
362 * IPython/Logger.py (Logger.log): fix a history handling bug. I
362 don't know if this is the end of it, but the behavior now is
363 don't know if this is the end of it, but the behavior now is
363 certainly much more correct. Note that coupled with macros,
364 certainly much more correct. Note that coupled with macros,
364 slightly surprising (at first) behavior may occur: a macro will in
365 slightly surprising (at first) behavior may occur: a macro will in
365 general expand to multiple lines of input, so upon exiting, the
366 general expand to multiple lines of input, so upon exiting, the
366 in/out counters will both be bumped by the corresponding amount
367 in/out counters will both be bumped by the corresponding amount
367 (as if the macro's contents had been typed interactively). Typing
368 (as if the macro's contents had been typed interactively). Typing
368 %hist will reveal the intermediate (silently processed) lines.
369 %hist will reveal the intermediate (silently processed) lines.
369
370
370 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
371 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
371 pickle to fail (%run was overwriting __main__ and not restoring
372 pickle to fail (%run was overwriting __main__ and not restoring
372 it, but pickle relies on __main__ to operate).
373 it, but pickle relies on __main__ to operate).
373
374
374 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
375 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
375 using properties, but forgot to make the main InteractiveShell
376 using properties, but forgot to make the main InteractiveShell
376 class a new-style class. Properties fail silently, and
377 class a new-style class. Properties fail silently, and
377 misteriously, with old-style class (getters work, but
378 misteriously, with old-style class (getters work, but
378 setters don't do anything).
379 setters don't do anything).
379
380
380 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
381 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
381
382
382 * IPython/Magic.py (magic_history): fix history reporting bug (I
383 * IPython/Magic.py (magic_history): fix history reporting bug (I
383 know some nasties are still there, I just can't seem to find a
384 know some nasties are still there, I just can't seem to find a
384 reproducible test case to track them down; the input history is
385 reproducible test case to track them down; the input history is
385 falling out of sync...)
386 falling out of sync...)
386
387
387 * IPython/iplib.py (handle_shell_escape): fix bug where both
388 * IPython/iplib.py (handle_shell_escape): fix bug where both
388 aliases and system accesses where broken for indented code (such
389 aliases and system accesses where broken for indented code (such
389 as loops).
390 as loops).
390
391
391 * IPython/genutils.py (shell): fix small but critical bug for
392 * IPython/genutils.py (shell): fix small but critical bug for
392 win32 system access.
393 win32 system access.
393
394
394 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
395 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
395
396
396 * IPython/iplib.py (showtraceback): remove use of the
397 * IPython/iplib.py (showtraceback): remove use of the
397 sys.last_{type/value/traceback} structures, which are non
398 sys.last_{type/value/traceback} structures, which are non
398 thread-safe.
399 thread-safe.
399 (_prefilter): change control flow to ensure that we NEVER
400 (_prefilter): change control flow to ensure that we NEVER
400 introspect objects when autocall is off. This will guarantee that
401 introspect objects when autocall is off. This will guarantee that
401 having an input line of the form 'x.y', where access to attribute
402 having an input line of the form 'x.y', where access to attribute
402 'y' has side effects, doesn't trigger the side effect TWICE. It
403 'y' has side effects, doesn't trigger the side effect TWICE. It
403 is important to note that, with autocall on, these side effects
404 is important to note that, with autocall on, these side effects
404 can still happen.
405 can still happen.
405 (ipsystem): new builtin, to complete the ip{magic/alias/system}
406 (ipsystem): new builtin, to complete the ip{magic/alias/system}
406 trio. IPython offers these three kinds of special calls which are
407 trio. IPython offers these three kinds of special calls which are
407 not python code, and it's a good thing to have their call method
408 not python code, and it's a good thing to have their call method
408 be accessible as pure python functions (not just special syntax at
409 be accessible as pure python functions (not just special syntax at
409 the command line). It gives us a better internal implementation
410 the command line). It gives us a better internal implementation
410 structure, as well as exposing these for user scripting more
411 structure, as well as exposing these for user scripting more
411 cleanly.
412 cleanly.
412
413
413 * IPython/macro.py (Macro.__init__): moved macros to a standalone
414 * IPython/macro.py (Macro.__init__): moved macros to a standalone
414 file. Now that they'll be more likely to be used with the
415 file. Now that they'll be more likely to be used with the
415 persistance system (%store), I want to make sure their module path
416 persistance system (%store), I want to make sure their module path
416 doesn't change in the future, so that we don't break things for
417 doesn't change in the future, so that we don't break things for
417 users' persisted data.
418 users' persisted data.
418
419
419 * IPython/iplib.py (autoindent_update): move indentation
420 * IPython/iplib.py (autoindent_update): move indentation
420 management into the _text_ processing loop, not the keyboard
421 management into the _text_ processing loop, not the keyboard
421 interactive one. This is necessary to correctly process non-typed
422 interactive one. This is necessary to correctly process non-typed
422 multiline input (such as macros).
423 multiline input (such as macros).
423
424
424 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
425 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
425 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
426 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
426 which was producing problems in the resulting manual.
427 which was producing problems in the resulting manual.
427 (magic_whos): improve reporting of instances (show their class,
428 (magic_whos): improve reporting of instances (show their class,
428 instead of simply printing 'instance' which isn't terribly
429 instead of simply printing 'instance' which isn't terribly
429 informative).
430 informative).
430
431
431 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
432 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
432 (minor mods) to support network shares under win32.
433 (minor mods) to support network shares under win32.
433
434
434 * IPython/winconsole.py (get_console_size): add new winconsole
435 * IPython/winconsole.py (get_console_size): add new winconsole
435 module and fixes to page_dumb() to improve its behavior under
436 module and fixes to page_dumb() to improve its behavior under
436 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
437 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
437
438
438 * IPython/Magic.py (Macro): simplified Macro class to just
439 * IPython/Magic.py (Macro): simplified Macro class to just
439 subclass list. We've had only 2.2 compatibility for a very long
440 subclass list. We've had only 2.2 compatibility for a very long
440 time, yet I was still avoiding subclassing the builtin types. No
441 time, yet I was still avoiding subclassing the builtin types. No
441 more (I'm also starting to use properties, though I won't shift to
442 more (I'm also starting to use properties, though I won't shift to
442 2.3-specific features quite yet).
443 2.3-specific features quite yet).
443 (magic_store): added Ville's patch for lightweight variable
444 (magic_store): added Ville's patch for lightweight variable
444 persistence, after a request on the user list by Matt Wilkie
445 persistence, after a request on the user list by Matt Wilkie
445 <maphew-AT-gmail.com>. The new %store magic's docstring has full
446 <maphew-AT-gmail.com>. The new %store magic's docstring has full
446 details.
447 details.
447
448
448 * IPython/iplib.py (InteractiveShell.post_config_initialization):
449 * IPython/iplib.py (InteractiveShell.post_config_initialization):
449 changed the default logfile name from 'ipython.log' to
450 changed the default logfile name from 'ipython.log' to
450 'ipython_log.py'. These logs are real python files, and now that
451 'ipython_log.py'. These logs are real python files, and now that
451 we have much better multiline support, people are more likely to
452 we have much better multiline support, people are more likely to
452 want to use them as such. Might as well name them correctly.
453 want to use them as such. Might as well name them correctly.
453
454
454 * IPython/Magic.py: substantial cleanup. While we can't stop
455 * IPython/Magic.py: substantial cleanup. While we can't stop
455 using magics as mixins, due to the existing customizations 'out
456 using magics as mixins, due to the existing customizations 'out
456 there' which rely on the mixin naming conventions, at least I
457 there' which rely on the mixin naming conventions, at least I
457 cleaned out all cross-class name usage. So once we are OK with
458 cleaned out all cross-class name usage. So once we are OK with
458 breaking compatibility, the two systems can be separated.
459 breaking compatibility, the two systems can be separated.
459
460
460 * IPython/Logger.py: major cleanup. This one is NOT a mixin
461 * IPython/Logger.py: major cleanup. This one is NOT a mixin
461 anymore, and the class is a fair bit less hideous as well. New
462 anymore, and the class is a fair bit less hideous as well. New
462 features were also introduced: timestamping of input, and logging
463 features were also introduced: timestamping of input, and logging
463 of output results. These are user-visible with the -t and -o
464 of output results. These are user-visible with the -t and -o
464 options to %logstart. Closes
465 options to %logstart. Closes
465 http://www.scipy.net/roundup/ipython/issue11 and a request by
466 http://www.scipy.net/roundup/ipython/issue11 and a request by
466 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
467 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
467
468
468 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
469 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
469
470
470 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
471 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
471 better hadnle backslashes in paths. See the thread 'More Windows
472 better hadnle backslashes in paths. See the thread 'More Windows
472 questions part 2 - \/ characters revisited' on the iypthon user
473 questions part 2 - \/ characters revisited' on the iypthon user
473 list:
474 list:
474 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
475 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
475
476
476 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
477 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
477
478
478 (InteractiveShell.__init__): change threaded shells to not use the
479 (InteractiveShell.__init__): change threaded shells to not use the
479 ipython crash handler. This was causing more problems than not,
480 ipython crash handler. This was causing more problems than not,
480 as exceptions in the main thread (GUI code, typically) would
481 as exceptions in the main thread (GUI code, typically) would
481 always show up as a 'crash', when they really weren't.
482 always show up as a 'crash', when they really weren't.
482
483
483 The colors and exception mode commands (%colors/%xmode) have been
484 The colors and exception mode commands (%colors/%xmode) have been
484 synchronized to also take this into account, so users can get
485 synchronized to also take this into account, so users can get
485 verbose exceptions for their threaded code as well. I also added
486 verbose exceptions for their threaded code as well. I also added
486 support for activating pdb inside this exception handler as well,
487 support for activating pdb inside this exception handler as well,
487 so now GUI authors can use IPython's enhanced pdb at runtime.
488 so now GUI authors can use IPython's enhanced pdb at runtime.
488
489
489 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
490 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
490 true by default, and add it to the shipped ipythonrc file. Since
491 true by default, and add it to the shipped ipythonrc file. Since
491 this asks the user before proceeding, I think it's OK to make it
492 this asks the user before proceeding, I think it's OK to make it
492 true by default.
493 true by default.
493
494
494 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
495 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
495 of the previous special-casing of input in the eval loop. I think
496 of the previous special-casing of input in the eval loop. I think
496 this is cleaner, as they really are commands and shouldn't have
497 this is cleaner, as they really are commands and shouldn't have
497 a special role in the middle of the core code.
498 a special role in the middle of the core code.
498
499
499 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
500 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
500
501
501 * IPython/iplib.py (edit_syntax_error): added support for
502 * IPython/iplib.py (edit_syntax_error): added support for
502 automatically reopening the editor if the file had a syntax error
503 automatically reopening the editor if the file had a syntax error
503 in it. Thanks to scottt who provided the patch at:
504 in it. Thanks to scottt who provided the patch at:
504 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
505 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
505 version committed).
506 version committed).
506
507
507 * IPython/iplib.py (handle_normal): add suport for multi-line
508 * IPython/iplib.py (handle_normal): add suport for multi-line
508 input with emtpy lines. This fixes
509 input with emtpy lines. This fixes
509 http://www.scipy.net/roundup/ipython/issue43 and a similar
510 http://www.scipy.net/roundup/ipython/issue43 and a similar
510 discussion on the user list.
511 discussion on the user list.
511
512
512 WARNING: a behavior change is necessarily introduced to support
513 WARNING: a behavior change is necessarily introduced to support
513 blank lines: now a single blank line with whitespace does NOT
514 blank lines: now a single blank line with whitespace does NOT
514 break the input loop, which means that when autoindent is on, by
515 break the input loop, which means that when autoindent is on, by
515 default hitting return on the next (indented) line does NOT exit.
516 default hitting return on the next (indented) line does NOT exit.
516
517
517 Instead, to exit a multiline input you can either have:
518 Instead, to exit a multiline input you can either have:
518
519
519 - TWO whitespace lines (just hit return again), or
520 - TWO whitespace lines (just hit return again), or
520 - a single whitespace line of a different length than provided
521 - a single whitespace line of a different length than provided
521 by the autoindent (add or remove a space).
522 by the autoindent (add or remove a space).
522
523
523 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
524 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
524 module to better organize all readline-related functionality.
525 module to better organize all readline-related functionality.
525 I've deleted FlexCompleter and put all completion clases here.
526 I've deleted FlexCompleter and put all completion clases here.
526
527
527 * IPython/iplib.py (raw_input): improve indentation management.
528 * IPython/iplib.py (raw_input): improve indentation management.
528 It is now possible to paste indented code with autoindent on, and
529 It is now possible to paste indented code with autoindent on, and
529 the code is interpreted correctly (though it still looks bad on
530 the code is interpreted correctly (though it still looks bad on
530 screen, due to the line-oriented nature of ipython).
531 screen, due to the line-oriented nature of ipython).
531 (MagicCompleter.complete): change behavior so that a TAB key on an
532 (MagicCompleter.complete): change behavior so that a TAB key on an
532 otherwise empty line actually inserts a tab, instead of completing
533 otherwise empty line actually inserts a tab, instead of completing
533 on the entire global namespace. This makes it easier to use the
534 on the entire global namespace. This makes it easier to use the
534 TAB key for indentation. After a request by Hans Meine
535 TAB key for indentation. After a request by Hans Meine
535 <hans_meine-AT-gmx.net>
536 <hans_meine-AT-gmx.net>
536 (_prefilter): add support so that typing plain 'exit' or 'quit'
537 (_prefilter): add support so that typing plain 'exit' or 'quit'
537 does a sensible thing. Originally I tried to deviate as little as
538 does a sensible thing. Originally I tried to deviate as little as
538 possible from the default python behavior, but even that one may
539 possible from the default python behavior, but even that one may
539 change in this direction (thread on python-dev to that effect).
540 change in this direction (thread on python-dev to that effect).
540 Regardless, ipython should do the right thing even if CPython's
541 Regardless, ipython should do the right thing even if CPython's
541 '>>>' prompt doesn't.
542 '>>>' prompt doesn't.
542 (InteractiveShell): removed subclassing code.InteractiveConsole
543 (InteractiveShell): removed subclassing code.InteractiveConsole
543 class. By now we'd overridden just about all of its methods: I've
544 class. By now we'd overridden just about all of its methods: I've
544 copied the remaining two over, and now ipython is a standalone
545 copied the remaining two over, and now ipython is a standalone
545 class. This will provide a clearer picture for the chainsaw
546 class. This will provide a clearer picture for the chainsaw
546 branch refactoring.
547 branch refactoring.
547
548
548 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
549 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
549
550
550 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
551 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
551 failures for objects which break when dir() is called on them.
552 failures for objects which break when dir() is called on them.
552
553
553 * IPython/FlexCompleter.py (Completer.__init__): Added support for
554 * IPython/FlexCompleter.py (Completer.__init__): Added support for
554 distinct local and global namespaces in the completer API. This
555 distinct local and global namespaces in the completer API. This
555 change allows us top properly handle completion with distinct
556 change allows us top properly handle completion with distinct
556 scopes, including in embedded instances (this had never really
557 scopes, including in embedded instances (this had never really
557 worked correctly).
558 worked correctly).
558
559
559 Note: this introduces a change in the constructor for
560 Note: this introduces a change in the constructor for
560 MagicCompleter, as a new global_namespace parameter is now the
561 MagicCompleter, as a new global_namespace parameter is now the
561 second argument (the others were bumped one position).
562 second argument (the others were bumped one position).
562
563
563 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
564 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
564
565
565 * IPython/iplib.py (embed_mainloop): fix tab-completion in
566 * IPython/iplib.py (embed_mainloop): fix tab-completion in
566 embedded instances (which can be done now thanks to Vivian's
567 embedded instances (which can be done now thanks to Vivian's
567 frame-handling fixes for pdb).
568 frame-handling fixes for pdb).
568 (InteractiveShell.__init__): Fix namespace handling problem in
569 (InteractiveShell.__init__): Fix namespace handling problem in
569 embedded instances. We were overwriting __main__ unconditionally,
570 embedded instances. We were overwriting __main__ unconditionally,
570 and this should only be done for 'full' (non-embedded) IPython;
571 and this should only be done for 'full' (non-embedded) IPython;
571 embedded instances must respect the caller's __main__. Thanks to
572 embedded instances must respect the caller's __main__. Thanks to
572 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
573 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
573
574
574 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
575 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
575
576
576 * setup.py: added download_url to setup(). This registers the
577 * setup.py: added download_url to setup(). This registers the
577 download address at PyPI, which is not only useful to humans
578 download address at PyPI, which is not only useful to humans
578 browsing the site, but is also picked up by setuptools (the Eggs
579 browsing the site, but is also picked up by setuptools (the Eggs
579 machinery). Thanks to Ville and R. Kern for the info/discussion
580 machinery). Thanks to Ville and R. Kern for the info/discussion
580 on this.
581 on this.
581
582
582 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
583 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
583
584
584 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
585 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
585 This brings a lot of nice functionality to the pdb mode, which now
586 This brings a lot of nice functionality to the pdb mode, which now
586 has tab-completion, syntax highlighting, and better stack handling
587 has tab-completion, syntax highlighting, and better stack handling
587 than before. Many thanks to Vivian De Smedt
588 than before. Many thanks to Vivian De Smedt
588 <vivian-AT-vdesmedt.com> for the original patches.
589 <vivian-AT-vdesmedt.com> for the original patches.
589
590
590 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
591 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
591
592
592 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
593 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
593 sequence to consistently accept the banner argument. The
594 sequence to consistently accept the banner argument. The
594 inconsistency was tripping SAGE, thanks to Gary Zablackis
595 inconsistency was tripping SAGE, thanks to Gary Zablackis
595 <gzabl-AT-yahoo.com> for the report.
596 <gzabl-AT-yahoo.com> for the report.
596
597
597 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
598 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
598
599
599 * IPython/iplib.py (InteractiveShell.post_config_initialization):
600 * IPython/iplib.py (InteractiveShell.post_config_initialization):
600 Fix bug where a naked 'alias' call in the ipythonrc file would
601 Fix bug where a naked 'alias' call in the ipythonrc file would
601 cause a crash. Bug reported by Jorgen Stenarson.
602 cause a crash. Bug reported by Jorgen Stenarson.
602
603
603 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
604 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
604
605
605 * IPython/ipmaker.py (make_IPython): cleanups which should improve
606 * IPython/ipmaker.py (make_IPython): cleanups which should improve
606 startup time.
607 startup time.
607
608
608 * IPython/iplib.py (runcode): my globals 'fix' for embedded
609 * IPython/iplib.py (runcode): my globals 'fix' for embedded
609 instances had introduced a bug with globals in normal code. Now
610 instances had introduced a bug with globals in normal code. Now
610 it's working in all cases.
611 it's working in all cases.
611
612
612 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
613 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
613 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
614 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
614 has been introduced to set the default case sensitivity of the
615 has been introduced to set the default case sensitivity of the
615 searches. Users can still select either mode at runtime on a
616 searches. Users can still select either mode at runtime on a
616 per-search basis.
617 per-search basis.
617
618
618 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
619 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
619
620
620 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
621 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
621 attributes in wildcard searches for subclasses. Modified version
622 attributes in wildcard searches for subclasses. Modified version
622 of a patch by Jorgen.
623 of a patch by Jorgen.
623
624
624 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
625 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
625
626
626 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
627 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
627 embedded instances. I added a user_global_ns attribute to the
628 embedded instances. I added a user_global_ns attribute to the
628 InteractiveShell class to handle this.
629 InteractiveShell class to handle this.
629
630
630 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
631 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
631
632
632 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
633 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
633 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
634 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
634 (reported under win32, but may happen also in other platforms).
635 (reported under win32, but may happen also in other platforms).
635 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
636 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
636
637
637 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
638 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
638
639
639 * IPython/Magic.py (magic_psearch): new support for wildcard
640 * IPython/Magic.py (magic_psearch): new support for wildcard
640 patterns. Now, typing ?a*b will list all names which begin with a
641 patterns. Now, typing ?a*b will list all names which begin with a
641 and end in b, for example. The %psearch magic has full
642 and end in b, for example. The %psearch magic has full
642 docstrings. Many thanks to JΓΆrgen Stenarson
643 docstrings. Many thanks to JΓΆrgen Stenarson
643 <jorgen.stenarson-AT-bostream.nu>, author of the patches
644 <jorgen.stenarson-AT-bostream.nu>, author of the patches
644 implementing this functionality.
645 implementing this functionality.
645
646
646 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
647 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
647
648
648 * Manual: fixed long-standing annoyance of double-dashes (as in
649 * Manual: fixed long-standing annoyance of double-dashes (as in
649 --prefix=~, for example) being stripped in the HTML version. This
650 --prefix=~, for example) being stripped in the HTML version. This
650 is a latex2html bug, but a workaround was provided. Many thanks
651 is a latex2html bug, but a workaround was provided. Many thanks
651 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
652 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
652 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
653 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
653 rolling. This seemingly small issue had tripped a number of users
654 rolling. This seemingly small issue had tripped a number of users
654 when first installing, so I'm glad to see it gone.
655 when first installing, so I'm glad to see it gone.
655
656
656 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
657 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
657
658
658 * IPython/Extensions/numeric_formats.py: fix missing import,
659 * IPython/Extensions/numeric_formats.py: fix missing import,
659 reported by Stephen Walton.
660 reported by Stephen Walton.
660
661
661 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
662 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
662
663
663 * IPython/demo.py: finish demo module, fully documented now.
664 * IPython/demo.py: finish demo module, fully documented now.
664
665
665 * IPython/genutils.py (file_read): simple little utility to read a
666 * IPython/genutils.py (file_read): simple little utility to read a
666 file and ensure it's closed afterwards.
667 file and ensure it's closed afterwards.
667
668
668 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
669 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
669
670
670 * IPython/demo.py (Demo.__init__): added support for individually
671 * IPython/demo.py (Demo.__init__): added support for individually
671 tagging blocks for automatic execution.
672 tagging blocks for automatic execution.
672
673
673 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
674 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
674 syntax-highlighted python sources, requested by John.
675 syntax-highlighted python sources, requested by John.
675
676
676 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
677 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
677
678
678 * IPython/demo.py (Demo.again): fix bug where again() blocks after
679 * IPython/demo.py (Demo.again): fix bug where again() blocks after
679 finishing.
680 finishing.
680
681
681 * IPython/genutils.py (shlex_split): moved from Magic to here,
682 * IPython/genutils.py (shlex_split): moved from Magic to here,
682 where all 2.2 compatibility stuff lives. I needed it for demo.py.
683 where all 2.2 compatibility stuff lives. I needed it for demo.py.
683
684
684 * IPython/demo.py (Demo.__init__): added support for silent
685 * IPython/demo.py (Demo.__init__): added support for silent
685 blocks, improved marks as regexps, docstrings written.
686 blocks, improved marks as regexps, docstrings written.
686 (Demo.__init__): better docstring, added support for sys.argv.
687 (Demo.__init__): better docstring, added support for sys.argv.
687
688
688 * IPython/genutils.py (marquee): little utility used by the demo
689 * IPython/genutils.py (marquee): little utility used by the demo
689 code, handy in general.
690 code, handy in general.
690
691
691 * IPython/demo.py (Demo.__init__): new class for interactive
692 * IPython/demo.py (Demo.__init__): new class for interactive
692 demos. Not documented yet, I just wrote it in a hurry for
693 demos. Not documented yet, I just wrote it in a hurry for
693 scipy'05. Will docstring later.
694 scipy'05. Will docstring later.
694
695
695 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
696 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
696
697
697 * IPython/Shell.py (sigint_handler): Drastic simplification which
698 * IPython/Shell.py (sigint_handler): Drastic simplification which
698 also seems to make Ctrl-C work correctly across threads! This is
699 also seems to make Ctrl-C work correctly across threads! This is
699 so simple, that I can't beleive I'd missed it before. Needs more
700 so simple, that I can't beleive I'd missed it before. Needs more
700 testing, though.
701 testing, though.
701 (KBINT): Never mind, revert changes. I'm sure I'd tried something
702 (KBINT): Never mind, revert changes. I'm sure I'd tried something
702 like this before...
703 like this before...
703
704
704 * IPython/genutils.py (get_home_dir): add protection against
705 * IPython/genutils.py (get_home_dir): add protection against
705 non-dirs in win32 registry.
706 non-dirs in win32 registry.
706
707
707 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
708 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
708 bug where dict was mutated while iterating (pysh crash).
709 bug where dict was mutated while iterating (pysh crash).
709
710
710 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
711 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
711
712
712 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
713 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
713 spurious newlines added by this routine. After a report by
714 spurious newlines added by this routine. After a report by
714 F. Mantegazza.
715 F. Mantegazza.
715
716
716 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
717 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
717
718
718 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
719 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
719 calls. These were a leftover from the GTK 1.x days, and can cause
720 calls. These were a leftover from the GTK 1.x days, and can cause
720 problems in certain cases (after a report by John Hunter).
721 problems in certain cases (after a report by John Hunter).
721
722
722 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
723 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
723 os.getcwd() fails at init time. Thanks to patch from David Remahl
724 os.getcwd() fails at init time. Thanks to patch from David Remahl
724 <chmod007-AT-mac.com>.
725 <chmod007-AT-mac.com>.
725 (InteractiveShell.__init__): prevent certain special magics from
726 (InteractiveShell.__init__): prevent certain special magics from
726 being shadowed by aliases. Closes
727 being shadowed by aliases. Closes
727 http://www.scipy.net/roundup/ipython/issue41.
728 http://www.scipy.net/roundup/ipython/issue41.
728
729
729 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
730 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
730
731
731 * IPython/iplib.py (InteractiveShell.complete): Added new
732 * IPython/iplib.py (InteractiveShell.complete): Added new
732 top-level completion method to expose the completion mechanism
733 top-level completion method to expose the completion mechanism
733 beyond readline-based environments.
734 beyond readline-based environments.
734
735
735 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
736 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
736
737
737 * tools/ipsvnc (svnversion): fix svnversion capture.
738 * tools/ipsvnc (svnversion): fix svnversion capture.
738
739
739 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
740 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
740 attribute to self, which was missing. Before, it was set by a
741 attribute to self, which was missing. Before, it was set by a
741 routine which in certain cases wasn't being called, so the
742 routine which in certain cases wasn't being called, so the
742 instance could end up missing the attribute. This caused a crash.
743 instance could end up missing the attribute. This caused a crash.
743 Closes http://www.scipy.net/roundup/ipython/issue40.
744 Closes http://www.scipy.net/roundup/ipython/issue40.
744
745
745 2005-08-16 Fernando Perez <fperez@colorado.edu>
746 2005-08-16 Fernando Perez <fperez@colorado.edu>
746
747
747 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
748 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
748 contains non-string attribute. Closes
749 contains non-string attribute. Closes
749 http://www.scipy.net/roundup/ipython/issue38.
750 http://www.scipy.net/roundup/ipython/issue38.
750
751
751 2005-08-14 Fernando Perez <fperez@colorado.edu>
752 2005-08-14 Fernando Perez <fperez@colorado.edu>
752
753
753 * tools/ipsvnc: Minor improvements, to add changeset info.
754 * tools/ipsvnc: Minor improvements, to add changeset info.
754
755
755 2005-08-12 Fernando Perez <fperez@colorado.edu>
756 2005-08-12 Fernando Perez <fperez@colorado.edu>
756
757
757 * IPython/iplib.py (runsource): remove self.code_to_run_src
758 * IPython/iplib.py (runsource): remove self.code_to_run_src
758 attribute. I realized this is nothing more than
759 attribute. I realized this is nothing more than
759 '\n'.join(self.buffer), and having the same data in two different
760 '\n'.join(self.buffer), and having the same data in two different
760 places is just asking for synchronization bugs. This may impact
761 places is just asking for synchronization bugs. This may impact
761 people who have custom exception handlers, so I need to warn
762 people who have custom exception handlers, so I need to warn
762 ipython-dev about it (F. Mantegazza may use them).
763 ipython-dev about it (F. Mantegazza may use them).
763
764
764 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
765 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
765
766
766 * IPython/genutils.py: fix 2.2 compatibility (generators)
767 * IPython/genutils.py: fix 2.2 compatibility (generators)
767
768
768 2005-07-18 Fernando Perez <fperez@colorado.edu>
769 2005-07-18 Fernando Perez <fperez@colorado.edu>
769
770
770 * IPython/genutils.py (get_home_dir): fix to help users with
771 * IPython/genutils.py (get_home_dir): fix to help users with
771 invalid $HOME under win32.
772 invalid $HOME under win32.
772
773
773 2005-07-17 Fernando Perez <fperez@colorado.edu>
774 2005-07-17 Fernando Perez <fperez@colorado.edu>
774
775
775 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
776 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
776 some old hacks and clean up a bit other routines; code should be
777 some old hacks and clean up a bit other routines; code should be
777 simpler and a bit faster.
778 simpler and a bit faster.
778
779
779 * IPython/iplib.py (interact): removed some last-resort attempts
780 * IPython/iplib.py (interact): removed some last-resort attempts
780 to survive broken stdout/stderr. That code was only making it
781 to survive broken stdout/stderr. That code was only making it
781 harder to abstract out the i/o (necessary for gui integration),
782 harder to abstract out the i/o (necessary for gui integration),
782 and the crashes it could prevent were extremely rare in practice
783 and the crashes it could prevent were extremely rare in practice
783 (besides being fully user-induced in a pretty violent manner).
784 (besides being fully user-induced in a pretty violent manner).
784
785
785 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
786 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
786 Nothing major yet, but the code is simpler to read; this should
787 Nothing major yet, but the code is simpler to read; this should
787 make it easier to do more serious modifications in the future.
788 make it easier to do more serious modifications in the future.
788
789
789 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
790 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
790 which broke in .15 (thanks to a report by Ville).
791 which broke in .15 (thanks to a report by Ville).
791
792
792 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
793 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
793 be quite correct, I know next to nothing about unicode). This
794 be quite correct, I know next to nothing about unicode). This
794 will allow unicode strings to be used in prompts, amongst other
795 will allow unicode strings to be used in prompts, amongst other
795 cases. It also will prevent ipython from crashing when unicode
796 cases. It also will prevent ipython from crashing when unicode
796 shows up unexpectedly in many places. If ascii encoding fails, we
797 shows up unexpectedly in many places. If ascii encoding fails, we
797 assume utf_8. Currently the encoding is not a user-visible
798 assume utf_8. Currently the encoding is not a user-visible
798 setting, though it could be made so if there is demand for it.
799 setting, though it could be made so if there is demand for it.
799
800
800 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
801 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
801
802
802 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
803 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
803
804
804 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
805 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
805
806
806 * IPython/genutils.py: Add 2.2 compatibility here, so all other
807 * IPython/genutils.py: Add 2.2 compatibility here, so all other
807 code can work transparently for 2.2/2.3.
808 code can work transparently for 2.2/2.3.
808
809
809 2005-07-16 Fernando Perez <fperez@colorado.edu>
810 2005-07-16 Fernando Perez <fperez@colorado.edu>
810
811
811 * IPython/ultraTB.py (ExceptionColors): Make a global variable
812 * IPython/ultraTB.py (ExceptionColors): Make a global variable
812 out of the color scheme table used for coloring exception
813 out of the color scheme table used for coloring exception
813 tracebacks. This allows user code to add new schemes at runtime.
814 tracebacks. This allows user code to add new schemes at runtime.
814 This is a minimally modified version of the patch at
815 This is a minimally modified version of the patch at
815 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
816 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
816 for the contribution.
817 for the contribution.
817
818
818 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
819 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
819 slightly modified version of the patch in
820 slightly modified version of the patch in
820 http://www.scipy.net/roundup/ipython/issue34, which also allows me
821 http://www.scipy.net/roundup/ipython/issue34, which also allows me
821 to remove the previous try/except solution (which was costlier).
822 to remove the previous try/except solution (which was costlier).
822 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
823 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
823
824
824 2005-06-08 Fernando Perez <fperez@colorado.edu>
825 2005-06-08 Fernando Perez <fperez@colorado.edu>
825
826
826 * IPython/iplib.py (write/write_err): Add methods to abstract all
827 * IPython/iplib.py (write/write_err): Add methods to abstract all
827 I/O a bit more.
828 I/O a bit more.
828
829
829 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
830 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
830 warning, reported by Aric Hagberg, fix by JD Hunter.
831 warning, reported by Aric Hagberg, fix by JD Hunter.
831
832
832 2005-06-02 *** Released version 0.6.15
833 2005-06-02 *** Released version 0.6.15
833
834
834 2005-06-01 Fernando Perez <fperez@colorado.edu>
835 2005-06-01 Fernando Perez <fperez@colorado.edu>
835
836
836 * IPython/iplib.py (MagicCompleter.file_matches): Fix
837 * IPython/iplib.py (MagicCompleter.file_matches): Fix
837 tab-completion of filenames within open-quoted strings. Note that
838 tab-completion of filenames within open-quoted strings. Note that
838 this requires that in ~/.ipython/ipythonrc, users change the
839 this requires that in ~/.ipython/ipythonrc, users change the
839 readline delimiters configuration to read:
840 readline delimiters configuration to read:
840
841
841 readline_remove_delims -/~
842 readline_remove_delims -/~
842
843
843
844
844 2005-05-31 *** Released version 0.6.14
845 2005-05-31 *** Released version 0.6.14
845
846
846 2005-05-29 Fernando Perez <fperez@colorado.edu>
847 2005-05-29 Fernando Perez <fperez@colorado.edu>
847
848
848 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
849 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
849 with files not on the filesystem. Reported by Eliyahu Sandler
850 with files not on the filesystem. Reported by Eliyahu Sandler
850 <eli@gondolin.net>
851 <eli@gondolin.net>
851
852
852 2005-05-22 Fernando Perez <fperez@colorado.edu>
853 2005-05-22 Fernando Perez <fperez@colorado.edu>
853
854
854 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
855 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
855 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
856 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
856
857
857 2005-05-19 Fernando Perez <fperez@colorado.edu>
858 2005-05-19 Fernando Perez <fperez@colorado.edu>
858
859
859 * IPython/iplib.py (safe_execfile): close a file which could be
860 * IPython/iplib.py (safe_execfile): close a file which could be
860 left open (causing problems in win32, which locks open files).
861 left open (causing problems in win32, which locks open files).
861 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
862 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
862
863
863 2005-05-18 Fernando Perez <fperez@colorado.edu>
864 2005-05-18 Fernando Perez <fperez@colorado.edu>
864
865
865 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
866 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
866 keyword arguments correctly to safe_execfile().
867 keyword arguments correctly to safe_execfile().
867
868
868 2005-05-13 Fernando Perez <fperez@colorado.edu>
869 2005-05-13 Fernando Perez <fperez@colorado.edu>
869
870
870 * ipython.1: Added info about Qt to manpage, and threads warning
871 * ipython.1: Added info about Qt to manpage, and threads warning
871 to usage page (invoked with --help).
872 to usage page (invoked with --help).
872
873
873 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
874 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
874 new matcher (it goes at the end of the priority list) to do
875 new matcher (it goes at the end of the priority list) to do
875 tab-completion on named function arguments. Submitted by George
876 tab-completion on named function arguments. Submitted by George
876 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
877 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
877 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
878 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
878 for more details.
879 for more details.
879
880
880 * IPython/Magic.py (magic_run): Added new -e flag to ignore
881 * IPython/Magic.py (magic_run): Added new -e flag to ignore
881 SystemExit exceptions in the script being run. Thanks to a report
882 SystemExit exceptions in the script being run. Thanks to a report
882 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
883 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
883 producing very annoying behavior when running unit tests.
884 producing very annoying behavior when running unit tests.
884
885
885 2005-05-12 Fernando Perez <fperez@colorado.edu>
886 2005-05-12 Fernando Perez <fperez@colorado.edu>
886
887
887 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
888 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
888 which I'd broken (again) due to a changed regexp. In the process,
889 which I'd broken (again) due to a changed regexp. In the process,
889 added ';' as an escape to auto-quote the whole line without
890 added ';' as an escape to auto-quote the whole line without
890 splitting its arguments. Thanks to a report by Jerry McRae
891 splitting its arguments. Thanks to a report by Jerry McRae
891 <qrs0xyc02-AT-sneakemail.com>.
892 <qrs0xyc02-AT-sneakemail.com>.
892
893
893 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
894 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
894 possible crashes caused by a TokenError. Reported by Ed Schofield
895 possible crashes caused by a TokenError. Reported by Ed Schofield
895 <schofield-AT-ftw.at>.
896 <schofield-AT-ftw.at>.
896
897
897 2005-05-06 Fernando Perez <fperez@colorado.edu>
898 2005-05-06 Fernando Perez <fperez@colorado.edu>
898
899
899 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
900 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
900
901
901 2005-04-29 Fernando Perez <fperez@colorado.edu>
902 2005-04-29 Fernando Perez <fperez@colorado.edu>
902
903
903 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
904 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
904 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
905 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
905 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
906 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
906 which provides support for Qt interactive usage (similar to the
907 which provides support for Qt interactive usage (similar to the
907 existing one for WX and GTK). This had been often requested.
908 existing one for WX and GTK). This had been often requested.
908
909
909 2005-04-14 *** Released version 0.6.13
910 2005-04-14 *** Released version 0.6.13
910
911
911 2005-04-08 Fernando Perez <fperez@colorado.edu>
912 2005-04-08 Fernando Perez <fperez@colorado.edu>
912
913
913 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
914 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
914 from _ofind, which gets called on almost every input line. Now,
915 from _ofind, which gets called on almost every input line. Now,
915 we only try to get docstrings if they are actually going to be
916 we only try to get docstrings if they are actually going to be
916 used (the overhead of fetching unnecessary docstrings can be
917 used (the overhead of fetching unnecessary docstrings can be
917 noticeable for certain objects, such as Pyro proxies).
918 noticeable for certain objects, such as Pyro proxies).
918
919
919 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
920 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
920 for completers. For some reason I had been passing them the state
921 for completers. For some reason I had been passing them the state
921 variable, which completers never actually need, and was in
922 variable, which completers never actually need, and was in
922 conflict with the rlcompleter API. Custom completers ONLY need to
923 conflict with the rlcompleter API. Custom completers ONLY need to
923 take the text parameter.
924 take the text parameter.
924
925
925 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
926 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
926 work correctly in pysh. I've also moved all the logic which used
927 work correctly in pysh. I've also moved all the logic which used
927 to be in pysh.py here, which will prevent problems with future
928 to be in pysh.py here, which will prevent problems with future
928 upgrades. However, this time I must warn users to update their
929 upgrades. However, this time I must warn users to update their
929 pysh profile to include the line
930 pysh profile to include the line
930
931
931 import_all IPython.Extensions.InterpreterExec
932 import_all IPython.Extensions.InterpreterExec
932
933
933 because otherwise things won't work for them. They MUST also
934 because otherwise things won't work for them. They MUST also
934 delete pysh.py and the line
935 delete pysh.py and the line
935
936
936 execfile pysh.py
937 execfile pysh.py
937
938
938 from their ipythonrc-pysh.
939 from their ipythonrc-pysh.
939
940
940 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
941 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
941 robust in the face of objects whose dir() returns non-strings
942 robust in the face of objects whose dir() returns non-strings
942 (which it shouldn't, but some broken libs like ITK do). Thanks to
943 (which it shouldn't, but some broken libs like ITK do). Thanks to
943 a patch by John Hunter (implemented differently, though). Also
944 a patch by John Hunter (implemented differently, though). Also
944 minor improvements by using .extend instead of + on lists.
945 minor improvements by using .extend instead of + on lists.
945
946
946 * pysh.py:
947 * pysh.py:
947
948
948 2005-04-06 Fernando Perez <fperez@colorado.edu>
949 2005-04-06 Fernando Perez <fperez@colorado.edu>
949
950
950 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
951 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
951 by default, so that all users benefit from it. Those who don't
952 by default, so that all users benefit from it. Those who don't
952 want it can still turn it off.
953 want it can still turn it off.
953
954
954 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
955 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
955 config file, I'd forgotten about this, so users were getting it
956 config file, I'd forgotten about this, so users were getting it
956 off by default.
957 off by default.
957
958
958 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
959 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
959 consistency. Now magics can be called in multiline statements,
960 consistency. Now magics can be called in multiline statements,
960 and python variables can be expanded in magic calls via $var.
961 and python variables can be expanded in magic calls via $var.
961 This makes the magic system behave just like aliases or !system
962 This makes the magic system behave just like aliases or !system
962 calls.
963 calls.
963
964
964 2005-03-28 Fernando Perez <fperez@colorado.edu>
965 2005-03-28 Fernando Perez <fperez@colorado.edu>
965
966
966 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
967 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
967 expensive string additions for building command. Add support for
968 expensive string additions for building command. Add support for
968 trailing ';' when autocall is used.
969 trailing ';' when autocall is used.
969
970
970 2005-03-26 Fernando Perez <fperez@colorado.edu>
971 2005-03-26 Fernando Perez <fperez@colorado.edu>
971
972
972 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
973 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
973 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
974 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
974 ipython.el robust against prompts with any number of spaces
975 ipython.el robust against prompts with any number of spaces
975 (including 0) after the ':' character.
976 (including 0) after the ':' character.
976
977
977 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
978 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
978 continuation prompt, which misled users to think the line was
979 continuation prompt, which misled users to think the line was
979 already indented. Closes debian Bug#300847, reported to me by
980 already indented. Closes debian Bug#300847, reported to me by
980 Norbert Tretkowski <tretkowski-AT-inittab.de>.
981 Norbert Tretkowski <tretkowski-AT-inittab.de>.
981
982
982 2005-03-23 Fernando Perez <fperez@colorado.edu>
983 2005-03-23 Fernando Perez <fperez@colorado.edu>
983
984
984 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
985 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
985 properly aligned if they have embedded newlines.
986 properly aligned if they have embedded newlines.
986
987
987 * IPython/iplib.py (runlines): Add a public method to expose
988 * IPython/iplib.py (runlines): Add a public method to expose
988 IPython's code execution machinery, so that users can run strings
989 IPython's code execution machinery, so that users can run strings
989 as if they had been typed at the prompt interactively.
990 as if they had been typed at the prompt interactively.
990 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
991 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
991 methods which can call the system shell, but with python variable
992 methods which can call the system shell, but with python variable
992 expansion. The three such methods are: __IPYTHON__.system,
993 expansion. The three such methods are: __IPYTHON__.system,
993 .getoutput and .getoutputerror. These need to be documented in a
994 .getoutput and .getoutputerror. These need to be documented in a
994 'public API' section (to be written) of the manual.
995 'public API' section (to be written) of the manual.
995
996
996 2005-03-20 Fernando Perez <fperez@colorado.edu>
997 2005-03-20 Fernando Perez <fperez@colorado.edu>
997
998
998 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
999 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
999 for custom exception handling. This is quite powerful, and it
1000 for custom exception handling. This is quite powerful, and it
1000 allows for user-installable exception handlers which can trap
1001 allows for user-installable exception handlers which can trap
1001 custom exceptions at runtime and treat them separately from
1002 custom exceptions at runtime and treat them separately from
1002 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
1003 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
1003 Mantegazza <mantegazza-AT-ill.fr>.
1004 Mantegazza <mantegazza-AT-ill.fr>.
1004 (InteractiveShell.set_custom_completer): public API function to
1005 (InteractiveShell.set_custom_completer): public API function to
1005 add new completers at runtime.
1006 add new completers at runtime.
1006
1007
1007 2005-03-19 Fernando Perez <fperez@colorado.edu>
1008 2005-03-19 Fernando Perez <fperez@colorado.edu>
1008
1009
1009 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
1010 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
1010 allow objects which provide their docstrings via non-standard
1011 allow objects which provide their docstrings via non-standard
1011 mechanisms (like Pyro proxies) to still be inspected by ipython's
1012 mechanisms (like Pyro proxies) to still be inspected by ipython's
1012 ? system.
1013 ? system.
1013
1014
1014 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
1015 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
1015 automatic capture system. I tried quite hard to make it work
1016 automatic capture system. I tried quite hard to make it work
1016 reliably, and simply failed. I tried many combinations with the
1017 reliably, and simply failed. I tried many combinations with the
1017 subprocess module, but eventually nothing worked in all needed
1018 subprocess module, but eventually nothing worked in all needed
1018 cases (not blocking stdin for the child, duplicating stdout
1019 cases (not blocking stdin for the child, duplicating stdout
1019 without blocking, etc). The new %sc/%sx still do capture to these
1020 without blocking, etc). The new %sc/%sx still do capture to these
1020 magical list/string objects which make shell use much more
1021 magical list/string objects which make shell use much more
1021 conveninent, so not all is lost.
1022 conveninent, so not all is lost.
1022
1023
1023 XXX - FIX MANUAL for the change above!
1024 XXX - FIX MANUAL for the change above!
1024
1025
1025 (runsource): I copied code.py's runsource() into ipython to modify
1026 (runsource): I copied code.py's runsource() into ipython to modify
1026 it a bit. Now the code object and source to be executed are
1027 it a bit. Now the code object and source to be executed are
1027 stored in ipython. This makes this info accessible to third-party
1028 stored in ipython. This makes this info accessible to third-party
1028 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
1029 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
1029 Mantegazza <mantegazza-AT-ill.fr>.
1030 Mantegazza <mantegazza-AT-ill.fr>.
1030
1031
1031 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
1032 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
1032 history-search via readline (like C-p/C-n). I'd wanted this for a
1033 history-search via readline (like C-p/C-n). I'd wanted this for a
1033 long time, but only recently found out how to do it. For users
1034 long time, but only recently found out how to do it. For users
1034 who already have their ipythonrc files made and want this, just
1035 who already have their ipythonrc files made and want this, just
1035 add:
1036 add:
1036
1037
1037 readline_parse_and_bind "\e[A": history-search-backward
1038 readline_parse_and_bind "\e[A": history-search-backward
1038 readline_parse_and_bind "\e[B": history-search-forward
1039 readline_parse_and_bind "\e[B": history-search-forward
1039
1040
1040 2005-03-18 Fernando Perez <fperez@colorado.edu>
1041 2005-03-18 Fernando Perez <fperez@colorado.edu>
1041
1042
1042 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
1043 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
1043 LSString and SList classes which allow transparent conversions
1044 LSString and SList classes which allow transparent conversions
1044 between list mode and whitespace-separated string.
1045 between list mode and whitespace-separated string.
1045 (magic_r): Fix recursion problem in %r.
1046 (magic_r): Fix recursion problem in %r.
1046
1047
1047 * IPython/genutils.py (LSString): New class to be used for
1048 * IPython/genutils.py (LSString): New class to be used for
1048 automatic storage of the results of all alias/system calls in _o
1049 automatic storage of the results of all alias/system calls in _o
1049 and _e (stdout/err). These provide a .l/.list attribute which
1050 and _e (stdout/err). These provide a .l/.list attribute which
1050 does automatic splitting on newlines. This means that for most
1051 does automatic splitting on newlines. This means that for most
1051 uses, you'll never need to do capturing of output with %sc/%sx
1052 uses, you'll never need to do capturing of output with %sc/%sx
1052 anymore, since ipython keeps this always done for you. Note that
1053 anymore, since ipython keeps this always done for you. Note that
1053 only the LAST results are stored, the _o/e variables are
1054 only the LAST results are stored, the _o/e variables are
1054 overwritten on each call. If you need to save their contents
1055 overwritten on each call. If you need to save their contents
1055 further, simply bind them to any other name.
1056 further, simply bind them to any other name.
1056
1057
1057 2005-03-17 Fernando Perez <fperez@colorado.edu>
1058 2005-03-17 Fernando Perez <fperez@colorado.edu>
1058
1059
1059 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
1060 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
1060 prompt namespace handling.
1061 prompt namespace handling.
1061
1062
1062 2005-03-16 Fernando Perez <fperez@colorado.edu>
1063 2005-03-16 Fernando Perez <fperez@colorado.edu>
1063
1064
1064 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
1065 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
1065 classic prompts to be '>>> ' (final space was missing, and it
1066 classic prompts to be '>>> ' (final space was missing, and it
1066 trips the emacs python mode).
1067 trips the emacs python mode).
1067 (BasePrompt.__str__): Added safe support for dynamic prompt
1068 (BasePrompt.__str__): Added safe support for dynamic prompt
1068 strings. Now you can set your prompt string to be '$x', and the
1069 strings. Now you can set your prompt string to be '$x', and the
1069 value of x will be printed from your interactive namespace. The
1070 value of x will be printed from your interactive namespace. The
1070 interpolation syntax includes the full Itpl support, so
1071 interpolation syntax includes the full Itpl support, so
1071 ${foo()+x+bar()} is a valid prompt string now, and the function
1072 ${foo()+x+bar()} is a valid prompt string now, and the function
1072 calls will be made at runtime.
1073 calls will be made at runtime.
1073
1074
1074 2005-03-15 Fernando Perez <fperez@colorado.edu>
1075 2005-03-15 Fernando Perez <fperez@colorado.edu>
1075
1076
1076 * IPython/Magic.py (magic_history): renamed %hist to %history, to
1077 * IPython/Magic.py (magic_history): renamed %hist to %history, to
1077 avoid name clashes in pylab. %hist still works, it just forwards
1078 avoid name clashes in pylab. %hist still works, it just forwards
1078 the call to %history.
1079 the call to %history.
1079
1080
1080 2005-03-02 *** Released version 0.6.12
1081 2005-03-02 *** Released version 0.6.12
1081
1082
1082 2005-03-02 Fernando Perez <fperez@colorado.edu>
1083 2005-03-02 Fernando Perez <fperez@colorado.edu>
1083
1084
1084 * IPython/iplib.py (handle_magic): log magic calls properly as
1085 * IPython/iplib.py (handle_magic): log magic calls properly as
1085 ipmagic() function calls.
1086 ipmagic() function calls.
1086
1087
1087 * IPython/Magic.py (magic_time): Improved %time to support
1088 * IPython/Magic.py (magic_time): Improved %time to support
1088 statements and provide wall-clock as well as CPU time.
1089 statements and provide wall-clock as well as CPU time.
1089
1090
1090 2005-02-27 Fernando Perez <fperez@colorado.edu>
1091 2005-02-27 Fernando Perez <fperez@colorado.edu>
1091
1092
1092 * IPython/hooks.py: New hooks module, to expose user-modifiable
1093 * IPython/hooks.py: New hooks module, to expose user-modifiable
1093 IPython functionality in a clean manner. For now only the editor
1094 IPython functionality in a clean manner. For now only the editor
1094 hook is actually written, and other thigns which I intend to turn
1095 hook is actually written, and other thigns which I intend to turn
1095 into proper hooks aren't yet there. The display and prefilter
1096 into proper hooks aren't yet there. The display and prefilter
1096 stuff, for example, should be hooks. But at least now the
1097 stuff, for example, should be hooks. But at least now the
1097 framework is in place, and the rest can be moved here with more
1098 framework is in place, and the rest can be moved here with more
1098 time later. IPython had had a .hooks variable for a long time for
1099 time later. IPython had had a .hooks variable for a long time for
1099 this purpose, but I'd never actually used it for anything.
1100 this purpose, but I'd never actually used it for anything.
1100
1101
1101 2005-02-26 Fernando Perez <fperez@colorado.edu>
1102 2005-02-26 Fernando Perez <fperez@colorado.edu>
1102
1103
1103 * IPython/ipmaker.py (make_IPython): make the default ipython
1104 * IPython/ipmaker.py (make_IPython): make the default ipython
1104 directory be called _ipython under win32, to follow more the
1105 directory be called _ipython under win32, to follow more the
1105 naming peculiarities of that platform (where buggy software like
1106 naming peculiarities of that platform (where buggy software like
1106 Visual Sourcesafe breaks with .named directories). Reported by
1107 Visual Sourcesafe breaks with .named directories). Reported by
1107 Ville Vainio.
1108 Ville Vainio.
1108
1109
1109 2005-02-23 Fernando Perez <fperez@colorado.edu>
1110 2005-02-23 Fernando Perez <fperez@colorado.edu>
1110
1111
1111 * IPython/iplib.py (InteractiveShell.__init__): removed a few
1112 * IPython/iplib.py (InteractiveShell.__init__): removed a few
1112 auto_aliases for win32 which were causing problems. Users can
1113 auto_aliases for win32 which were causing problems. Users can
1113 define the ones they personally like.
1114 define the ones they personally like.
1114
1115
1115 2005-02-21 Fernando Perez <fperez@colorado.edu>
1116 2005-02-21 Fernando Perez <fperez@colorado.edu>
1116
1117
1117 * IPython/Magic.py (magic_time): new magic to time execution of
1118 * IPython/Magic.py (magic_time): new magic to time execution of
1118 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
1119 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
1119
1120
1120 2005-02-19 Fernando Perez <fperez@colorado.edu>
1121 2005-02-19 Fernando Perez <fperez@colorado.edu>
1121
1122
1122 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
1123 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
1123 into keys (for prompts, for example).
1124 into keys (for prompts, for example).
1124
1125
1125 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
1126 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
1126 prompts in case users want them. This introduces a small behavior
1127 prompts in case users want them. This introduces a small behavior
1127 change: ipython does not automatically add a space to all prompts
1128 change: ipython does not automatically add a space to all prompts
1128 anymore. To get the old prompts with a space, users should add it
1129 anymore. To get the old prompts with a space, users should add it
1129 manually to their ipythonrc file, so for example prompt_in1 should
1130 manually to their ipythonrc file, so for example prompt_in1 should
1130 now read 'In [\#]: ' instead of 'In [\#]:'.
1131 now read 'In [\#]: ' instead of 'In [\#]:'.
1131 (BasePrompt.__init__): New option prompts_pad_left (only in rc
1132 (BasePrompt.__init__): New option prompts_pad_left (only in rc
1132 file) to control left-padding of secondary prompts.
1133 file) to control left-padding of secondary prompts.
1133
1134
1134 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
1135 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
1135 the profiler can't be imported. Fix for Debian, which removed
1136 the profiler can't be imported. Fix for Debian, which removed
1136 profile.py because of License issues. I applied a slightly
1137 profile.py because of License issues. I applied a slightly
1137 modified version of the original Debian patch at
1138 modified version of the original Debian patch at
1138 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
1139 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
1139
1140
1140 2005-02-17 Fernando Perez <fperez@colorado.edu>
1141 2005-02-17 Fernando Perez <fperez@colorado.edu>
1141
1142
1142 * IPython/genutils.py (native_line_ends): Fix bug which would
1143 * IPython/genutils.py (native_line_ends): Fix bug which would
1143 cause improper line-ends under win32 b/c I was not opening files
1144 cause improper line-ends under win32 b/c I was not opening files
1144 in binary mode. Bug report and fix thanks to Ville.
1145 in binary mode. Bug report and fix thanks to Ville.
1145
1146
1146 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
1147 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
1147 trying to catch spurious foo[1] autocalls. My fix actually broke
1148 trying to catch spurious foo[1] autocalls. My fix actually broke
1148 ',/' autoquote/call with explicit escape (bad regexp).
1149 ',/' autoquote/call with explicit escape (bad regexp).
1149
1150
1150 2005-02-15 *** Released version 0.6.11
1151 2005-02-15 *** Released version 0.6.11
1151
1152
1152 2005-02-14 Fernando Perez <fperez@colorado.edu>
1153 2005-02-14 Fernando Perez <fperez@colorado.edu>
1153
1154
1154 * IPython/background_jobs.py: New background job management
1155 * IPython/background_jobs.py: New background job management
1155 subsystem. This is implemented via a new set of classes, and
1156 subsystem. This is implemented via a new set of classes, and
1156 IPython now provides a builtin 'jobs' object for background job
1157 IPython now provides a builtin 'jobs' object for background job
1157 execution. A convenience %bg magic serves as a lightweight
1158 execution. A convenience %bg magic serves as a lightweight
1158 frontend for starting the more common type of calls. This was
1159 frontend for starting the more common type of calls. This was
1159 inspired by discussions with B. Granger and the BackgroundCommand
1160 inspired by discussions with B. Granger and the BackgroundCommand
1160 class described in the book Python Scripting for Computational
1161 class described in the book Python Scripting for Computational
1161 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
1162 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
1162 (although ultimately no code from this text was used, as IPython's
1163 (although ultimately no code from this text was used, as IPython's
1163 system is a separate implementation).
1164 system is a separate implementation).
1164
1165
1165 * IPython/iplib.py (MagicCompleter.python_matches): add new option
1166 * IPython/iplib.py (MagicCompleter.python_matches): add new option
1166 to control the completion of single/double underscore names
1167 to control the completion of single/double underscore names
1167 separately. As documented in the example ipytonrc file, the
1168 separately. As documented in the example ipytonrc file, the
1168 readline_omit__names variable can now be set to 2, to omit even
1169 readline_omit__names variable can now be set to 2, to omit even
1169 single underscore names. Thanks to a patch by Brian Wong
1170 single underscore names. Thanks to a patch by Brian Wong
1170 <BrianWong-AT-AirgoNetworks.Com>.
1171 <BrianWong-AT-AirgoNetworks.Com>.
1171 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
1172 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
1172 be autocalled as foo([1]) if foo were callable. A problem for
1173 be autocalled as foo([1]) if foo were callable. A problem for
1173 things which are both callable and implement __getitem__.
1174 things which are both callable and implement __getitem__.
1174 (init_readline): Fix autoindentation for win32. Thanks to a patch
1175 (init_readline): Fix autoindentation for win32. Thanks to a patch
1175 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
1176 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
1176
1177
1177 2005-02-12 Fernando Perez <fperez@colorado.edu>
1178 2005-02-12 Fernando Perez <fperez@colorado.edu>
1178
1179
1179 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
1180 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
1180 which I had written long ago to sort out user error messages which
1181 which I had written long ago to sort out user error messages which
1181 may occur during startup. This seemed like a good idea initially,
1182 may occur during startup. This seemed like a good idea initially,
1182 but it has proven a disaster in retrospect. I don't want to
1183 but it has proven a disaster in retrospect. I don't want to
1183 change much code for now, so my fix is to set the internal 'debug'
1184 change much code for now, so my fix is to set the internal 'debug'
1184 flag to true everywhere, whose only job was precisely to control
1185 flag to true everywhere, whose only job was precisely to control
1185 this subsystem. This closes issue 28 (as well as avoiding all
1186 this subsystem. This closes issue 28 (as well as avoiding all
1186 sorts of strange hangups which occur from time to time).
1187 sorts of strange hangups which occur from time to time).
1187
1188
1188 2005-02-07 Fernando Perez <fperez@colorado.edu>
1189 2005-02-07 Fernando Perez <fperez@colorado.edu>
1189
1190
1190 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
1191 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
1191 previous call produced a syntax error.
1192 previous call produced a syntax error.
1192
1193
1193 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1194 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1194 classes without constructor.
1195 classes without constructor.
1195
1196
1196 2005-02-06 Fernando Perez <fperez@colorado.edu>
1197 2005-02-06 Fernando Perez <fperez@colorado.edu>
1197
1198
1198 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
1199 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
1199 completions with the results of each matcher, so we return results
1200 completions with the results of each matcher, so we return results
1200 to the user from all namespaces. This breaks with ipython
1201 to the user from all namespaces. This breaks with ipython
1201 tradition, but I think it's a nicer behavior. Now you get all
1202 tradition, but I think it's a nicer behavior. Now you get all
1202 possible completions listed, from all possible namespaces (python,
1203 possible completions listed, from all possible namespaces (python,
1203 filesystem, magics...) After a request by John Hunter
1204 filesystem, magics...) After a request by John Hunter
1204 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1205 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1205
1206
1206 2005-02-05 Fernando Perez <fperez@colorado.edu>
1207 2005-02-05 Fernando Perez <fperez@colorado.edu>
1207
1208
1208 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
1209 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
1209 the call had quote characters in it (the quotes were stripped).
1210 the call had quote characters in it (the quotes were stripped).
1210
1211
1211 2005-01-31 Fernando Perez <fperez@colorado.edu>
1212 2005-01-31 Fernando Perez <fperez@colorado.edu>
1212
1213
1213 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
1214 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
1214 Itpl.itpl() to make the code more robust against psyco
1215 Itpl.itpl() to make the code more robust against psyco
1215 optimizations.
1216 optimizations.
1216
1217
1217 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
1218 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
1218 of causing an exception. Quicker, cleaner.
1219 of causing an exception. Quicker, cleaner.
1219
1220
1220 2005-01-28 Fernando Perez <fperez@colorado.edu>
1221 2005-01-28 Fernando Perez <fperez@colorado.edu>
1221
1222
1222 * scripts/ipython_win_post_install.py (install): hardcode
1223 * scripts/ipython_win_post_install.py (install): hardcode
1223 sys.prefix+'python.exe' as the executable path. It turns out that
1224 sys.prefix+'python.exe' as the executable path. It turns out that
1224 during the post-installation run, sys.executable resolves to the
1225 during the post-installation run, sys.executable resolves to the
1225 name of the binary installer! I should report this as a distutils
1226 name of the binary installer! I should report this as a distutils
1226 bug, I think. I updated the .10 release with this tiny fix, to
1227 bug, I think. I updated the .10 release with this tiny fix, to
1227 avoid annoying the lists further.
1228 avoid annoying the lists further.
1228
1229
1229 2005-01-27 *** Released version 0.6.10
1230 2005-01-27 *** Released version 0.6.10
1230
1231
1231 2005-01-27 Fernando Perez <fperez@colorado.edu>
1232 2005-01-27 Fernando Perez <fperez@colorado.edu>
1232
1233
1233 * IPython/numutils.py (norm): Added 'inf' as optional name for
1234 * IPython/numutils.py (norm): Added 'inf' as optional name for
1234 L-infinity norm, included references to mathworld.com for vector
1235 L-infinity norm, included references to mathworld.com for vector
1235 norm definitions.
1236 norm definitions.
1236 (amin/amax): added amin/amax for array min/max. Similar to what
1237 (amin/amax): added amin/amax for array min/max. Similar to what
1237 pylab ships with after the recent reorganization of names.
1238 pylab ships with after the recent reorganization of names.
1238 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1239 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1239
1240
1240 * ipython.el: committed Alex's recent fixes and improvements.
1241 * ipython.el: committed Alex's recent fixes and improvements.
1241 Tested with python-mode from CVS, and it looks excellent. Since
1242 Tested with python-mode from CVS, and it looks excellent. Since
1242 python-mode hasn't released anything in a while, I'm temporarily
1243 python-mode hasn't released anything in a while, I'm temporarily
1243 putting a copy of today's CVS (v 4.70) of python-mode in:
1244 putting a copy of today's CVS (v 4.70) of python-mode in:
1244 http://ipython.scipy.org/tmp/python-mode.el
1245 http://ipython.scipy.org/tmp/python-mode.el
1245
1246
1246 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1247 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1247 sys.executable for the executable name, instead of assuming it's
1248 sys.executable for the executable name, instead of assuming it's
1248 called 'python.exe' (the post-installer would have produced broken
1249 called 'python.exe' (the post-installer would have produced broken
1249 setups on systems with a differently named python binary).
1250 setups on systems with a differently named python binary).
1250
1251
1251 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1252 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1252 references to os.linesep, to make the code more
1253 references to os.linesep, to make the code more
1253 platform-independent. This is also part of the win32 coloring
1254 platform-independent. This is also part of the win32 coloring
1254 fixes.
1255 fixes.
1255
1256
1256 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1257 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1257 lines, which actually cause coloring bugs because the length of
1258 lines, which actually cause coloring bugs because the length of
1258 the line is very difficult to correctly compute with embedded
1259 the line is very difficult to correctly compute with embedded
1259 escapes. This was the source of all the coloring problems under
1260 escapes. This was the source of all the coloring problems under
1260 Win32. I think that _finally_, Win32 users have a properly
1261 Win32. I think that _finally_, Win32 users have a properly
1261 working ipython in all respects. This would never have happened
1262 working ipython in all respects. This would never have happened
1262 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1263 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1263
1264
1264 2005-01-26 *** Released version 0.6.9
1265 2005-01-26 *** Released version 0.6.9
1265
1266
1266 2005-01-25 Fernando Perez <fperez@colorado.edu>
1267 2005-01-25 Fernando Perez <fperez@colorado.edu>
1267
1268
1268 * setup.py: finally, we have a true Windows installer, thanks to
1269 * setup.py: finally, we have a true Windows installer, thanks to
1269 the excellent work of Viktor Ransmayr
1270 the excellent work of Viktor Ransmayr
1270 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1271 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1271 Windows users. The setup routine is quite a bit cleaner thanks to
1272 Windows users. The setup routine is quite a bit cleaner thanks to
1272 this, and the post-install script uses the proper functions to
1273 this, and the post-install script uses the proper functions to
1273 allow a clean de-installation using the standard Windows Control
1274 allow a clean de-installation using the standard Windows Control
1274 Panel.
1275 Panel.
1275
1276
1276 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1277 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1277 environment variable under all OSes (including win32) if
1278 environment variable under all OSes (including win32) if
1278 available. This will give consistency to win32 users who have set
1279 available. This will give consistency to win32 users who have set
1279 this variable for any reason. If os.environ['HOME'] fails, the
1280 this variable for any reason. If os.environ['HOME'] fails, the
1280 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1281 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1281
1282
1282 2005-01-24 Fernando Perez <fperez@colorado.edu>
1283 2005-01-24 Fernando Perez <fperez@colorado.edu>
1283
1284
1284 * IPython/numutils.py (empty_like): add empty_like(), similar to
1285 * IPython/numutils.py (empty_like): add empty_like(), similar to
1285 zeros_like() but taking advantage of the new empty() Numeric routine.
1286 zeros_like() but taking advantage of the new empty() Numeric routine.
1286
1287
1287 2005-01-23 *** Released version 0.6.8
1288 2005-01-23 *** Released version 0.6.8
1288
1289
1289 2005-01-22 Fernando Perez <fperez@colorado.edu>
1290 2005-01-22 Fernando Perez <fperez@colorado.edu>
1290
1291
1291 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1292 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1292 automatic show() calls. After discussing things with JDH, it
1293 automatic show() calls. After discussing things with JDH, it
1293 turns out there are too many corner cases where this can go wrong.
1294 turns out there are too many corner cases where this can go wrong.
1294 It's best not to try to be 'too smart', and simply have ipython
1295 It's best not to try to be 'too smart', and simply have ipython
1295 reproduce as much as possible the default behavior of a normal
1296 reproduce as much as possible the default behavior of a normal
1296 python shell.
1297 python shell.
1297
1298
1298 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1299 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1299 line-splitting regexp and _prefilter() to avoid calling getattr()
1300 line-splitting regexp and _prefilter() to avoid calling getattr()
1300 on assignments. This closes
1301 on assignments. This closes
1301 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1302 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1302 readline uses getattr(), so a simple <TAB> keypress is still
1303 readline uses getattr(), so a simple <TAB> keypress is still
1303 enough to trigger getattr() calls on an object.
1304 enough to trigger getattr() calls on an object.
1304
1305
1305 2005-01-21 Fernando Perez <fperez@colorado.edu>
1306 2005-01-21 Fernando Perez <fperez@colorado.edu>
1306
1307
1307 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1308 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1308 docstring under pylab so it doesn't mask the original.
1309 docstring under pylab so it doesn't mask the original.
1309
1310
1310 2005-01-21 *** Released version 0.6.7
1311 2005-01-21 *** Released version 0.6.7
1311
1312
1312 2005-01-21 Fernando Perez <fperez@colorado.edu>
1313 2005-01-21 Fernando Perez <fperez@colorado.edu>
1313
1314
1314 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1315 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1315 signal handling for win32 users in multithreaded mode.
1316 signal handling for win32 users in multithreaded mode.
1316
1317
1317 2005-01-17 Fernando Perez <fperez@colorado.edu>
1318 2005-01-17 Fernando Perez <fperez@colorado.edu>
1318
1319
1319 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1320 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1320 instances with no __init__. After a crash report by Norbert Nemec
1321 instances with no __init__. After a crash report by Norbert Nemec
1321 <Norbert-AT-nemec-online.de>.
1322 <Norbert-AT-nemec-online.de>.
1322
1323
1323 2005-01-14 Fernando Perez <fperez@colorado.edu>
1324 2005-01-14 Fernando Perez <fperez@colorado.edu>
1324
1325
1325 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1326 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1326 names for verbose exceptions, when multiple dotted names and the
1327 names for verbose exceptions, when multiple dotted names and the
1327 'parent' object were present on the same line.
1328 'parent' object were present on the same line.
1328
1329
1329 2005-01-11 Fernando Perez <fperez@colorado.edu>
1330 2005-01-11 Fernando Perez <fperez@colorado.edu>
1330
1331
1331 * IPython/genutils.py (flag_calls): new utility to trap and flag
1332 * IPython/genutils.py (flag_calls): new utility to trap and flag
1332 calls in functions. I need it to clean up matplotlib support.
1333 calls in functions. I need it to clean up matplotlib support.
1333 Also removed some deprecated code in genutils.
1334 Also removed some deprecated code in genutils.
1334
1335
1335 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1336 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1336 that matplotlib scripts called with %run, which don't call show()
1337 that matplotlib scripts called with %run, which don't call show()
1337 themselves, still have their plotting windows open.
1338 themselves, still have their plotting windows open.
1338
1339
1339 2005-01-05 Fernando Perez <fperez@colorado.edu>
1340 2005-01-05 Fernando Perez <fperez@colorado.edu>
1340
1341
1341 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1342 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1342 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1343 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1343
1344
1344 2004-12-19 Fernando Perez <fperez@colorado.edu>
1345 2004-12-19 Fernando Perez <fperez@colorado.edu>
1345
1346
1346 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1347 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1347 parent_runcode, which was an eyesore. The same result can be
1348 parent_runcode, which was an eyesore. The same result can be
1348 obtained with Python's regular superclass mechanisms.
1349 obtained with Python's regular superclass mechanisms.
1349
1350
1350 2004-12-17 Fernando Perez <fperez@colorado.edu>
1351 2004-12-17 Fernando Perez <fperez@colorado.edu>
1351
1352
1352 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1353 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1353 reported by Prabhu.
1354 reported by Prabhu.
1354 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1355 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1355 sys.stderr) instead of explicitly calling sys.stderr. This helps
1356 sys.stderr) instead of explicitly calling sys.stderr. This helps
1356 maintain our I/O abstractions clean, for future GUI embeddings.
1357 maintain our I/O abstractions clean, for future GUI embeddings.
1357
1358
1358 * IPython/genutils.py (info): added new utility for sys.stderr
1359 * IPython/genutils.py (info): added new utility for sys.stderr
1359 unified info message handling (thin wrapper around warn()).
1360 unified info message handling (thin wrapper around warn()).
1360
1361
1361 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1362 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1362 composite (dotted) names on verbose exceptions.
1363 composite (dotted) names on verbose exceptions.
1363 (VerboseTB.nullrepr): harden against another kind of errors which
1364 (VerboseTB.nullrepr): harden against another kind of errors which
1364 Python's inspect module can trigger, and which were crashing
1365 Python's inspect module can trigger, and which were crashing
1365 IPython. Thanks to a report by Marco Lombardi
1366 IPython. Thanks to a report by Marco Lombardi
1366 <mlombard-AT-ma010192.hq.eso.org>.
1367 <mlombard-AT-ma010192.hq.eso.org>.
1367
1368
1368 2004-12-13 *** Released version 0.6.6
1369 2004-12-13 *** Released version 0.6.6
1369
1370
1370 2004-12-12 Fernando Perez <fperez@colorado.edu>
1371 2004-12-12 Fernando Perez <fperez@colorado.edu>
1371
1372
1372 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1373 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1373 generated by pygtk upon initialization if it was built without
1374 generated by pygtk upon initialization if it was built without
1374 threads (for matplotlib users). After a crash reported by
1375 threads (for matplotlib users). After a crash reported by
1375 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1376 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1376
1377
1377 * IPython/ipmaker.py (make_IPython): fix small bug in the
1378 * IPython/ipmaker.py (make_IPython): fix small bug in the
1378 import_some parameter for multiple imports.
1379 import_some parameter for multiple imports.
1379
1380
1380 * IPython/iplib.py (ipmagic): simplified the interface of
1381 * IPython/iplib.py (ipmagic): simplified the interface of
1381 ipmagic() to take a single string argument, just as it would be
1382 ipmagic() to take a single string argument, just as it would be
1382 typed at the IPython cmd line.
1383 typed at the IPython cmd line.
1383 (ipalias): Added new ipalias() with an interface identical to
1384 (ipalias): Added new ipalias() with an interface identical to
1384 ipmagic(). This completes exposing a pure python interface to the
1385 ipmagic(). This completes exposing a pure python interface to the
1385 alias and magic system, which can be used in loops or more complex
1386 alias and magic system, which can be used in loops or more complex
1386 code where IPython's automatic line mangling is not active.
1387 code where IPython's automatic line mangling is not active.
1387
1388
1388 * IPython/genutils.py (timing): changed interface of timing to
1389 * IPython/genutils.py (timing): changed interface of timing to
1389 simply run code once, which is the most common case. timings()
1390 simply run code once, which is the most common case. timings()
1390 remains unchanged, for the cases where you want multiple runs.
1391 remains unchanged, for the cases where you want multiple runs.
1391
1392
1392 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1393 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1393 bug where Python2.2 crashes with exec'ing code which does not end
1394 bug where Python2.2 crashes with exec'ing code which does not end
1394 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1395 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1395 before.
1396 before.
1396
1397
1397 2004-12-10 Fernando Perez <fperez@colorado.edu>
1398 2004-12-10 Fernando Perez <fperez@colorado.edu>
1398
1399
1399 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1400 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1400 -t to -T, to accomodate the new -t flag in %run (the %run and
1401 -t to -T, to accomodate the new -t flag in %run (the %run and
1401 %prun options are kind of intermixed, and it's not easy to change
1402 %prun options are kind of intermixed, and it's not easy to change
1402 this with the limitations of python's getopt).
1403 this with the limitations of python's getopt).
1403
1404
1404 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1405 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1405 the execution of scripts. It's not as fine-tuned as timeit.py,
1406 the execution of scripts. It's not as fine-tuned as timeit.py,
1406 but it works from inside ipython (and under 2.2, which lacks
1407 but it works from inside ipython (and under 2.2, which lacks
1407 timeit.py). Optionally a number of runs > 1 can be given for
1408 timeit.py). Optionally a number of runs > 1 can be given for
1408 timing very short-running code.
1409 timing very short-running code.
1409
1410
1410 * IPython/genutils.py (uniq_stable): new routine which returns a
1411 * IPython/genutils.py (uniq_stable): new routine which returns a
1411 list of unique elements in any iterable, but in stable order of
1412 list of unique elements in any iterable, but in stable order of
1412 appearance. I needed this for the ultraTB fixes, and it's a handy
1413 appearance. I needed this for the ultraTB fixes, and it's a handy
1413 utility.
1414 utility.
1414
1415
1415 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1416 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1416 dotted names in Verbose exceptions. This had been broken since
1417 dotted names in Verbose exceptions. This had been broken since
1417 the very start, now x.y will properly be printed in a Verbose
1418 the very start, now x.y will properly be printed in a Verbose
1418 traceback, instead of x being shown and y appearing always as an
1419 traceback, instead of x being shown and y appearing always as an
1419 'undefined global'. Getting this to work was a bit tricky,
1420 'undefined global'. Getting this to work was a bit tricky,
1420 because by default python tokenizers are stateless. Saved by
1421 because by default python tokenizers are stateless. Saved by
1421 python's ability to easily add a bit of state to an arbitrary
1422 python's ability to easily add a bit of state to an arbitrary
1422 function (without needing to build a full-blown callable object).
1423 function (without needing to build a full-blown callable object).
1423
1424
1424 Also big cleanup of this code, which had horrendous runtime
1425 Also big cleanup of this code, which had horrendous runtime
1425 lookups of zillions of attributes for colorization. Moved all
1426 lookups of zillions of attributes for colorization. Moved all
1426 this code into a few templates, which make it cleaner and quicker.
1427 this code into a few templates, which make it cleaner and quicker.
1427
1428
1428 Printout quality was also improved for Verbose exceptions: one
1429 Printout quality was also improved for Verbose exceptions: one
1429 variable per line, and memory addresses are printed (this can be
1430 variable per line, and memory addresses are printed (this can be
1430 quite handy in nasty debugging situations, which is what Verbose
1431 quite handy in nasty debugging situations, which is what Verbose
1431 is for).
1432 is for).
1432
1433
1433 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1434 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1434 the command line as scripts to be loaded by embedded instances.
1435 the command line as scripts to be loaded by embedded instances.
1435 Doing so has the potential for an infinite recursion if there are
1436 Doing so has the potential for an infinite recursion if there are
1436 exceptions thrown in the process. This fixes a strange crash
1437 exceptions thrown in the process. This fixes a strange crash
1437 reported by Philippe MULLER <muller-AT-irit.fr>.
1438 reported by Philippe MULLER <muller-AT-irit.fr>.
1438
1439
1439 2004-12-09 Fernando Perez <fperez@colorado.edu>
1440 2004-12-09 Fernando Perez <fperez@colorado.edu>
1440
1441
1441 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1442 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1442 to reflect new names in matplotlib, which now expose the
1443 to reflect new names in matplotlib, which now expose the
1443 matlab-compatible interface via a pylab module instead of the
1444 matlab-compatible interface via a pylab module instead of the
1444 'matlab' name. The new code is backwards compatible, so users of
1445 'matlab' name. The new code is backwards compatible, so users of
1445 all matplotlib versions are OK. Patch by J. Hunter.
1446 all matplotlib versions are OK. Patch by J. Hunter.
1446
1447
1447 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1448 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1448 of __init__ docstrings for instances (class docstrings are already
1449 of __init__ docstrings for instances (class docstrings are already
1449 automatically printed). Instances with customized docstrings
1450 automatically printed). Instances with customized docstrings
1450 (indep. of the class) are also recognized and all 3 separate
1451 (indep. of the class) are also recognized and all 3 separate
1451 docstrings are printed (instance, class, constructor). After some
1452 docstrings are printed (instance, class, constructor). After some
1452 comments/suggestions by J. Hunter.
1453 comments/suggestions by J. Hunter.
1453
1454
1454 2004-12-05 Fernando Perez <fperez@colorado.edu>
1455 2004-12-05 Fernando Perez <fperez@colorado.edu>
1455
1456
1456 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1457 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1457 warnings when tab-completion fails and triggers an exception.
1458 warnings when tab-completion fails and triggers an exception.
1458
1459
1459 2004-12-03 Fernando Perez <fperez@colorado.edu>
1460 2004-12-03 Fernando Perez <fperez@colorado.edu>
1460
1461
1461 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1462 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1462 be triggered when using 'run -p'. An incorrect option flag was
1463 be triggered when using 'run -p'. An incorrect option flag was
1463 being set ('d' instead of 'D').
1464 being set ('d' instead of 'D').
1464 (manpage): fix missing escaped \- sign.
1465 (manpage): fix missing escaped \- sign.
1465
1466
1466 2004-11-30 *** Released version 0.6.5
1467 2004-11-30 *** Released version 0.6.5
1467
1468
1468 2004-11-30 Fernando Perez <fperez@colorado.edu>
1469 2004-11-30 Fernando Perez <fperez@colorado.edu>
1469
1470
1470 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1471 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1471 setting with -d option.
1472 setting with -d option.
1472
1473
1473 * setup.py (docfiles): Fix problem where the doc glob I was using
1474 * setup.py (docfiles): Fix problem where the doc glob I was using
1474 was COMPLETELY BROKEN. It was giving the right files by pure
1475 was COMPLETELY BROKEN. It was giving the right files by pure
1475 accident, but failed once I tried to include ipython.el. Note:
1476 accident, but failed once I tried to include ipython.el. Note:
1476 glob() does NOT allow you to do exclusion on multiple endings!
1477 glob() does NOT allow you to do exclusion on multiple endings!
1477
1478
1478 2004-11-29 Fernando Perez <fperez@colorado.edu>
1479 2004-11-29 Fernando Perez <fperez@colorado.edu>
1479
1480
1480 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1481 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1481 the manpage as the source. Better formatting & consistency.
1482 the manpage as the source. Better formatting & consistency.
1482
1483
1483 * IPython/Magic.py (magic_run): Added new -d option, to run
1484 * IPython/Magic.py (magic_run): Added new -d option, to run
1484 scripts under the control of the python pdb debugger. Note that
1485 scripts under the control of the python pdb debugger. Note that
1485 this required changing the %prun option -d to -D, to avoid a clash
1486 this required changing the %prun option -d to -D, to avoid a clash
1486 (since %run must pass options to %prun, and getopt is too dumb to
1487 (since %run must pass options to %prun, and getopt is too dumb to
1487 handle options with string values with embedded spaces). Thanks
1488 handle options with string values with embedded spaces). Thanks
1488 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1489 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1489 (magic_who_ls): added type matching to %who and %whos, so that one
1490 (magic_who_ls): added type matching to %who and %whos, so that one
1490 can filter their output to only include variables of certain
1491 can filter their output to only include variables of certain
1491 types. Another suggestion by Matthew.
1492 types. Another suggestion by Matthew.
1492 (magic_whos): Added memory summaries in kb and Mb for arrays.
1493 (magic_whos): Added memory summaries in kb and Mb for arrays.
1493 (magic_who): Improve formatting (break lines every 9 vars).
1494 (magic_who): Improve formatting (break lines every 9 vars).
1494
1495
1495 2004-11-28 Fernando Perez <fperez@colorado.edu>
1496 2004-11-28 Fernando Perez <fperez@colorado.edu>
1496
1497
1497 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1498 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1498 cache when empty lines were present.
1499 cache when empty lines were present.
1499
1500
1500 2004-11-24 Fernando Perez <fperez@colorado.edu>
1501 2004-11-24 Fernando Perez <fperez@colorado.edu>
1501
1502
1502 * IPython/usage.py (__doc__): document the re-activated threading
1503 * IPython/usage.py (__doc__): document the re-activated threading
1503 options for WX and GTK.
1504 options for WX and GTK.
1504
1505
1505 2004-11-23 Fernando Perez <fperez@colorado.edu>
1506 2004-11-23 Fernando Perez <fperez@colorado.edu>
1506
1507
1507 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1508 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1508 the -wthread and -gthread options, along with a new -tk one to try
1509 the -wthread and -gthread options, along with a new -tk one to try
1509 and coordinate Tk threading with wx/gtk. The tk support is very
1510 and coordinate Tk threading with wx/gtk. The tk support is very
1510 platform dependent, since it seems to require Tcl and Tk to be
1511 platform dependent, since it seems to require Tcl and Tk to be
1511 built with threads (Fedora1/2 appears NOT to have it, but in
1512 built with threads (Fedora1/2 appears NOT to have it, but in
1512 Prabhu's Debian boxes it works OK). But even with some Tk
1513 Prabhu's Debian boxes it works OK). But even with some Tk
1513 limitations, this is a great improvement.
1514 limitations, this is a great improvement.
1514
1515
1515 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1516 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1516 info in user prompts. Patch by Prabhu.
1517 info in user prompts. Patch by Prabhu.
1517
1518
1518 2004-11-18 Fernando Perez <fperez@colorado.edu>
1519 2004-11-18 Fernando Perez <fperez@colorado.edu>
1519
1520
1520 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1521 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1521 EOFErrors and bail, to avoid infinite loops if a non-terminating
1522 EOFErrors and bail, to avoid infinite loops if a non-terminating
1522 file is fed into ipython. Patch submitted in issue 19 by user,
1523 file is fed into ipython. Patch submitted in issue 19 by user,
1523 many thanks.
1524 many thanks.
1524
1525
1525 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1526 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1526 autoquote/parens in continuation prompts, which can cause lots of
1527 autoquote/parens in continuation prompts, which can cause lots of
1527 problems. Closes roundup issue 20.
1528 problems. Closes roundup issue 20.
1528
1529
1529 2004-11-17 Fernando Perez <fperez@colorado.edu>
1530 2004-11-17 Fernando Perez <fperez@colorado.edu>
1530
1531
1531 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1532 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1532 reported as debian bug #280505. I'm not sure my local changelog
1533 reported as debian bug #280505. I'm not sure my local changelog
1533 entry has the proper debian format (Jack?).
1534 entry has the proper debian format (Jack?).
1534
1535
1535 2004-11-08 *** Released version 0.6.4
1536 2004-11-08 *** Released version 0.6.4
1536
1537
1537 2004-11-08 Fernando Perez <fperez@colorado.edu>
1538 2004-11-08 Fernando Perez <fperez@colorado.edu>
1538
1539
1539 * IPython/iplib.py (init_readline): Fix exit message for Windows
1540 * IPython/iplib.py (init_readline): Fix exit message for Windows
1540 when readline is active. Thanks to a report by Eric Jones
1541 when readline is active. Thanks to a report by Eric Jones
1541 <eric-AT-enthought.com>.
1542 <eric-AT-enthought.com>.
1542
1543
1543 2004-11-07 Fernando Perez <fperez@colorado.edu>
1544 2004-11-07 Fernando Perez <fperez@colorado.edu>
1544
1545
1545 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1546 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1546 sometimes seen by win2k/cygwin users.
1547 sometimes seen by win2k/cygwin users.
1547
1548
1548 2004-11-06 Fernando Perez <fperez@colorado.edu>
1549 2004-11-06 Fernando Perez <fperez@colorado.edu>
1549
1550
1550 * IPython/iplib.py (interact): Change the handling of %Exit from
1551 * IPython/iplib.py (interact): Change the handling of %Exit from
1551 trying to propagate a SystemExit to an internal ipython flag.
1552 trying to propagate a SystemExit to an internal ipython flag.
1552 This is less elegant than using Python's exception mechanism, but
1553 This is less elegant than using Python's exception mechanism, but
1553 I can't get that to work reliably with threads, so under -pylab
1554 I can't get that to work reliably with threads, so under -pylab
1554 %Exit was hanging IPython. Cross-thread exception handling is
1555 %Exit was hanging IPython. Cross-thread exception handling is
1555 really a bitch. Thaks to a bug report by Stephen Walton
1556 really a bitch. Thaks to a bug report by Stephen Walton
1556 <stephen.walton-AT-csun.edu>.
1557 <stephen.walton-AT-csun.edu>.
1557
1558
1558 2004-11-04 Fernando Perez <fperez@colorado.edu>
1559 2004-11-04 Fernando Perez <fperez@colorado.edu>
1559
1560
1560 * IPython/iplib.py (raw_input_original): store a pointer to the
1561 * IPython/iplib.py (raw_input_original): store a pointer to the
1561 true raw_input to harden against code which can modify it
1562 true raw_input to harden against code which can modify it
1562 (wx.py.PyShell does this and would otherwise crash ipython).
1563 (wx.py.PyShell does this and would otherwise crash ipython).
1563 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1564 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1564
1565
1565 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1566 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1566 Ctrl-C problem, which does not mess up the input line.
1567 Ctrl-C problem, which does not mess up the input line.
1567
1568
1568 2004-11-03 Fernando Perez <fperez@colorado.edu>
1569 2004-11-03 Fernando Perez <fperez@colorado.edu>
1569
1570
1570 * IPython/Release.py: Changed licensing to BSD, in all files.
1571 * IPython/Release.py: Changed licensing to BSD, in all files.
1571 (name): lowercase name for tarball/RPM release.
1572 (name): lowercase name for tarball/RPM release.
1572
1573
1573 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1574 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1574 use throughout ipython.
1575 use throughout ipython.
1575
1576
1576 * IPython/Magic.py (Magic._ofind): Switch to using the new
1577 * IPython/Magic.py (Magic._ofind): Switch to using the new
1577 OInspect.getdoc() function.
1578 OInspect.getdoc() function.
1578
1579
1579 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1580 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1580 of the line currently being canceled via Ctrl-C. It's extremely
1581 of the line currently being canceled via Ctrl-C. It's extremely
1581 ugly, but I don't know how to do it better (the problem is one of
1582 ugly, but I don't know how to do it better (the problem is one of
1582 handling cross-thread exceptions).
1583 handling cross-thread exceptions).
1583
1584
1584 2004-10-28 Fernando Perez <fperez@colorado.edu>
1585 2004-10-28 Fernando Perez <fperez@colorado.edu>
1585
1586
1586 * IPython/Shell.py (signal_handler): add signal handlers to trap
1587 * IPython/Shell.py (signal_handler): add signal handlers to trap
1587 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1588 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1588 report by Francesc Alted.
1589 report by Francesc Alted.
1589
1590
1590 2004-10-21 Fernando Perez <fperez@colorado.edu>
1591 2004-10-21 Fernando Perez <fperez@colorado.edu>
1591
1592
1592 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1593 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1593 to % for pysh syntax extensions.
1594 to % for pysh syntax extensions.
1594
1595
1595 2004-10-09 Fernando Perez <fperez@colorado.edu>
1596 2004-10-09 Fernando Perez <fperez@colorado.edu>
1596
1597
1597 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1598 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1598 arrays to print a more useful summary, without calling str(arr).
1599 arrays to print a more useful summary, without calling str(arr).
1599 This avoids the problem of extremely lengthy computations which
1600 This avoids the problem of extremely lengthy computations which
1600 occur if arr is large, and appear to the user as a system lockup
1601 occur if arr is large, and appear to the user as a system lockup
1601 with 100% cpu activity. After a suggestion by Kristian Sandberg
1602 with 100% cpu activity. After a suggestion by Kristian Sandberg
1602 <Kristian.Sandberg@colorado.edu>.
1603 <Kristian.Sandberg@colorado.edu>.
1603 (Magic.__init__): fix bug in global magic escapes not being
1604 (Magic.__init__): fix bug in global magic escapes not being
1604 correctly set.
1605 correctly set.
1605
1606
1606 2004-10-08 Fernando Perez <fperez@colorado.edu>
1607 2004-10-08 Fernando Perez <fperez@colorado.edu>
1607
1608
1608 * IPython/Magic.py (__license__): change to absolute imports of
1609 * IPython/Magic.py (__license__): change to absolute imports of
1609 ipython's own internal packages, to start adapting to the absolute
1610 ipython's own internal packages, to start adapting to the absolute
1610 import requirement of PEP-328.
1611 import requirement of PEP-328.
1611
1612
1612 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1613 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1613 files, and standardize author/license marks through the Release
1614 files, and standardize author/license marks through the Release
1614 module instead of having per/file stuff (except for files with
1615 module instead of having per/file stuff (except for files with
1615 particular licenses, like the MIT/PSF-licensed codes).
1616 particular licenses, like the MIT/PSF-licensed codes).
1616
1617
1617 * IPython/Debugger.py: remove dead code for python 2.1
1618 * IPython/Debugger.py: remove dead code for python 2.1
1618
1619
1619 2004-10-04 Fernando Perez <fperez@colorado.edu>
1620 2004-10-04 Fernando Perez <fperez@colorado.edu>
1620
1621
1621 * IPython/iplib.py (ipmagic): New function for accessing magics
1622 * IPython/iplib.py (ipmagic): New function for accessing magics
1622 via a normal python function call.
1623 via a normal python function call.
1623
1624
1624 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1625 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1625 from '@' to '%', to accomodate the new @decorator syntax of python
1626 from '@' to '%', to accomodate the new @decorator syntax of python
1626 2.4.
1627 2.4.
1627
1628
1628 2004-09-29 Fernando Perez <fperez@colorado.edu>
1629 2004-09-29 Fernando Perez <fperez@colorado.edu>
1629
1630
1630 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1631 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1631 matplotlib.use to prevent running scripts which try to switch
1632 matplotlib.use to prevent running scripts which try to switch
1632 interactive backends from within ipython. This will just crash
1633 interactive backends from within ipython. This will just crash
1633 the python interpreter, so we can't allow it (but a detailed error
1634 the python interpreter, so we can't allow it (but a detailed error
1634 is given to the user).
1635 is given to the user).
1635
1636
1636 2004-09-28 Fernando Perez <fperez@colorado.edu>
1637 2004-09-28 Fernando Perez <fperez@colorado.edu>
1637
1638
1638 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1639 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1639 matplotlib-related fixes so that using @run with non-matplotlib
1640 matplotlib-related fixes so that using @run with non-matplotlib
1640 scripts doesn't pop up spurious plot windows. This requires
1641 scripts doesn't pop up spurious plot windows. This requires
1641 matplotlib >= 0.63, where I had to make some changes as well.
1642 matplotlib >= 0.63, where I had to make some changes as well.
1642
1643
1643 * IPython/ipmaker.py (make_IPython): update version requirement to
1644 * IPython/ipmaker.py (make_IPython): update version requirement to
1644 python 2.2.
1645 python 2.2.
1645
1646
1646 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1647 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1647 banner arg for embedded customization.
1648 banner arg for embedded customization.
1648
1649
1649 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1650 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1650 explicit uses of __IP as the IPython's instance name. Now things
1651 explicit uses of __IP as the IPython's instance name. Now things
1651 are properly handled via the shell.name value. The actual code
1652 are properly handled via the shell.name value. The actual code
1652 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1653 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1653 is much better than before. I'll clean things completely when the
1654 is much better than before. I'll clean things completely when the
1654 magic stuff gets a real overhaul.
1655 magic stuff gets a real overhaul.
1655
1656
1656 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1657 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1657 minor changes to debian dir.
1658 minor changes to debian dir.
1658
1659
1659 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1660 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1660 pointer to the shell itself in the interactive namespace even when
1661 pointer to the shell itself in the interactive namespace even when
1661 a user-supplied dict is provided. This is needed for embedding
1662 a user-supplied dict is provided. This is needed for embedding
1662 purposes (found by tests with Michel Sanner).
1663 purposes (found by tests with Michel Sanner).
1663
1664
1664 2004-09-27 Fernando Perez <fperez@colorado.edu>
1665 2004-09-27 Fernando Perez <fperez@colorado.edu>
1665
1666
1666 * IPython/UserConfig/ipythonrc: remove []{} from
1667 * IPython/UserConfig/ipythonrc: remove []{} from
1667 readline_remove_delims, so that things like [modname.<TAB> do
1668 readline_remove_delims, so that things like [modname.<TAB> do
1668 proper completion. This disables [].TAB, but that's a less common
1669 proper completion. This disables [].TAB, but that's a less common
1669 case than module names in list comprehensions, for example.
1670 case than module names in list comprehensions, for example.
1670 Thanks to a report by Andrea Riciputi.
1671 Thanks to a report by Andrea Riciputi.
1671
1672
1672 2004-09-09 Fernando Perez <fperez@colorado.edu>
1673 2004-09-09 Fernando Perez <fperez@colorado.edu>
1673
1674
1674 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1675 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1675 blocking problems in win32 and osx. Fix by John.
1676 blocking problems in win32 and osx. Fix by John.
1676
1677
1677 2004-09-08 Fernando Perez <fperez@colorado.edu>
1678 2004-09-08 Fernando Perez <fperez@colorado.edu>
1678
1679
1679 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1680 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1680 for Win32 and OSX. Fix by John Hunter.
1681 for Win32 and OSX. Fix by John Hunter.
1681
1682
1682 2004-08-30 *** Released version 0.6.3
1683 2004-08-30 *** Released version 0.6.3
1683
1684
1684 2004-08-30 Fernando Perez <fperez@colorado.edu>
1685 2004-08-30 Fernando Perez <fperez@colorado.edu>
1685
1686
1686 * setup.py (isfile): Add manpages to list of dependent files to be
1687 * setup.py (isfile): Add manpages to list of dependent files to be
1687 updated.
1688 updated.
1688
1689
1689 2004-08-27 Fernando Perez <fperez@colorado.edu>
1690 2004-08-27 Fernando Perez <fperez@colorado.edu>
1690
1691
1691 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1692 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1692 for now. They don't really work with standalone WX/GTK code
1693 for now. They don't really work with standalone WX/GTK code
1693 (though matplotlib IS working fine with both of those backends).
1694 (though matplotlib IS working fine with both of those backends).
1694 This will neeed much more testing. I disabled most things with
1695 This will neeed much more testing. I disabled most things with
1695 comments, so turning it back on later should be pretty easy.
1696 comments, so turning it back on later should be pretty easy.
1696
1697
1697 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1698 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1698 autocalling of expressions like r'foo', by modifying the line
1699 autocalling of expressions like r'foo', by modifying the line
1699 split regexp. Closes
1700 split regexp. Closes
1700 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1701 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1701 Riley <ipythonbugs-AT-sabi.net>.
1702 Riley <ipythonbugs-AT-sabi.net>.
1702 (InteractiveShell.mainloop): honor --nobanner with banner
1703 (InteractiveShell.mainloop): honor --nobanner with banner
1703 extensions.
1704 extensions.
1704
1705
1705 * IPython/Shell.py: Significant refactoring of all classes, so
1706 * IPython/Shell.py: Significant refactoring of all classes, so
1706 that we can really support ALL matplotlib backends and threading
1707 that we can really support ALL matplotlib backends and threading
1707 models (John spotted a bug with Tk which required this). Now we
1708 models (John spotted a bug with Tk which required this). Now we
1708 should support single-threaded, WX-threads and GTK-threads, both
1709 should support single-threaded, WX-threads and GTK-threads, both
1709 for generic code and for matplotlib.
1710 for generic code and for matplotlib.
1710
1711
1711 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1712 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1712 -pylab, to simplify things for users. Will also remove the pylab
1713 -pylab, to simplify things for users. Will also remove the pylab
1713 profile, since now all of matplotlib configuration is directly
1714 profile, since now all of matplotlib configuration is directly
1714 handled here. This also reduces startup time.
1715 handled here. This also reduces startup time.
1715
1716
1716 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1717 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1717 shell wasn't being correctly called. Also in IPShellWX.
1718 shell wasn't being correctly called. Also in IPShellWX.
1718
1719
1719 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1720 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1720 fine-tune banner.
1721 fine-tune banner.
1721
1722
1722 * IPython/numutils.py (spike): Deprecate these spike functions,
1723 * IPython/numutils.py (spike): Deprecate these spike functions,
1723 delete (long deprecated) gnuplot_exec handler.
1724 delete (long deprecated) gnuplot_exec handler.
1724
1725
1725 2004-08-26 Fernando Perez <fperez@colorado.edu>
1726 2004-08-26 Fernando Perez <fperez@colorado.edu>
1726
1727
1727 * ipython.1: Update for threading options, plus some others which
1728 * ipython.1: Update for threading options, plus some others which
1728 were missing.
1729 were missing.
1729
1730
1730 * IPython/ipmaker.py (__call__): Added -wthread option for
1731 * IPython/ipmaker.py (__call__): Added -wthread option for
1731 wxpython thread handling. Make sure threading options are only
1732 wxpython thread handling. Make sure threading options are only
1732 valid at the command line.
1733 valid at the command line.
1733
1734
1734 * scripts/ipython: moved shell selection into a factory function
1735 * scripts/ipython: moved shell selection into a factory function
1735 in Shell.py, to keep the starter script to a minimum.
1736 in Shell.py, to keep the starter script to a minimum.
1736
1737
1737 2004-08-25 Fernando Perez <fperez@colorado.edu>
1738 2004-08-25 Fernando Perez <fperez@colorado.edu>
1738
1739
1739 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1740 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1740 John. Along with some recent changes he made to matplotlib, the
1741 John. Along with some recent changes he made to matplotlib, the
1741 next versions of both systems should work very well together.
1742 next versions of both systems should work very well together.
1742
1743
1743 2004-08-24 Fernando Perez <fperez@colorado.edu>
1744 2004-08-24 Fernando Perez <fperez@colorado.edu>
1744
1745
1745 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1746 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1746 tried to switch the profiling to using hotshot, but I'm getting
1747 tried to switch the profiling to using hotshot, but I'm getting
1747 strange errors from prof.runctx() there. I may be misreading the
1748 strange errors from prof.runctx() there. I may be misreading the
1748 docs, but it looks weird. For now the profiling code will
1749 docs, but it looks weird. For now the profiling code will
1749 continue to use the standard profiler.
1750 continue to use the standard profiler.
1750
1751
1751 2004-08-23 Fernando Perez <fperez@colorado.edu>
1752 2004-08-23 Fernando Perez <fperez@colorado.edu>
1752
1753
1753 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1754 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1754 threaded shell, by John Hunter. It's not quite ready yet, but
1755 threaded shell, by John Hunter. It's not quite ready yet, but
1755 close.
1756 close.
1756
1757
1757 2004-08-22 Fernando Perez <fperez@colorado.edu>
1758 2004-08-22 Fernando Perez <fperez@colorado.edu>
1758
1759
1759 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1760 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1760 in Magic and ultraTB.
1761 in Magic and ultraTB.
1761
1762
1762 * ipython.1: document threading options in manpage.
1763 * ipython.1: document threading options in manpage.
1763
1764
1764 * scripts/ipython: Changed name of -thread option to -gthread,
1765 * scripts/ipython: Changed name of -thread option to -gthread,
1765 since this is GTK specific. I want to leave the door open for a
1766 since this is GTK specific. I want to leave the door open for a
1766 -wthread option for WX, which will most likely be necessary. This
1767 -wthread option for WX, which will most likely be necessary. This
1767 change affects usage and ipmaker as well.
1768 change affects usage and ipmaker as well.
1768
1769
1769 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1770 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1770 handle the matplotlib shell issues. Code by John Hunter
1771 handle the matplotlib shell issues. Code by John Hunter
1771 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1772 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1772 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1773 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1773 broken (and disabled for end users) for now, but it puts the
1774 broken (and disabled for end users) for now, but it puts the
1774 infrastructure in place.
1775 infrastructure in place.
1775
1776
1776 2004-08-21 Fernando Perez <fperez@colorado.edu>
1777 2004-08-21 Fernando Perez <fperez@colorado.edu>
1777
1778
1778 * ipythonrc-pylab: Add matplotlib support.
1779 * ipythonrc-pylab: Add matplotlib support.
1779
1780
1780 * matplotlib_config.py: new files for matplotlib support, part of
1781 * matplotlib_config.py: new files for matplotlib support, part of
1781 the pylab profile.
1782 the pylab profile.
1782
1783
1783 * IPython/usage.py (__doc__): documented the threading options.
1784 * IPython/usage.py (__doc__): documented the threading options.
1784
1785
1785 2004-08-20 Fernando Perez <fperez@colorado.edu>
1786 2004-08-20 Fernando Perez <fperez@colorado.edu>
1786
1787
1787 * ipython: Modified the main calling routine to handle the -thread
1788 * ipython: Modified the main calling routine to handle the -thread
1788 and -mpthread options. This needs to be done as a top-level hack,
1789 and -mpthread options. This needs to be done as a top-level hack,
1789 because it determines which class to instantiate for IPython
1790 because it determines which class to instantiate for IPython
1790 itself.
1791 itself.
1791
1792
1792 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1793 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1793 classes to support multithreaded GTK operation without blocking,
1794 classes to support multithreaded GTK operation without blocking,
1794 and matplotlib with all backends. This is a lot of still very
1795 and matplotlib with all backends. This is a lot of still very
1795 experimental code, and threads are tricky. So it may still have a
1796 experimental code, and threads are tricky. So it may still have a
1796 few rough edges... This code owes a lot to
1797 few rough edges... This code owes a lot to
1797 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1798 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1798 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1799 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1799 to John Hunter for all the matplotlib work.
1800 to John Hunter for all the matplotlib work.
1800
1801
1801 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1802 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1802 options for gtk thread and matplotlib support.
1803 options for gtk thread and matplotlib support.
1803
1804
1804 2004-08-16 Fernando Perez <fperez@colorado.edu>
1805 2004-08-16 Fernando Perez <fperez@colorado.edu>
1805
1806
1806 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1807 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1807 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1808 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1808 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1809 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1809
1810
1810 2004-08-11 Fernando Perez <fperez@colorado.edu>
1811 2004-08-11 Fernando Perez <fperez@colorado.edu>
1811
1812
1812 * setup.py (isfile): Fix build so documentation gets updated for
1813 * setup.py (isfile): Fix build so documentation gets updated for
1813 rpms (it was only done for .tgz builds).
1814 rpms (it was only done for .tgz builds).
1814
1815
1815 2004-08-10 Fernando Perez <fperez@colorado.edu>
1816 2004-08-10 Fernando Perez <fperez@colorado.edu>
1816
1817
1817 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1818 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1818
1819
1819 * iplib.py : Silence syntax error exceptions in tab-completion.
1820 * iplib.py : Silence syntax error exceptions in tab-completion.
1820
1821
1821 2004-08-05 Fernando Perez <fperez@colorado.edu>
1822 2004-08-05 Fernando Perez <fperez@colorado.edu>
1822
1823
1823 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1824 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1824 'color off' mark for continuation prompts. This was causing long
1825 'color off' mark for continuation prompts. This was causing long
1825 continuation lines to mis-wrap.
1826 continuation lines to mis-wrap.
1826
1827
1827 2004-08-01 Fernando Perez <fperez@colorado.edu>
1828 2004-08-01 Fernando Perez <fperez@colorado.edu>
1828
1829
1829 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1830 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1830 for building ipython to be a parameter. All this is necessary
1831 for building ipython to be a parameter. All this is necessary
1831 right now to have a multithreaded version, but this insane
1832 right now to have a multithreaded version, but this insane
1832 non-design will be cleaned up soon. For now, it's a hack that
1833 non-design will be cleaned up soon. For now, it's a hack that
1833 works.
1834 works.
1834
1835
1835 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1836 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1836 args in various places. No bugs so far, but it's a dangerous
1837 args in various places. No bugs so far, but it's a dangerous
1837 practice.
1838 practice.
1838
1839
1839 2004-07-31 Fernando Perez <fperez@colorado.edu>
1840 2004-07-31 Fernando Perez <fperez@colorado.edu>
1840
1841
1841 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1842 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1842 fix completion of files with dots in their names under most
1843 fix completion of files with dots in their names under most
1843 profiles (pysh was OK because the completion order is different).
1844 profiles (pysh was OK because the completion order is different).
1844
1845
1845 2004-07-27 Fernando Perez <fperez@colorado.edu>
1846 2004-07-27 Fernando Perez <fperez@colorado.edu>
1846
1847
1847 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1848 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1848 keywords manually, b/c the one in keyword.py was removed in python
1849 keywords manually, b/c the one in keyword.py was removed in python
1849 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1850 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1850 This is NOT a bug under python 2.3 and earlier.
1851 This is NOT a bug under python 2.3 and earlier.
1851
1852
1852 2004-07-26 Fernando Perez <fperez@colorado.edu>
1853 2004-07-26 Fernando Perez <fperez@colorado.edu>
1853
1854
1854 * IPython/ultraTB.py (VerboseTB.text): Add another
1855 * IPython/ultraTB.py (VerboseTB.text): Add another
1855 linecache.checkcache() call to try to prevent inspect.py from
1856 linecache.checkcache() call to try to prevent inspect.py from
1856 crashing under python 2.3. I think this fixes
1857 crashing under python 2.3. I think this fixes
1857 http://www.scipy.net/roundup/ipython/issue17.
1858 http://www.scipy.net/roundup/ipython/issue17.
1858
1859
1859 2004-07-26 *** Released version 0.6.2
1860 2004-07-26 *** Released version 0.6.2
1860
1861
1861 2004-07-26 Fernando Perez <fperez@colorado.edu>
1862 2004-07-26 Fernando Perez <fperez@colorado.edu>
1862
1863
1863 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1864 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1864 fail for any number.
1865 fail for any number.
1865 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1866 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1866 empty bookmarks.
1867 empty bookmarks.
1867
1868
1868 2004-07-26 *** Released version 0.6.1
1869 2004-07-26 *** Released version 0.6.1
1869
1870
1870 2004-07-26 Fernando Perez <fperez@colorado.edu>
1871 2004-07-26 Fernando Perez <fperez@colorado.edu>
1871
1872
1872 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1873 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1873
1874
1874 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1875 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1875 escaping '()[]{}' in filenames.
1876 escaping '()[]{}' in filenames.
1876
1877
1877 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1878 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1878 Python 2.2 users who lack a proper shlex.split.
1879 Python 2.2 users who lack a proper shlex.split.
1879
1880
1880 2004-07-19 Fernando Perez <fperez@colorado.edu>
1881 2004-07-19 Fernando Perez <fperez@colorado.edu>
1881
1882
1882 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1883 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1883 for reading readline's init file. I follow the normal chain:
1884 for reading readline's init file. I follow the normal chain:
1884 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1885 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1885 report by Mike Heeter. This closes
1886 report by Mike Heeter. This closes
1886 http://www.scipy.net/roundup/ipython/issue16.
1887 http://www.scipy.net/roundup/ipython/issue16.
1887
1888
1888 2004-07-18 Fernando Perez <fperez@colorado.edu>
1889 2004-07-18 Fernando Perez <fperez@colorado.edu>
1889
1890
1890 * IPython/iplib.py (__init__): Add better handling of '\' under
1891 * IPython/iplib.py (__init__): Add better handling of '\' under
1891 Win32 for filenames. After a patch by Ville.
1892 Win32 for filenames. After a patch by Ville.
1892
1893
1893 2004-07-17 Fernando Perez <fperez@colorado.edu>
1894 2004-07-17 Fernando Perez <fperez@colorado.edu>
1894
1895
1895 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1896 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1896 autocalling would be triggered for 'foo is bar' if foo is
1897 autocalling would be triggered for 'foo is bar' if foo is
1897 callable. I also cleaned up the autocall detection code to use a
1898 callable. I also cleaned up the autocall detection code to use a
1898 regexp, which is faster. Bug reported by Alexander Schmolck.
1899 regexp, which is faster. Bug reported by Alexander Schmolck.
1899
1900
1900 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1901 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1901 '?' in them would confuse the help system. Reported by Alex
1902 '?' in them would confuse the help system. Reported by Alex
1902 Schmolck.
1903 Schmolck.
1903
1904
1904 2004-07-16 Fernando Perez <fperez@colorado.edu>
1905 2004-07-16 Fernando Perez <fperez@colorado.edu>
1905
1906
1906 * IPython/GnuplotInteractive.py (__all__): added plot2.
1907 * IPython/GnuplotInteractive.py (__all__): added plot2.
1907
1908
1908 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1909 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1909 plotting dictionaries, lists or tuples of 1d arrays.
1910 plotting dictionaries, lists or tuples of 1d arrays.
1910
1911
1911 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1912 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1912 optimizations.
1913 optimizations.
1913
1914
1914 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1915 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1915 the information which was there from Janko's original IPP code:
1916 the information which was there from Janko's original IPP code:
1916
1917
1917 03.05.99 20:53 porto.ifm.uni-kiel.de
1918 03.05.99 20:53 porto.ifm.uni-kiel.de
1918 --Started changelog.
1919 --Started changelog.
1919 --make clear do what it say it does
1920 --make clear do what it say it does
1920 --added pretty output of lines from inputcache
1921 --added pretty output of lines from inputcache
1921 --Made Logger a mixin class, simplifies handling of switches
1922 --Made Logger a mixin class, simplifies handling of switches
1922 --Added own completer class. .string<TAB> expands to last history
1923 --Added own completer class. .string<TAB> expands to last history
1923 line which starts with string. The new expansion is also present
1924 line which starts with string. The new expansion is also present
1924 with Ctrl-r from the readline library. But this shows, who this
1925 with Ctrl-r from the readline library. But this shows, who this
1925 can be done for other cases.
1926 can be done for other cases.
1926 --Added convention that all shell functions should accept a
1927 --Added convention that all shell functions should accept a
1927 parameter_string This opens the door for different behaviour for
1928 parameter_string This opens the door for different behaviour for
1928 each function. @cd is a good example of this.
1929 each function. @cd is a good example of this.
1929
1930
1930 04.05.99 12:12 porto.ifm.uni-kiel.de
1931 04.05.99 12:12 porto.ifm.uni-kiel.de
1931 --added logfile rotation
1932 --added logfile rotation
1932 --added new mainloop method which freezes first the namespace
1933 --added new mainloop method which freezes first the namespace
1933
1934
1934 07.05.99 21:24 porto.ifm.uni-kiel.de
1935 07.05.99 21:24 porto.ifm.uni-kiel.de
1935 --added the docreader classes. Now there is a help system.
1936 --added the docreader classes. Now there is a help system.
1936 -This is only a first try. Currently it's not easy to put new
1937 -This is only a first try. Currently it's not easy to put new
1937 stuff in the indices. But this is the way to go. Info would be
1938 stuff in the indices. But this is the way to go. Info would be
1938 better, but HTML is every where and not everybody has an info
1939 better, but HTML is every where and not everybody has an info
1939 system installed and it's not so easy to change html-docs to info.
1940 system installed and it's not so easy to change html-docs to info.
1940 --added global logfile option
1941 --added global logfile option
1941 --there is now a hook for object inspection method pinfo needs to
1942 --there is now a hook for object inspection method pinfo needs to
1942 be provided for this. Can be reached by two '??'.
1943 be provided for this. Can be reached by two '??'.
1943
1944
1944 08.05.99 20:51 porto.ifm.uni-kiel.de
1945 08.05.99 20:51 porto.ifm.uni-kiel.de
1945 --added a README
1946 --added a README
1946 --bug in rc file. Something has changed so functions in the rc
1947 --bug in rc file. Something has changed so functions in the rc
1947 file need to reference the shell and not self. Not clear if it's a
1948 file need to reference the shell and not self. Not clear if it's a
1948 bug or feature.
1949 bug or feature.
1949 --changed rc file for new behavior
1950 --changed rc file for new behavior
1950
1951
1951 2004-07-15 Fernando Perez <fperez@colorado.edu>
1952 2004-07-15 Fernando Perez <fperez@colorado.edu>
1952
1953
1953 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1954 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1954 cache was falling out of sync in bizarre manners when multi-line
1955 cache was falling out of sync in bizarre manners when multi-line
1955 input was present. Minor optimizations and cleanup.
1956 input was present. Minor optimizations and cleanup.
1956
1957
1957 (Logger): Remove old Changelog info for cleanup. This is the
1958 (Logger): Remove old Changelog info for cleanup. This is the
1958 information which was there from Janko's original code:
1959 information which was there from Janko's original code:
1959
1960
1960 Changes to Logger: - made the default log filename a parameter
1961 Changes to Logger: - made the default log filename a parameter
1961
1962
1962 - put a check for lines beginning with !@? in log(). Needed
1963 - put a check for lines beginning with !@? in log(). Needed
1963 (even if the handlers properly log their lines) for mid-session
1964 (even if the handlers properly log their lines) for mid-session
1964 logging activation to work properly. Without this, lines logged
1965 logging activation to work properly. Without this, lines logged
1965 in mid session, which get read from the cache, would end up
1966 in mid session, which get read from the cache, would end up
1966 'bare' (with !@? in the open) in the log. Now they are caught
1967 'bare' (with !@? in the open) in the log. Now they are caught
1967 and prepended with a #.
1968 and prepended with a #.
1968
1969
1969 * IPython/iplib.py (InteractiveShell.init_readline): added check
1970 * IPython/iplib.py (InteractiveShell.init_readline): added check
1970 in case MagicCompleter fails to be defined, so we don't crash.
1971 in case MagicCompleter fails to be defined, so we don't crash.
1971
1972
1972 2004-07-13 Fernando Perez <fperez@colorado.edu>
1973 2004-07-13 Fernando Perez <fperez@colorado.edu>
1973
1974
1974 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1975 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1975 of EPS if the requested filename ends in '.eps'.
1976 of EPS if the requested filename ends in '.eps'.
1976
1977
1977 2004-07-04 Fernando Perez <fperez@colorado.edu>
1978 2004-07-04 Fernando Perez <fperez@colorado.edu>
1978
1979
1979 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1980 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1980 escaping of quotes when calling the shell.
1981 escaping of quotes when calling the shell.
1981
1982
1982 2004-07-02 Fernando Perez <fperez@colorado.edu>
1983 2004-07-02 Fernando Perez <fperez@colorado.edu>
1983
1984
1984 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1985 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1985 gettext not working because we were clobbering '_'. Fixes
1986 gettext not working because we were clobbering '_'. Fixes
1986 http://www.scipy.net/roundup/ipython/issue6.
1987 http://www.scipy.net/roundup/ipython/issue6.
1987
1988
1988 2004-07-01 Fernando Perez <fperez@colorado.edu>
1989 2004-07-01 Fernando Perez <fperez@colorado.edu>
1989
1990
1990 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1991 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1991 into @cd. Patch by Ville.
1992 into @cd. Patch by Ville.
1992
1993
1993 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1994 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1994 new function to store things after ipmaker runs. Patch by Ville.
1995 new function to store things after ipmaker runs. Patch by Ville.
1995 Eventually this will go away once ipmaker is removed and the class
1996 Eventually this will go away once ipmaker is removed and the class
1996 gets cleaned up, but for now it's ok. Key functionality here is
1997 gets cleaned up, but for now it's ok. Key functionality here is
1997 the addition of the persistent storage mechanism, a dict for
1998 the addition of the persistent storage mechanism, a dict for
1998 keeping data across sessions (for now just bookmarks, but more can
1999 keeping data across sessions (for now just bookmarks, but more can
1999 be implemented later).
2000 be implemented later).
2000
2001
2001 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
2002 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
2002 persistent across sections. Patch by Ville, I modified it
2003 persistent across sections. Patch by Ville, I modified it
2003 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
2004 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
2004 added a '-l' option to list all bookmarks.
2005 added a '-l' option to list all bookmarks.
2005
2006
2006 * IPython/iplib.py (InteractiveShell.atexit_operations): new
2007 * IPython/iplib.py (InteractiveShell.atexit_operations): new
2007 center for cleanup. Registered with atexit.register(). I moved
2008 center for cleanup. Registered with atexit.register(). I moved
2008 here the old exit_cleanup(). After a patch by Ville.
2009 here the old exit_cleanup(). After a patch by Ville.
2009
2010
2010 * IPython/Magic.py (get_py_filename): added '~' to the accepted
2011 * IPython/Magic.py (get_py_filename): added '~' to the accepted
2011 characters in the hacked shlex_split for python 2.2.
2012 characters in the hacked shlex_split for python 2.2.
2012
2013
2013 * IPython/iplib.py (file_matches): more fixes to filenames with
2014 * IPython/iplib.py (file_matches): more fixes to filenames with
2014 whitespace in them. It's not perfect, but limitations in python's
2015 whitespace in them. It's not perfect, but limitations in python's
2015 readline make it impossible to go further.
2016 readline make it impossible to go further.
2016
2017
2017 2004-06-29 Fernando Perez <fperez@colorado.edu>
2018 2004-06-29 Fernando Perez <fperez@colorado.edu>
2018
2019
2019 * IPython/iplib.py (file_matches): escape whitespace correctly in
2020 * IPython/iplib.py (file_matches): escape whitespace correctly in
2020 filename completions. Bug reported by Ville.
2021 filename completions. Bug reported by Ville.
2021
2022
2022 2004-06-28 Fernando Perez <fperez@colorado.edu>
2023 2004-06-28 Fernando Perez <fperez@colorado.edu>
2023
2024
2024 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
2025 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
2025 the history file will be called 'history-PROFNAME' (or just
2026 the history file will be called 'history-PROFNAME' (or just
2026 'history' if no profile is loaded). I was getting annoyed at
2027 'history' if no profile is loaded). I was getting annoyed at
2027 getting my Numerical work history clobbered by pysh sessions.
2028 getting my Numerical work history clobbered by pysh sessions.
2028
2029
2029 * IPython/iplib.py (InteractiveShell.__init__): Internal
2030 * IPython/iplib.py (InteractiveShell.__init__): Internal
2030 getoutputerror() function so that we can honor the system_verbose
2031 getoutputerror() function so that we can honor the system_verbose
2031 flag for _all_ system calls. I also added escaping of #
2032 flag for _all_ system calls. I also added escaping of #
2032 characters here to avoid confusing Itpl.
2033 characters here to avoid confusing Itpl.
2033
2034
2034 * IPython/Magic.py (shlex_split): removed call to shell in
2035 * IPython/Magic.py (shlex_split): removed call to shell in
2035 parse_options and replaced it with shlex.split(). The annoying
2036 parse_options and replaced it with shlex.split(). The annoying
2036 part was that in Python 2.2, shlex.split() doesn't exist, so I had
2037 part was that in Python 2.2, shlex.split() doesn't exist, so I had
2037 to backport it from 2.3, with several frail hacks (the shlex
2038 to backport it from 2.3, with several frail hacks (the shlex
2038 module is rather limited in 2.2). Thanks to a suggestion by Ville
2039 module is rather limited in 2.2). Thanks to a suggestion by Ville
2039 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
2040 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
2040 problem.
2041 problem.
2041
2042
2042 (Magic.magic_system_verbose): new toggle to print the actual
2043 (Magic.magic_system_verbose): new toggle to print the actual
2043 system calls made by ipython. Mainly for debugging purposes.
2044 system calls made by ipython. Mainly for debugging purposes.
2044
2045
2045 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
2046 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
2046 doesn't support persistence. Reported (and fix suggested) by
2047 doesn't support persistence. Reported (and fix suggested) by
2047 Travis Caldwell <travis_caldwell2000@yahoo.com>.
2048 Travis Caldwell <travis_caldwell2000@yahoo.com>.
2048
2049
2049 2004-06-26 Fernando Perez <fperez@colorado.edu>
2050 2004-06-26 Fernando Perez <fperez@colorado.edu>
2050
2051
2051 * IPython/Logger.py (Logger.log): fix to handle correctly empty
2052 * IPython/Logger.py (Logger.log): fix to handle correctly empty
2052 continue prompts.
2053 continue prompts.
2053
2054
2054 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
2055 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
2055 function (basically a big docstring) and a few more things here to
2056 function (basically a big docstring) and a few more things here to
2056 speedup startup. pysh.py is now very lightweight. We want because
2057 speedup startup. pysh.py is now very lightweight. We want because
2057 it gets execfile'd, while InterpreterExec gets imported, so
2058 it gets execfile'd, while InterpreterExec gets imported, so
2058 byte-compilation saves time.
2059 byte-compilation saves time.
2059
2060
2060 2004-06-25 Fernando Perez <fperez@colorado.edu>
2061 2004-06-25 Fernando Perez <fperez@colorado.edu>
2061
2062
2062 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
2063 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
2063 -NUM', which was recently broken.
2064 -NUM', which was recently broken.
2064
2065
2065 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
2066 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
2066 in multi-line input (but not !!, which doesn't make sense there).
2067 in multi-line input (but not !!, which doesn't make sense there).
2067
2068
2068 * IPython/UserConfig/ipythonrc: made autoindent on by default.
2069 * IPython/UserConfig/ipythonrc: made autoindent on by default.
2069 It's just too useful, and people can turn it off in the less
2070 It's just too useful, and people can turn it off in the less
2070 common cases where it's a problem.
2071 common cases where it's a problem.
2071
2072
2072 2004-06-24 Fernando Perez <fperez@colorado.edu>
2073 2004-06-24 Fernando Perez <fperez@colorado.edu>
2073
2074
2074 * IPython/iplib.py (InteractiveShell._prefilter): big change -
2075 * IPython/iplib.py (InteractiveShell._prefilter): big change -
2075 special syntaxes (like alias calling) is now allied in multi-line
2076 special syntaxes (like alias calling) is now allied in multi-line
2076 input. This is still _very_ experimental, but it's necessary for
2077 input. This is still _very_ experimental, but it's necessary for
2077 efficient shell usage combining python looping syntax with system
2078 efficient shell usage combining python looping syntax with system
2078 calls. For now it's restricted to aliases, I don't think it
2079 calls. For now it's restricted to aliases, I don't think it
2079 really even makes sense to have this for magics.
2080 really even makes sense to have this for magics.
2080
2081
2081 2004-06-23 Fernando Perez <fperez@colorado.edu>
2082 2004-06-23 Fernando Perez <fperez@colorado.edu>
2082
2083
2083 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
2084 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
2084 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
2085 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
2085
2086
2086 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
2087 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
2087 extensions under Windows (after code sent by Gary Bishop). The
2088 extensions under Windows (after code sent by Gary Bishop). The
2088 extensions considered 'executable' are stored in IPython's rc
2089 extensions considered 'executable' are stored in IPython's rc
2089 structure as win_exec_ext.
2090 structure as win_exec_ext.
2090
2091
2091 * IPython/genutils.py (shell): new function, like system() but
2092 * IPython/genutils.py (shell): new function, like system() but
2092 without return value. Very useful for interactive shell work.
2093 without return value. Very useful for interactive shell work.
2093
2094
2094 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
2095 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
2095 delete aliases.
2096 delete aliases.
2096
2097
2097 * IPython/iplib.py (InteractiveShell.alias_table_update): make
2098 * IPython/iplib.py (InteractiveShell.alias_table_update): make
2098 sure that the alias table doesn't contain python keywords.
2099 sure that the alias table doesn't contain python keywords.
2099
2100
2100 2004-06-21 Fernando Perez <fperez@colorado.edu>
2101 2004-06-21 Fernando Perez <fperez@colorado.edu>
2101
2102
2102 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
2103 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
2103 non-existent items are found in $PATH. Reported by Thorsten.
2104 non-existent items are found in $PATH. Reported by Thorsten.
2104
2105
2105 2004-06-20 Fernando Perez <fperez@colorado.edu>
2106 2004-06-20 Fernando Perez <fperez@colorado.edu>
2106
2107
2107 * IPython/iplib.py (complete): modified the completer so that the
2108 * IPython/iplib.py (complete): modified the completer so that the
2108 order of priorities can be easily changed at runtime.
2109 order of priorities can be easily changed at runtime.
2109
2110
2110 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
2111 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
2111 Modified to auto-execute all lines beginning with '~', '/' or '.'.
2112 Modified to auto-execute all lines beginning with '~', '/' or '.'.
2112
2113
2113 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
2114 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
2114 expand Python variables prepended with $ in all system calls. The
2115 expand Python variables prepended with $ in all system calls. The
2115 same was done to InteractiveShell.handle_shell_escape. Now all
2116 same was done to InteractiveShell.handle_shell_escape. Now all
2116 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
2117 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
2117 expansion of python variables and expressions according to the
2118 expansion of python variables and expressions according to the
2118 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
2119 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
2119
2120
2120 Though PEP-215 has been rejected, a similar (but simpler) one
2121 Though PEP-215 has been rejected, a similar (but simpler) one
2121 seems like it will go into Python 2.4, PEP-292 -
2122 seems like it will go into Python 2.4, PEP-292 -
2122 http://www.python.org/peps/pep-0292.html.
2123 http://www.python.org/peps/pep-0292.html.
2123
2124
2124 I'll keep the full syntax of PEP-215, since IPython has since the
2125 I'll keep the full syntax of PEP-215, since IPython has since the
2125 start used Ka-Ping Yee's reference implementation discussed there
2126 start used Ka-Ping Yee's reference implementation discussed there
2126 (Itpl), and I actually like the powerful semantics it offers.
2127 (Itpl), and I actually like the powerful semantics it offers.
2127
2128
2128 In order to access normal shell variables, the $ has to be escaped
2129 In order to access normal shell variables, the $ has to be escaped
2129 via an extra $. For example:
2130 via an extra $. For example:
2130
2131
2131 In [7]: PATH='a python variable'
2132 In [7]: PATH='a python variable'
2132
2133
2133 In [8]: !echo $PATH
2134 In [8]: !echo $PATH
2134 a python variable
2135 a python variable
2135
2136
2136 In [9]: !echo $$PATH
2137 In [9]: !echo $$PATH
2137 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2138 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2138
2139
2139 (Magic.parse_options): escape $ so the shell doesn't evaluate
2140 (Magic.parse_options): escape $ so the shell doesn't evaluate
2140 things prematurely.
2141 things prematurely.
2141
2142
2142 * IPython/iplib.py (InteractiveShell.call_alias): added the
2143 * IPython/iplib.py (InteractiveShell.call_alias): added the
2143 ability for aliases to expand python variables via $.
2144 ability for aliases to expand python variables via $.
2144
2145
2145 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
2146 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
2146 system, now there's a @rehash/@rehashx pair of magics. These work
2147 system, now there's a @rehash/@rehashx pair of magics. These work
2147 like the csh rehash command, and can be invoked at any time. They
2148 like the csh rehash command, and can be invoked at any time. They
2148 build a table of aliases to everything in the user's $PATH
2149 build a table of aliases to everything in the user's $PATH
2149 (@rehash uses everything, @rehashx is slower but only adds
2150 (@rehash uses everything, @rehashx is slower but only adds
2150 executable files). With this, the pysh.py-based shell profile can
2151 executable files). With this, the pysh.py-based shell profile can
2151 now simply call rehash upon startup, and full access to all
2152 now simply call rehash upon startup, and full access to all
2152 programs in the user's path is obtained.
2153 programs in the user's path is obtained.
2153
2154
2154 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
2155 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
2155 functionality is now fully in place. I removed the old dynamic
2156 functionality is now fully in place. I removed the old dynamic
2156 code generation based approach, in favor of a much lighter one
2157 code generation based approach, in favor of a much lighter one
2157 based on a simple dict. The advantage is that this allows me to
2158 based on a simple dict. The advantage is that this allows me to
2158 now have thousands of aliases with negligible cost (unthinkable
2159 now have thousands of aliases with negligible cost (unthinkable
2159 with the old system).
2160 with the old system).
2160
2161
2161 2004-06-19 Fernando Perez <fperez@colorado.edu>
2162 2004-06-19 Fernando Perez <fperez@colorado.edu>
2162
2163
2163 * IPython/iplib.py (__init__): extended MagicCompleter class to
2164 * IPython/iplib.py (__init__): extended MagicCompleter class to
2164 also complete (last in priority) on user aliases.
2165 also complete (last in priority) on user aliases.
2165
2166
2166 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
2167 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
2167 call to eval.
2168 call to eval.
2168 (ItplNS.__init__): Added a new class which functions like Itpl,
2169 (ItplNS.__init__): Added a new class which functions like Itpl,
2169 but allows configuring the namespace for the evaluation to occur
2170 but allows configuring the namespace for the evaluation to occur
2170 in.
2171 in.
2171
2172
2172 2004-06-18 Fernando Perez <fperez@colorado.edu>
2173 2004-06-18 Fernando Perez <fperez@colorado.edu>
2173
2174
2174 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
2175 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
2175 better message when 'exit' or 'quit' are typed (a common newbie
2176 better message when 'exit' or 'quit' are typed (a common newbie
2176 confusion).
2177 confusion).
2177
2178
2178 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
2179 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
2179 check for Windows users.
2180 check for Windows users.
2180
2181
2181 * IPython/iplib.py (InteractiveShell.user_setup): removed
2182 * IPython/iplib.py (InteractiveShell.user_setup): removed
2182 disabling of colors for Windows. I'll test at runtime and issue a
2183 disabling of colors for Windows. I'll test at runtime and issue a
2183 warning if Gary's readline isn't found, as to nudge users to
2184 warning if Gary's readline isn't found, as to nudge users to
2184 download it.
2185 download it.
2185
2186
2186 2004-06-16 Fernando Perez <fperez@colorado.edu>
2187 2004-06-16 Fernando Perez <fperez@colorado.edu>
2187
2188
2188 * IPython/genutils.py (Stream.__init__): changed to print errors
2189 * IPython/genutils.py (Stream.__init__): changed to print errors
2189 to sys.stderr. I had a circular dependency here. Now it's
2190 to sys.stderr. I had a circular dependency here. Now it's
2190 possible to run ipython as IDLE's shell (consider this pre-alpha,
2191 possible to run ipython as IDLE's shell (consider this pre-alpha,
2191 since true stdout things end up in the starting terminal instead
2192 since true stdout things end up in the starting terminal instead
2192 of IDLE's out).
2193 of IDLE's out).
2193
2194
2194 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
2195 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
2195 users who haven't # updated their prompt_in2 definitions. Remove
2196 users who haven't # updated their prompt_in2 definitions. Remove
2196 eventually.
2197 eventually.
2197 (multiple_replace): added credit to original ASPN recipe.
2198 (multiple_replace): added credit to original ASPN recipe.
2198
2199
2199 2004-06-15 Fernando Perez <fperez@colorado.edu>
2200 2004-06-15 Fernando Perez <fperez@colorado.edu>
2200
2201
2201 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
2202 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
2202 list of auto-defined aliases.
2203 list of auto-defined aliases.
2203
2204
2204 2004-06-13 Fernando Perez <fperez@colorado.edu>
2205 2004-06-13 Fernando Perez <fperez@colorado.edu>
2205
2206
2206 * setup.py (scriptfiles): Don't trigger win_post_install unless an
2207 * setup.py (scriptfiles): Don't trigger win_post_install unless an
2207 install was really requested (so setup.py can be used for other
2208 install was really requested (so setup.py can be used for other
2208 things under Windows).
2209 things under Windows).
2209
2210
2210 2004-06-10 Fernando Perez <fperez@colorado.edu>
2211 2004-06-10 Fernando Perez <fperez@colorado.edu>
2211
2212
2212 * IPython/Logger.py (Logger.create_log): Manually remove any old
2213 * IPython/Logger.py (Logger.create_log): Manually remove any old
2213 backup, since os.remove may fail under Windows. Fixes bug
2214 backup, since os.remove may fail under Windows. Fixes bug
2214 reported by Thorsten.
2215 reported by Thorsten.
2215
2216
2216 2004-06-09 Fernando Perez <fperez@colorado.edu>
2217 2004-06-09 Fernando Perez <fperez@colorado.edu>
2217
2218
2218 * examples/example-embed.py: fixed all references to %n (replaced
2219 * examples/example-embed.py: fixed all references to %n (replaced
2219 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
2220 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
2220 for all examples and the manual as well.
2221 for all examples and the manual as well.
2221
2222
2222 2004-06-08 Fernando Perez <fperez@colorado.edu>
2223 2004-06-08 Fernando Perez <fperez@colorado.edu>
2223
2224
2224 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2225 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2225 alignment and color management. All 3 prompt subsystems now
2226 alignment and color management. All 3 prompt subsystems now
2226 inherit from BasePrompt.
2227 inherit from BasePrompt.
2227
2228
2228 * tools/release: updates for windows installer build and tag rpms
2229 * tools/release: updates for windows installer build and tag rpms
2229 with python version (since paths are fixed).
2230 with python version (since paths are fixed).
2230
2231
2231 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2232 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2232 which will become eventually obsolete. Also fixed the default
2233 which will become eventually obsolete. Also fixed the default
2233 prompt_in2 to use \D, so at least new users start with the correct
2234 prompt_in2 to use \D, so at least new users start with the correct
2234 defaults.
2235 defaults.
2235 WARNING: Users with existing ipythonrc files will need to apply
2236 WARNING: Users with existing ipythonrc files will need to apply
2236 this fix manually!
2237 this fix manually!
2237
2238
2238 * setup.py: make windows installer (.exe). This is finally the
2239 * setup.py: make windows installer (.exe). This is finally the
2239 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2240 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2240 which I hadn't included because it required Python 2.3 (or recent
2241 which I hadn't included because it required Python 2.3 (or recent
2241 distutils).
2242 distutils).
2242
2243
2243 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2244 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2244 usage of new '\D' escape.
2245 usage of new '\D' escape.
2245
2246
2246 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2247 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2247 lacks os.getuid())
2248 lacks os.getuid())
2248 (CachedOutput.set_colors): Added the ability to turn coloring
2249 (CachedOutput.set_colors): Added the ability to turn coloring
2249 on/off with @colors even for manually defined prompt colors. It
2250 on/off with @colors even for manually defined prompt colors. It
2250 uses a nasty global, but it works safely and via the generic color
2251 uses a nasty global, but it works safely and via the generic color
2251 handling mechanism.
2252 handling mechanism.
2252 (Prompt2.__init__): Introduced new escape '\D' for continuation
2253 (Prompt2.__init__): Introduced new escape '\D' for continuation
2253 prompts. It represents the counter ('\#') as dots.
2254 prompts. It represents the counter ('\#') as dots.
2254 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2255 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2255 need to update their ipythonrc files and replace '%n' with '\D' in
2256 need to update their ipythonrc files and replace '%n' with '\D' in
2256 their prompt_in2 settings everywhere. Sorry, but there's
2257 their prompt_in2 settings everywhere. Sorry, but there's
2257 otherwise no clean way to get all prompts to properly align. The
2258 otherwise no clean way to get all prompts to properly align. The
2258 ipythonrc shipped with IPython has been updated.
2259 ipythonrc shipped with IPython has been updated.
2259
2260
2260 2004-06-07 Fernando Perez <fperez@colorado.edu>
2261 2004-06-07 Fernando Perez <fperez@colorado.edu>
2261
2262
2262 * setup.py (isfile): Pass local_icons option to latex2html, so the
2263 * setup.py (isfile): Pass local_icons option to latex2html, so the
2263 resulting HTML file is self-contained. Thanks to
2264 resulting HTML file is self-contained. Thanks to
2264 dryice-AT-liu.com.cn for the tip.
2265 dryice-AT-liu.com.cn for the tip.
2265
2266
2266 * pysh.py: I created a new profile 'shell', which implements a
2267 * pysh.py: I created a new profile 'shell', which implements a
2267 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2268 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2268 system shell, nor will it become one anytime soon. It's mainly
2269 system shell, nor will it become one anytime soon. It's mainly
2269 meant to illustrate the use of the new flexible bash-like prompts.
2270 meant to illustrate the use of the new flexible bash-like prompts.
2270 I guess it could be used by hardy souls for true shell management,
2271 I guess it could be used by hardy souls for true shell management,
2271 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2272 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2272 profile. This uses the InterpreterExec extension provided by
2273 profile. This uses the InterpreterExec extension provided by
2273 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2274 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2274
2275
2275 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2276 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2276 auto-align itself with the length of the previous input prompt
2277 auto-align itself with the length of the previous input prompt
2277 (taking into account the invisible color escapes).
2278 (taking into account the invisible color escapes).
2278 (CachedOutput.__init__): Large restructuring of this class. Now
2279 (CachedOutput.__init__): Large restructuring of this class. Now
2279 all three prompts (primary1, primary2, output) are proper objects,
2280 all three prompts (primary1, primary2, output) are proper objects,
2280 managed by the 'parent' CachedOutput class. The code is still a
2281 managed by the 'parent' CachedOutput class. The code is still a
2281 bit hackish (all prompts share state via a pointer to the cache),
2282 bit hackish (all prompts share state via a pointer to the cache),
2282 but it's overall far cleaner than before.
2283 but it's overall far cleaner than before.
2283
2284
2284 * IPython/genutils.py (getoutputerror): modified to add verbose,
2285 * IPython/genutils.py (getoutputerror): modified to add verbose,
2285 debug and header options. This makes the interface of all getout*
2286 debug and header options. This makes the interface of all getout*
2286 functions uniform.
2287 functions uniform.
2287 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2288 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2288
2289
2289 * IPython/Magic.py (Magic.default_option): added a function to
2290 * IPython/Magic.py (Magic.default_option): added a function to
2290 allow registering default options for any magic command. This
2291 allow registering default options for any magic command. This
2291 makes it easy to have profiles which customize the magics globally
2292 makes it easy to have profiles which customize the magics globally
2292 for a certain use. The values set through this function are
2293 for a certain use. The values set through this function are
2293 picked up by the parse_options() method, which all magics should
2294 picked up by the parse_options() method, which all magics should
2294 use to parse their options.
2295 use to parse their options.
2295
2296
2296 * IPython/genutils.py (warn): modified the warnings framework to
2297 * IPython/genutils.py (warn): modified the warnings framework to
2297 use the Term I/O class. I'm trying to slowly unify all of
2298 use the Term I/O class. I'm trying to slowly unify all of
2298 IPython's I/O operations to pass through Term.
2299 IPython's I/O operations to pass through Term.
2299
2300
2300 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2301 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2301 the secondary prompt to correctly match the length of the primary
2302 the secondary prompt to correctly match the length of the primary
2302 one for any prompt. Now multi-line code will properly line up
2303 one for any prompt. Now multi-line code will properly line up
2303 even for path dependent prompts, such as the new ones available
2304 even for path dependent prompts, such as the new ones available
2304 via the prompt_specials.
2305 via the prompt_specials.
2305
2306
2306 2004-06-06 Fernando Perez <fperez@colorado.edu>
2307 2004-06-06 Fernando Perez <fperez@colorado.edu>
2307
2308
2308 * IPython/Prompts.py (prompt_specials): Added the ability to have
2309 * IPython/Prompts.py (prompt_specials): Added the ability to have
2309 bash-like special sequences in the prompts, which get
2310 bash-like special sequences in the prompts, which get
2310 automatically expanded. Things like hostname, current working
2311 automatically expanded. Things like hostname, current working
2311 directory and username are implemented already, but it's easy to
2312 directory and username are implemented already, but it's easy to
2312 add more in the future. Thanks to a patch by W.J. van der Laan
2313 add more in the future. Thanks to a patch by W.J. van der Laan
2313 <gnufnork-AT-hetdigitalegat.nl>
2314 <gnufnork-AT-hetdigitalegat.nl>
2314 (prompt_specials): Added color support for prompt strings, so
2315 (prompt_specials): Added color support for prompt strings, so
2315 users can define arbitrary color setups for their prompts.
2316 users can define arbitrary color setups for their prompts.
2316
2317
2317 2004-06-05 Fernando Perez <fperez@colorado.edu>
2318 2004-06-05 Fernando Perez <fperez@colorado.edu>
2318
2319
2319 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2320 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2320 code to load Gary Bishop's readline and configure it
2321 code to load Gary Bishop's readline and configure it
2321 automatically. Thanks to Gary for help on this.
2322 automatically. Thanks to Gary for help on this.
2322
2323
2323 2004-06-01 Fernando Perez <fperez@colorado.edu>
2324 2004-06-01 Fernando Perez <fperez@colorado.edu>
2324
2325
2325 * IPython/Logger.py (Logger.create_log): fix bug for logging
2326 * IPython/Logger.py (Logger.create_log): fix bug for logging
2326 with no filename (previous fix was incomplete).
2327 with no filename (previous fix was incomplete).
2327
2328
2328 2004-05-25 Fernando Perez <fperez@colorado.edu>
2329 2004-05-25 Fernando Perez <fperez@colorado.edu>
2329
2330
2330 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2331 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2331 parens would get passed to the shell.
2332 parens would get passed to the shell.
2332
2333
2333 2004-05-20 Fernando Perez <fperez@colorado.edu>
2334 2004-05-20 Fernando Perez <fperez@colorado.edu>
2334
2335
2335 * IPython/Magic.py (Magic.magic_prun): changed default profile
2336 * IPython/Magic.py (Magic.magic_prun): changed default profile
2336 sort order to 'time' (the more common profiling need).
2337 sort order to 'time' (the more common profiling need).
2337
2338
2338 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2339 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2339 so that source code shown is guaranteed in sync with the file on
2340 so that source code shown is guaranteed in sync with the file on
2340 disk (also changed in psource). Similar fix to the one for
2341 disk (also changed in psource). Similar fix to the one for
2341 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2342 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2342 <yann.ledu-AT-noos.fr>.
2343 <yann.ledu-AT-noos.fr>.
2343
2344
2344 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2345 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2345 with a single option would not be correctly parsed. Closes
2346 with a single option would not be correctly parsed. Closes
2346 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2347 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2347 introduced in 0.6.0 (on 2004-05-06).
2348 introduced in 0.6.0 (on 2004-05-06).
2348
2349
2349 2004-05-13 *** Released version 0.6.0
2350 2004-05-13 *** Released version 0.6.0
2350
2351
2351 2004-05-13 Fernando Perez <fperez@colorado.edu>
2352 2004-05-13 Fernando Perez <fperez@colorado.edu>
2352
2353
2353 * debian/: Added debian/ directory to CVS, so that debian support
2354 * debian/: Added debian/ directory to CVS, so that debian support
2354 is publicly accessible. The debian package is maintained by Jack
2355 is publicly accessible. The debian package is maintained by Jack
2355 Moffit <jack-AT-xiph.org>.
2356 Moffit <jack-AT-xiph.org>.
2356
2357
2357 * Documentation: included the notes about an ipython-based system
2358 * Documentation: included the notes about an ipython-based system
2358 shell (the hypothetical 'pysh') into the new_design.pdf document,
2359 shell (the hypothetical 'pysh') into the new_design.pdf document,
2359 so that these ideas get distributed to users along with the
2360 so that these ideas get distributed to users along with the
2360 official documentation.
2361 official documentation.
2361
2362
2362 2004-05-10 Fernando Perez <fperez@colorado.edu>
2363 2004-05-10 Fernando Perez <fperez@colorado.edu>
2363
2364
2364 * IPython/Logger.py (Logger.create_log): fix recently introduced
2365 * IPython/Logger.py (Logger.create_log): fix recently introduced
2365 bug (misindented line) where logstart would fail when not given an
2366 bug (misindented line) where logstart would fail when not given an
2366 explicit filename.
2367 explicit filename.
2367
2368
2368 2004-05-09 Fernando Perez <fperez@colorado.edu>
2369 2004-05-09 Fernando Perez <fperez@colorado.edu>
2369
2370
2370 * IPython/Magic.py (Magic.parse_options): skip system call when
2371 * IPython/Magic.py (Magic.parse_options): skip system call when
2371 there are no options to look for. Faster, cleaner for the common
2372 there are no options to look for. Faster, cleaner for the common
2372 case.
2373 case.
2373
2374
2374 * Documentation: many updates to the manual: describing Windows
2375 * Documentation: many updates to the manual: describing Windows
2375 support better, Gnuplot updates, credits, misc small stuff. Also
2376 support better, Gnuplot updates, credits, misc small stuff. Also
2376 updated the new_design doc a bit.
2377 updated the new_design doc a bit.
2377
2378
2378 2004-05-06 *** Released version 0.6.0.rc1
2379 2004-05-06 *** Released version 0.6.0.rc1
2379
2380
2380 2004-05-06 Fernando Perez <fperez@colorado.edu>
2381 2004-05-06 Fernando Perez <fperez@colorado.edu>
2381
2382
2382 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2383 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2383 operations to use the vastly more efficient list/''.join() method.
2384 operations to use the vastly more efficient list/''.join() method.
2384 (FormattedTB.text): Fix
2385 (FormattedTB.text): Fix
2385 http://www.scipy.net/roundup/ipython/issue12 - exception source
2386 http://www.scipy.net/roundup/ipython/issue12 - exception source
2386 extract not updated after reload. Thanks to Mike Salib
2387 extract not updated after reload. Thanks to Mike Salib
2387 <msalib-AT-mit.edu> for pinning the source of the problem.
2388 <msalib-AT-mit.edu> for pinning the source of the problem.
2388 Fortunately, the solution works inside ipython and doesn't require
2389 Fortunately, the solution works inside ipython and doesn't require
2389 any changes to python proper.
2390 any changes to python proper.
2390
2391
2391 * IPython/Magic.py (Magic.parse_options): Improved to process the
2392 * IPython/Magic.py (Magic.parse_options): Improved to process the
2392 argument list as a true shell would (by actually using the
2393 argument list as a true shell would (by actually using the
2393 underlying system shell). This way, all @magics automatically get
2394 underlying system shell). This way, all @magics automatically get
2394 shell expansion for variables. Thanks to a comment by Alex
2395 shell expansion for variables. Thanks to a comment by Alex
2395 Schmolck.
2396 Schmolck.
2396
2397
2397 2004-04-04 Fernando Perez <fperez@colorado.edu>
2398 2004-04-04 Fernando Perez <fperez@colorado.edu>
2398
2399
2399 * IPython/iplib.py (InteractiveShell.interact): Added a special
2400 * IPython/iplib.py (InteractiveShell.interact): Added a special
2400 trap for a debugger quit exception, which is basically impossible
2401 trap for a debugger quit exception, which is basically impossible
2401 to handle by normal mechanisms, given what pdb does to the stack.
2402 to handle by normal mechanisms, given what pdb does to the stack.
2402 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2403 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2403
2404
2404 2004-04-03 Fernando Perez <fperez@colorado.edu>
2405 2004-04-03 Fernando Perez <fperez@colorado.edu>
2405
2406
2406 * IPython/genutils.py (Term): Standardized the names of the Term
2407 * IPython/genutils.py (Term): Standardized the names of the Term
2407 class streams to cin/cout/cerr, following C++ naming conventions
2408 class streams to cin/cout/cerr, following C++ naming conventions
2408 (I can't use in/out/err because 'in' is not a valid attribute
2409 (I can't use in/out/err because 'in' is not a valid attribute
2409 name).
2410 name).
2410
2411
2411 * IPython/iplib.py (InteractiveShell.interact): don't increment
2412 * IPython/iplib.py (InteractiveShell.interact): don't increment
2412 the prompt if there's no user input. By Daniel 'Dang' Griffith
2413 the prompt if there's no user input. By Daniel 'Dang' Griffith
2413 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2414 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2414 Francois Pinard.
2415 Francois Pinard.
2415
2416
2416 2004-04-02 Fernando Perez <fperez@colorado.edu>
2417 2004-04-02 Fernando Perez <fperez@colorado.edu>
2417
2418
2418 * IPython/genutils.py (Stream.__init__): Modified to survive at
2419 * IPython/genutils.py (Stream.__init__): Modified to survive at
2419 least importing in contexts where stdin/out/err aren't true file
2420 least importing in contexts where stdin/out/err aren't true file
2420 objects, such as PyCrust (they lack fileno() and mode). However,
2421 objects, such as PyCrust (they lack fileno() and mode). However,
2421 the recovery facilities which rely on these things existing will
2422 the recovery facilities which rely on these things existing will
2422 not work.
2423 not work.
2423
2424
2424 2004-04-01 Fernando Perez <fperez@colorado.edu>
2425 2004-04-01 Fernando Perez <fperez@colorado.edu>
2425
2426
2426 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2427 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2427 use the new getoutputerror() function, so it properly
2428 use the new getoutputerror() function, so it properly
2428 distinguishes stdout/err.
2429 distinguishes stdout/err.
2429
2430
2430 * IPython/genutils.py (getoutputerror): added a function to
2431 * IPython/genutils.py (getoutputerror): added a function to
2431 capture separately the standard output and error of a command.
2432 capture separately the standard output and error of a command.
2432 After a comment from dang on the mailing lists. This code is
2433 After a comment from dang on the mailing lists. This code is
2433 basically a modified version of commands.getstatusoutput(), from
2434 basically a modified version of commands.getstatusoutput(), from
2434 the standard library.
2435 the standard library.
2435
2436
2436 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2437 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2437 '!!' as a special syntax (shorthand) to access @sx.
2438 '!!' as a special syntax (shorthand) to access @sx.
2438
2439
2439 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2440 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2440 command and return its output as a list split on '\n'.
2441 command and return its output as a list split on '\n'.
2441
2442
2442 2004-03-31 Fernando Perez <fperez@colorado.edu>
2443 2004-03-31 Fernando Perez <fperez@colorado.edu>
2443
2444
2444 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2445 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2445 method to dictionaries used as FakeModule instances if they lack
2446 method to dictionaries used as FakeModule instances if they lack
2446 it. At least pydoc in python2.3 breaks for runtime-defined
2447 it. At least pydoc in python2.3 breaks for runtime-defined
2447 functions without this hack. At some point I need to _really_
2448 functions without this hack. At some point I need to _really_
2448 understand what FakeModule is doing, because it's a gross hack.
2449 understand what FakeModule is doing, because it's a gross hack.
2449 But it solves Arnd's problem for now...
2450 But it solves Arnd's problem for now...
2450
2451
2451 2004-02-27 Fernando Perez <fperez@colorado.edu>
2452 2004-02-27 Fernando Perez <fperez@colorado.edu>
2452
2453
2453 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2454 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2454 mode would behave erratically. Also increased the number of
2455 mode would behave erratically. Also increased the number of
2455 possible logs in rotate mod to 999. Thanks to Rod Holland
2456 possible logs in rotate mod to 999. Thanks to Rod Holland
2456 <rhh@StructureLABS.com> for the report and fixes.
2457 <rhh@StructureLABS.com> for the report and fixes.
2457
2458
2458 2004-02-26 Fernando Perez <fperez@colorado.edu>
2459 2004-02-26 Fernando Perez <fperez@colorado.edu>
2459
2460
2460 * IPython/genutils.py (page): Check that the curses module really
2461 * IPython/genutils.py (page): Check that the curses module really
2461 has the initscr attribute before trying to use it. For some
2462 has the initscr attribute before trying to use it. For some
2462 reason, the Solaris curses module is missing this. I think this
2463 reason, the Solaris curses module is missing this. I think this
2463 should be considered a Solaris python bug, but I'm not sure.
2464 should be considered a Solaris python bug, but I'm not sure.
2464
2465
2465 2004-01-17 Fernando Perez <fperez@colorado.edu>
2466 2004-01-17 Fernando Perez <fperez@colorado.edu>
2466
2467
2467 * IPython/genutils.py (Stream.__init__): Changes to try to make
2468 * IPython/genutils.py (Stream.__init__): Changes to try to make
2468 ipython robust against stdin/out/err being closed by the user.
2469 ipython robust against stdin/out/err being closed by the user.
2469 This is 'user error' (and blocks a normal python session, at least
2470 This is 'user error' (and blocks a normal python session, at least
2470 the stdout case). However, Ipython should be able to survive such
2471 the stdout case). However, Ipython should be able to survive such
2471 instances of abuse as gracefully as possible. To simplify the
2472 instances of abuse as gracefully as possible. To simplify the
2472 coding and maintain compatibility with Gary Bishop's Term
2473 coding and maintain compatibility with Gary Bishop's Term
2473 contributions, I've made use of classmethods for this. I think
2474 contributions, I've made use of classmethods for this. I think
2474 this introduces a dependency on python 2.2.
2475 this introduces a dependency on python 2.2.
2475
2476
2476 2004-01-13 Fernando Perez <fperez@colorado.edu>
2477 2004-01-13 Fernando Perez <fperez@colorado.edu>
2477
2478
2478 * IPython/numutils.py (exp_safe): simplified the code a bit and
2479 * IPython/numutils.py (exp_safe): simplified the code a bit and
2479 removed the need for importing the kinds module altogether.
2480 removed the need for importing the kinds module altogether.
2480
2481
2481 2004-01-06 Fernando Perez <fperez@colorado.edu>
2482 2004-01-06 Fernando Perez <fperez@colorado.edu>
2482
2483
2483 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2484 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2484 a magic function instead, after some community feedback. No
2485 a magic function instead, after some community feedback. No
2485 special syntax will exist for it, but its name is deliberately
2486 special syntax will exist for it, but its name is deliberately
2486 very short.
2487 very short.
2487
2488
2488 2003-12-20 Fernando Perez <fperez@colorado.edu>
2489 2003-12-20 Fernando Perez <fperez@colorado.edu>
2489
2490
2490 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2491 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2491 new functionality, to automagically assign the result of a shell
2492 new functionality, to automagically assign the result of a shell
2492 command to a variable. I'll solicit some community feedback on
2493 command to a variable. I'll solicit some community feedback on
2493 this before making it permanent.
2494 this before making it permanent.
2494
2495
2495 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2496 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2496 requested about callables for which inspect couldn't obtain a
2497 requested about callables for which inspect couldn't obtain a
2497 proper argspec. Thanks to a crash report sent by Etienne
2498 proper argspec. Thanks to a crash report sent by Etienne
2498 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2499 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2499
2500
2500 2003-12-09 Fernando Perez <fperez@colorado.edu>
2501 2003-12-09 Fernando Perez <fperez@colorado.edu>
2501
2502
2502 * IPython/genutils.py (page): patch for the pager to work across
2503 * IPython/genutils.py (page): patch for the pager to work across
2503 various versions of Windows. By Gary Bishop.
2504 various versions of Windows. By Gary Bishop.
2504
2505
2505 2003-12-04 Fernando Perez <fperez@colorado.edu>
2506 2003-12-04 Fernando Perez <fperez@colorado.edu>
2506
2507
2507 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2508 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2508 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2509 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2509 While I tested this and it looks ok, there may still be corner
2510 While I tested this and it looks ok, there may still be corner
2510 cases I've missed.
2511 cases I've missed.
2511
2512
2512 2003-12-01 Fernando Perez <fperez@colorado.edu>
2513 2003-12-01 Fernando Perez <fperez@colorado.edu>
2513
2514
2514 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2515 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2515 where a line like 'p,q=1,2' would fail because the automagic
2516 where a line like 'p,q=1,2' would fail because the automagic
2516 system would be triggered for @p.
2517 system would be triggered for @p.
2517
2518
2518 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2519 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2519 cleanups, code unmodified.
2520 cleanups, code unmodified.
2520
2521
2521 * IPython/genutils.py (Term): added a class for IPython to handle
2522 * IPython/genutils.py (Term): added a class for IPython to handle
2522 output. In most cases it will just be a proxy for stdout/err, but
2523 output. In most cases it will just be a proxy for stdout/err, but
2523 having this allows modifications to be made for some platforms,
2524 having this allows modifications to be made for some platforms,
2524 such as handling color escapes under Windows. All of this code
2525 such as handling color escapes under Windows. All of this code
2525 was contributed by Gary Bishop, with minor modifications by me.
2526 was contributed by Gary Bishop, with minor modifications by me.
2526 The actual changes affect many files.
2527 The actual changes affect many files.
2527
2528
2528 2003-11-30 Fernando Perez <fperez@colorado.edu>
2529 2003-11-30 Fernando Perez <fperez@colorado.edu>
2529
2530
2530 * IPython/iplib.py (file_matches): new completion code, courtesy
2531 * IPython/iplib.py (file_matches): new completion code, courtesy
2531 of Jeff Collins. This enables filename completion again under
2532 of Jeff Collins. This enables filename completion again under
2532 python 2.3, which disabled it at the C level.
2533 python 2.3, which disabled it at the C level.
2533
2534
2534 2003-11-11 Fernando Perez <fperez@colorado.edu>
2535 2003-11-11 Fernando Perez <fperez@colorado.edu>
2535
2536
2536 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2537 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2537 for Numeric.array(map(...)), but often convenient.
2538 for Numeric.array(map(...)), but often convenient.
2538
2539
2539 2003-11-05 Fernando Perez <fperez@colorado.edu>
2540 2003-11-05 Fernando Perez <fperez@colorado.edu>
2540
2541
2541 * IPython/numutils.py (frange): Changed a call from int() to
2542 * IPython/numutils.py (frange): Changed a call from int() to
2542 int(round()) to prevent a problem reported with arange() in the
2543 int(round()) to prevent a problem reported with arange() in the
2543 numpy list.
2544 numpy list.
2544
2545
2545 2003-10-06 Fernando Perez <fperez@colorado.edu>
2546 2003-10-06 Fernando Perez <fperez@colorado.edu>
2546
2547
2547 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2548 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2548 prevent crashes if sys lacks an argv attribute (it happens with
2549 prevent crashes if sys lacks an argv attribute (it happens with
2549 embedded interpreters which build a bare-bones sys module).
2550 embedded interpreters which build a bare-bones sys module).
2550 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2551 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2551
2552
2552 2003-09-24 Fernando Perez <fperez@colorado.edu>
2553 2003-09-24 Fernando Perez <fperez@colorado.edu>
2553
2554
2554 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2555 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2555 to protect against poorly written user objects where __getattr__
2556 to protect against poorly written user objects where __getattr__
2556 raises exceptions other than AttributeError. Thanks to a bug
2557 raises exceptions other than AttributeError. Thanks to a bug
2557 report by Oliver Sander <osander-AT-gmx.de>.
2558 report by Oliver Sander <osander-AT-gmx.de>.
2558
2559
2559 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2560 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2560 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2561 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2561
2562
2562 2003-09-09 Fernando Perez <fperez@colorado.edu>
2563 2003-09-09 Fernando Perez <fperez@colorado.edu>
2563
2564
2564 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2565 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2565 unpacking a list whith a callable as first element would
2566 unpacking a list whith a callable as first element would
2566 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2567 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2567 Collins.
2568 Collins.
2568
2569
2569 2003-08-25 *** Released version 0.5.0
2570 2003-08-25 *** Released version 0.5.0
2570
2571
2571 2003-08-22 Fernando Perez <fperez@colorado.edu>
2572 2003-08-22 Fernando Perez <fperez@colorado.edu>
2572
2573
2573 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2574 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2574 improperly defined user exceptions. Thanks to feedback from Mark
2575 improperly defined user exceptions. Thanks to feedback from Mark
2575 Russell <mrussell-AT-verio.net>.
2576 Russell <mrussell-AT-verio.net>.
2576
2577
2577 2003-08-20 Fernando Perez <fperez@colorado.edu>
2578 2003-08-20 Fernando Perez <fperez@colorado.edu>
2578
2579
2579 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2580 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2580 printing so that it would print multi-line string forms starting
2581 printing so that it would print multi-line string forms starting
2581 with a new line. This way the formatting is better respected for
2582 with a new line. This way the formatting is better respected for
2582 objects which work hard to make nice string forms.
2583 objects which work hard to make nice string forms.
2583
2584
2584 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2585 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2585 autocall would overtake data access for objects with both
2586 autocall would overtake data access for objects with both
2586 __getitem__ and __call__.
2587 __getitem__ and __call__.
2587
2588
2588 2003-08-19 *** Released version 0.5.0-rc1
2589 2003-08-19 *** Released version 0.5.0-rc1
2589
2590
2590 2003-08-19 Fernando Perez <fperez@colorado.edu>
2591 2003-08-19 Fernando Perez <fperez@colorado.edu>
2591
2592
2592 * IPython/deep_reload.py (load_tail): single tiny change here
2593 * IPython/deep_reload.py (load_tail): single tiny change here
2593 seems to fix the long-standing bug of dreload() failing to work
2594 seems to fix the long-standing bug of dreload() failing to work
2594 for dotted names. But this module is pretty tricky, so I may have
2595 for dotted names. But this module is pretty tricky, so I may have
2595 missed some subtlety. Needs more testing!.
2596 missed some subtlety. Needs more testing!.
2596
2597
2597 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2598 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2598 exceptions which have badly implemented __str__ methods.
2599 exceptions which have badly implemented __str__ methods.
2599 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2600 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2600 which I've been getting reports about from Python 2.3 users. I
2601 which I've been getting reports about from Python 2.3 users. I
2601 wish I had a simple test case to reproduce the problem, so I could
2602 wish I had a simple test case to reproduce the problem, so I could
2602 either write a cleaner workaround or file a bug report if
2603 either write a cleaner workaround or file a bug report if
2603 necessary.
2604 necessary.
2604
2605
2605 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2606 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2606 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2607 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2607 a bug report by Tjabo Kloppenburg.
2608 a bug report by Tjabo Kloppenburg.
2608
2609
2609 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2610 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2610 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2611 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2611 seems rather unstable. Thanks to a bug report by Tjabo
2612 seems rather unstable. Thanks to a bug report by Tjabo
2612 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2613 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2613
2614
2614 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2615 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2615 this out soon because of the critical fixes in the inner loop for
2616 this out soon because of the critical fixes in the inner loop for
2616 generators.
2617 generators.
2617
2618
2618 * IPython/Magic.py (Magic.getargspec): removed. This (and
2619 * IPython/Magic.py (Magic.getargspec): removed. This (and
2619 _get_def) have been obsoleted by OInspect for a long time, I
2620 _get_def) have been obsoleted by OInspect for a long time, I
2620 hadn't noticed that they were dead code.
2621 hadn't noticed that they were dead code.
2621 (Magic._ofind): restored _ofind functionality for a few literals
2622 (Magic._ofind): restored _ofind functionality for a few literals
2622 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2623 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2623 for things like "hello".capitalize?, since that would require a
2624 for things like "hello".capitalize?, since that would require a
2624 potentially dangerous eval() again.
2625 potentially dangerous eval() again.
2625
2626
2626 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2627 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2627 logic a bit more to clean up the escapes handling and minimize the
2628 logic a bit more to clean up the escapes handling and minimize the
2628 use of _ofind to only necessary cases. The interactive 'feel' of
2629 use of _ofind to only necessary cases. The interactive 'feel' of
2629 IPython should have improved quite a bit with the changes in
2630 IPython should have improved quite a bit with the changes in
2630 _prefilter and _ofind (besides being far safer than before).
2631 _prefilter and _ofind (besides being far safer than before).
2631
2632
2632 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2633 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2633 obscure, never reported). Edit would fail to find the object to
2634 obscure, never reported). Edit would fail to find the object to
2634 edit under some circumstances.
2635 edit under some circumstances.
2635 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2636 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2636 which were causing double-calling of generators. Those eval calls
2637 which were causing double-calling of generators. Those eval calls
2637 were _very_ dangerous, since code with side effects could be
2638 were _very_ dangerous, since code with side effects could be
2638 triggered. As they say, 'eval is evil'... These were the
2639 triggered. As they say, 'eval is evil'... These were the
2639 nastiest evals in IPython. Besides, _ofind is now far simpler,
2640 nastiest evals in IPython. Besides, _ofind is now far simpler,
2640 and it should also be quite a bit faster. Its use of inspect is
2641 and it should also be quite a bit faster. Its use of inspect is
2641 also safer, so perhaps some of the inspect-related crashes I've
2642 also safer, so perhaps some of the inspect-related crashes I've
2642 seen lately with Python 2.3 might be taken care of. That will
2643 seen lately with Python 2.3 might be taken care of. That will
2643 need more testing.
2644 need more testing.
2644
2645
2645 2003-08-17 Fernando Perez <fperez@colorado.edu>
2646 2003-08-17 Fernando Perez <fperez@colorado.edu>
2646
2647
2647 * IPython/iplib.py (InteractiveShell._prefilter): significant
2648 * IPython/iplib.py (InteractiveShell._prefilter): significant
2648 simplifications to the logic for handling user escapes. Faster
2649 simplifications to the logic for handling user escapes. Faster
2649 and simpler code.
2650 and simpler code.
2650
2651
2651 2003-08-14 Fernando Perez <fperez@colorado.edu>
2652 2003-08-14 Fernando Perez <fperez@colorado.edu>
2652
2653
2653 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2654 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2654 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2655 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2655 but it should be quite a bit faster. And the recursive version
2656 but it should be quite a bit faster. And the recursive version
2656 generated O(log N) intermediate storage for all rank>1 arrays,
2657 generated O(log N) intermediate storage for all rank>1 arrays,
2657 even if they were contiguous.
2658 even if they were contiguous.
2658 (l1norm): Added this function.
2659 (l1norm): Added this function.
2659 (norm): Added this function for arbitrary norms (including
2660 (norm): Added this function for arbitrary norms (including
2660 l-infinity). l1 and l2 are still special cases for convenience
2661 l-infinity). l1 and l2 are still special cases for convenience
2661 and speed.
2662 and speed.
2662
2663
2663 2003-08-03 Fernando Perez <fperez@colorado.edu>
2664 2003-08-03 Fernando Perez <fperez@colorado.edu>
2664
2665
2665 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2666 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2666 exceptions, which now raise PendingDeprecationWarnings in Python
2667 exceptions, which now raise PendingDeprecationWarnings in Python
2667 2.3. There were some in Magic and some in Gnuplot2.
2668 2.3. There were some in Magic and some in Gnuplot2.
2668
2669
2669 2003-06-30 Fernando Perez <fperez@colorado.edu>
2670 2003-06-30 Fernando Perez <fperez@colorado.edu>
2670
2671
2671 * IPython/genutils.py (page): modified to call curses only for
2672 * IPython/genutils.py (page): modified to call curses only for
2672 terminals where TERM=='xterm'. After problems under many other
2673 terminals where TERM=='xterm'. After problems under many other
2673 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2674 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2674
2675
2675 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2676 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2676 would be triggered when readline was absent. This was just an old
2677 would be triggered when readline was absent. This was just an old
2677 debugging statement I'd forgotten to take out.
2678 debugging statement I'd forgotten to take out.
2678
2679
2679 2003-06-20 Fernando Perez <fperez@colorado.edu>
2680 2003-06-20 Fernando Perez <fperez@colorado.edu>
2680
2681
2681 * IPython/genutils.py (clock): modified to return only user time
2682 * IPython/genutils.py (clock): modified to return only user time
2682 (not counting system time), after a discussion on scipy. While
2683 (not counting system time), after a discussion on scipy. While
2683 system time may be a useful quantity occasionally, it may much
2684 system time may be a useful quantity occasionally, it may much
2684 more easily be skewed by occasional swapping or other similar
2685 more easily be skewed by occasional swapping or other similar
2685 activity.
2686 activity.
2686
2687
2687 2003-06-05 Fernando Perez <fperez@colorado.edu>
2688 2003-06-05 Fernando Perez <fperez@colorado.edu>
2688
2689
2689 * IPython/numutils.py (identity): new function, for building
2690 * IPython/numutils.py (identity): new function, for building
2690 arbitrary rank Kronecker deltas (mostly backwards compatible with
2691 arbitrary rank Kronecker deltas (mostly backwards compatible with
2691 Numeric.identity)
2692 Numeric.identity)
2692
2693
2693 2003-06-03 Fernando Perez <fperez@colorado.edu>
2694 2003-06-03 Fernando Perez <fperez@colorado.edu>
2694
2695
2695 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2696 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2696 arguments passed to magics with spaces, to allow trailing '\' to
2697 arguments passed to magics with spaces, to allow trailing '\' to
2697 work normally (mainly for Windows users).
2698 work normally (mainly for Windows users).
2698
2699
2699 2003-05-29 Fernando Perez <fperez@colorado.edu>
2700 2003-05-29 Fernando Perez <fperez@colorado.edu>
2700
2701
2701 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2702 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2702 instead of pydoc.help. This fixes a bizarre behavior where
2703 instead of pydoc.help. This fixes a bizarre behavior where
2703 printing '%s' % locals() would trigger the help system. Now
2704 printing '%s' % locals() would trigger the help system. Now
2704 ipython behaves like normal python does.
2705 ipython behaves like normal python does.
2705
2706
2706 Note that if one does 'from pydoc import help', the bizarre
2707 Note that if one does 'from pydoc import help', the bizarre
2707 behavior returns, but this will also happen in normal python, so
2708 behavior returns, but this will also happen in normal python, so
2708 it's not an ipython bug anymore (it has to do with how pydoc.help
2709 it's not an ipython bug anymore (it has to do with how pydoc.help
2709 is implemented).
2710 is implemented).
2710
2711
2711 2003-05-22 Fernando Perez <fperez@colorado.edu>
2712 2003-05-22 Fernando Perez <fperez@colorado.edu>
2712
2713
2713 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2714 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2714 return [] instead of None when nothing matches, also match to end
2715 return [] instead of None when nothing matches, also match to end
2715 of line. Patch by Gary Bishop.
2716 of line. Patch by Gary Bishop.
2716
2717
2717 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2718 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2718 protection as before, for files passed on the command line. This
2719 protection as before, for files passed on the command line. This
2719 prevents the CrashHandler from kicking in if user files call into
2720 prevents the CrashHandler from kicking in if user files call into
2720 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2721 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2721 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2722 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2722
2723
2723 2003-05-20 *** Released version 0.4.0
2724 2003-05-20 *** Released version 0.4.0
2724
2725
2725 2003-05-20 Fernando Perez <fperez@colorado.edu>
2726 2003-05-20 Fernando Perez <fperez@colorado.edu>
2726
2727
2727 * setup.py: added support for manpages. It's a bit hackish b/c of
2728 * setup.py: added support for manpages. It's a bit hackish b/c of
2728 a bug in the way the bdist_rpm distutils target handles gzipped
2729 a bug in the way the bdist_rpm distutils target handles gzipped
2729 manpages, but it works. After a patch by Jack.
2730 manpages, but it works. After a patch by Jack.
2730
2731
2731 2003-05-19 Fernando Perez <fperez@colorado.edu>
2732 2003-05-19 Fernando Perez <fperez@colorado.edu>
2732
2733
2733 * IPython/numutils.py: added a mockup of the kinds module, since
2734 * IPython/numutils.py: added a mockup of the kinds module, since
2734 it was recently removed from Numeric. This way, numutils will
2735 it was recently removed from Numeric. This way, numutils will
2735 work for all users even if they are missing kinds.
2736 work for all users even if they are missing kinds.
2736
2737
2737 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2738 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2738 failure, which can occur with SWIG-wrapped extensions. After a
2739 failure, which can occur with SWIG-wrapped extensions. After a
2739 crash report from Prabhu.
2740 crash report from Prabhu.
2740
2741
2741 2003-05-16 Fernando Perez <fperez@colorado.edu>
2742 2003-05-16 Fernando Perez <fperez@colorado.edu>
2742
2743
2743 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2744 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2744 protect ipython from user code which may call directly
2745 protect ipython from user code which may call directly
2745 sys.excepthook (this looks like an ipython crash to the user, even
2746 sys.excepthook (this looks like an ipython crash to the user, even
2746 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2747 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2747 This is especially important to help users of WxWindows, but may
2748 This is especially important to help users of WxWindows, but may
2748 also be useful in other cases.
2749 also be useful in other cases.
2749
2750
2750 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2751 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2751 an optional tb_offset to be specified, and to preserve exception
2752 an optional tb_offset to be specified, and to preserve exception
2752 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2753 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2753
2754
2754 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2755 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2755
2756
2756 2003-05-15 Fernando Perez <fperez@colorado.edu>
2757 2003-05-15 Fernando Perez <fperez@colorado.edu>
2757
2758
2758 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2759 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2759 installing for a new user under Windows.
2760 installing for a new user under Windows.
2760
2761
2761 2003-05-12 Fernando Perez <fperez@colorado.edu>
2762 2003-05-12 Fernando Perez <fperez@colorado.edu>
2762
2763
2763 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2764 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2764 handler for Emacs comint-based lines. Currently it doesn't do
2765 handler for Emacs comint-based lines. Currently it doesn't do
2765 much (but importantly, it doesn't update the history cache). In
2766 much (but importantly, it doesn't update the history cache). In
2766 the future it may be expanded if Alex needs more functionality
2767 the future it may be expanded if Alex needs more functionality
2767 there.
2768 there.
2768
2769
2769 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2770 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2770 info to crash reports.
2771 info to crash reports.
2771
2772
2772 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2773 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2773 just like Python's -c. Also fixed crash with invalid -color
2774 just like Python's -c. Also fixed crash with invalid -color
2774 option value at startup. Thanks to Will French
2775 option value at startup. Thanks to Will French
2775 <wfrench-AT-bestweb.net> for the bug report.
2776 <wfrench-AT-bestweb.net> for the bug report.
2776
2777
2777 2003-05-09 Fernando Perez <fperez@colorado.edu>
2778 2003-05-09 Fernando Perez <fperez@colorado.edu>
2778
2779
2779 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2780 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2780 to EvalDict (it's a mapping, after all) and simplified its code
2781 to EvalDict (it's a mapping, after all) and simplified its code
2781 quite a bit, after a nice discussion on c.l.py where Gustavo
2782 quite a bit, after a nice discussion on c.l.py where Gustavo
2782 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2783 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2783
2784
2784 2003-04-30 Fernando Perez <fperez@colorado.edu>
2785 2003-04-30 Fernando Perez <fperez@colorado.edu>
2785
2786
2786 * IPython/genutils.py (timings_out): modified it to reduce its
2787 * IPython/genutils.py (timings_out): modified it to reduce its
2787 overhead in the common reps==1 case.
2788 overhead in the common reps==1 case.
2788
2789
2789 2003-04-29 Fernando Perez <fperez@colorado.edu>
2790 2003-04-29 Fernando Perez <fperez@colorado.edu>
2790
2791
2791 * IPython/genutils.py (timings_out): Modified to use the resource
2792 * IPython/genutils.py (timings_out): Modified to use the resource
2792 module, which avoids the wraparound problems of time.clock().
2793 module, which avoids the wraparound problems of time.clock().
2793
2794
2794 2003-04-17 *** Released version 0.2.15pre4
2795 2003-04-17 *** Released version 0.2.15pre4
2795
2796
2796 2003-04-17 Fernando Perez <fperez@colorado.edu>
2797 2003-04-17 Fernando Perez <fperez@colorado.edu>
2797
2798
2798 * setup.py (scriptfiles): Split windows-specific stuff over to a
2799 * setup.py (scriptfiles): Split windows-specific stuff over to a
2799 separate file, in an attempt to have a Windows GUI installer.
2800 separate file, in an attempt to have a Windows GUI installer.
2800 That didn't work, but part of the groundwork is done.
2801 That didn't work, but part of the groundwork is done.
2801
2802
2802 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2803 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2803 indent/unindent with 4 spaces. Particularly useful in combination
2804 indent/unindent with 4 spaces. Particularly useful in combination
2804 with the new auto-indent option.
2805 with the new auto-indent option.
2805
2806
2806 2003-04-16 Fernando Perez <fperez@colorado.edu>
2807 2003-04-16 Fernando Perez <fperez@colorado.edu>
2807
2808
2808 * IPython/Magic.py: various replacements of self.rc for
2809 * IPython/Magic.py: various replacements of self.rc for
2809 self.shell.rc. A lot more remains to be done to fully disentangle
2810 self.shell.rc. A lot more remains to be done to fully disentangle
2810 this class from the main Shell class.
2811 this class from the main Shell class.
2811
2812
2812 * IPython/GnuplotRuntime.py: added checks for mouse support so
2813 * IPython/GnuplotRuntime.py: added checks for mouse support so
2813 that we don't try to enable it if the current gnuplot doesn't
2814 that we don't try to enable it if the current gnuplot doesn't
2814 really support it. Also added checks so that we don't try to
2815 really support it. Also added checks so that we don't try to
2815 enable persist under Windows (where Gnuplot doesn't recognize the
2816 enable persist under Windows (where Gnuplot doesn't recognize the
2816 option).
2817 option).
2817
2818
2818 * IPython/iplib.py (InteractiveShell.interact): Added optional
2819 * IPython/iplib.py (InteractiveShell.interact): Added optional
2819 auto-indenting code, after a patch by King C. Shu
2820 auto-indenting code, after a patch by King C. Shu
2820 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2821 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2821 get along well with pasting indented code. If I ever figure out
2822 get along well with pasting indented code. If I ever figure out
2822 how to make that part go well, it will become on by default.
2823 how to make that part go well, it will become on by default.
2823
2824
2824 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2825 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2825 crash ipython if there was an unmatched '%' in the user's prompt
2826 crash ipython if there was an unmatched '%' in the user's prompt
2826 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2827 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2827
2828
2828 * IPython/iplib.py (InteractiveShell.interact): removed the
2829 * IPython/iplib.py (InteractiveShell.interact): removed the
2829 ability to ask the user whether he wants to crash or not at the
2830 ability to ask the user whether he wants to crash or not at the
2830 'last line' exception handler. Calling functions at that point
2831 'last line' exception handler. Calling functions at that point
2831 changes the stack, and the error reports would have incorrect
2832 changes the stack, and the error reports would have incorrect
2832 tracebacks.
2833 tracebacks.
2833
2834
2834 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2835 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2835 pass through a peger a pretty-printed form of any object. After a
2836 pass through a peger a pretty-printed form of any object. After a
2836 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2837 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2837
2838
2838 2003-04-14 Fernando Perez <fperez@colorado.edu>
2839 2003-04-14 Fernando Perez <fperez@colorado.edu>
2839
2840
2840 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2841 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2841 all files in ~ would be modified at first install (instead of
2842 all files in ~ would be modified at first install (instead of
2842 ~/.ipython). This could be potentially disastrous, as the
2843 ~/.ipython). This could be potentially disastrous, as the
2843 modification (make line-endings native) could damage binary files.
2844 modification (make line-endings native) could damage binary files.
2844
2845
2845 2003-04-10 Fernando Perez <fperez@colorado.edu>
2846 2003-04-10 Fernando Perez <fperez@colorado.edu>
2846
2847
2847 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2848 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2848 handle only lines which are invalid python. This now means that
2849 handle only lines which are invalid python. This now means that
2849 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2850 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2850 for the bug report.
2851 for the bug report.
2851
2852
2852 2003-04-01 Fernando Perez <fperez@colorado.edu>
2853 2003-04-01 Fernando Perez <fperez@colorado.edu>
2853
2854
2854 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2855 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2855 where failing to set sys.last_traceback would crash pdb.pm().
2856 where failing to set sys.last_traceback would crash pdb.pm().
2856 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2857 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2857 report.
2858 report.
2858
2859
2859 2003-03-25 Fernando Perez <fperez@colorado.edu>
2860 2003-03-25 Fernando Perez <fperez@colorado.edu>
2860
2861
2861 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2862 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2862 before printing it (it had a lot of spurious blank lines at the
2863 before printing it (it had a lot of spurious blank lines at the
2863 end).
2864 end).
2864
2865
2865 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2866 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2866 output would be sent 21 times! Obviously people don't use this
2867 output would be sent 21 times! Obviously people don't use this
2867 too often, or I would have heard about it.
2868 too often, or I would have heard about it.
2868
2869
2869 2003-03-24 Fernando Perez <fperez@colorado.edu>
2870 2003-03-24 Fernando Perez <fperez@colorado.edu>
2870
2871
2871 * setup.py (scriptfiles): renamed the data_files parameter from
2872 * setup.py (scriptfiles): renamed the data_files parameter from
2872 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2873 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2873 for the patch.
2874 for the patch.
2874
2875
2875 2003-03-20 Fernando Perez <fperez@colorado.edu>
2876 2003-03-20 Fernando Perez <fperez@colorado.edu>
2876
2877
2877 * IPython/genutils.py (error): added error() and fatal()
2878 * IPython/genutils.py (error): added error() and fatal()
2878 functions.
2879 functions.
2879
2880
2880 2003-03-18 *** Released version 0.2.15pre3
2881 2003-03-18 *** Released version 0.2.15pre3
2881
2882
2882 2003-03-18 Fernando Perez <fperez@colorado.edu>
2883 2003-03-18 Fernando Perez <fperez@colorado.edu>
2883
2884
2884 * setupext/install_data_ext.py
2885 * setupext/install_data_ext.py
2885 (install_data_ext.initialize_options): Class contributed by Jack
2886 (install_data_ext.initialize_options): Class contributed by Jack
2886 Moffit for fixing the old distutils hack. He is sending this to
2887 Moffit for fixing the old distutils hack. He is sending this to
2887 the distutils folks so in the future we may not need it as a
2888 the distutils folks so in the future we may not need it as a
2888 private fix.
2889 private fix.
2889
2890
2890 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2891 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2891 changes for Debian packaging. See his patch for full details.
2892 changes for Debian packaging. See his patch for full details.
2892 The old distutils hack of making the ipythonrc* files carry a
2893 The old distutils hack of making the ipythonrc* files carry a
2893 bogus .py extension is gone, at last. Examples were moved to a
2894 bogus .py extension is gone, at last. Examples were moved to a
2894 separate subdir under doc/, and the separate executable scripts
2895 separate subdir under doc/, and the separate executable scripts
2895 now live in their own directory. Overall a great cleanup. The
2896 now live in their own directory. Overall a great cleanup. The
2896 manual was updated to use the new files, and setup.py has been
2897 manual was updated to use the new files, and setup.py has been
2897 fixed for this setup.
2898 fixed for this setup.
2898
2899
2899 * IPython/PyColorize.py (Parser.usage): made non-executable and
2900 * IPython/PyColorize.py (Parser.usage): made non-executable and
2900 created a pycolor wrapper around it to be included as a script.
2901 created a pycolor wrapper around it to be included as a script.
2901
2902
2902 2003-03-12 *** Released version 0.2.15pre2
2903 2003-03-12 *** Released version 0.2.15pre2
2903
2904
2904 2003-03-12 Fernando Perez <fperez@colorado.edu>
2905 2003-03-12 Fernando Perez <fperez@colorado.edu>
2905
2906
2906 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2907 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2907 long-standing problem with garbage characters in some terminals.
2908 long-standing problem with garbage characters in some terminals.
2908 The issue was really that the \001 and \002 escapes must _only_ be
2909 The issue was really that the \001 and \002 escapes must _only_ be
2909 passed to input prompts (which call readline), but _never_ to
2910 passed to input prompts (which call readline), but _never_ to
2910 normal text to be printed on screen. I changed ColorANSI to have
2911 normal text to be printed on screen. I changed ColorANSI to have
2911 two classes: TermColors and InputTermColors, each with the
2912 two classes: TermColors and InputTermColors, each with the
2912 appropriate escapes for input prompts or normal text. The code in
2913 appropriate escapes for input prompts or normal text. The code in
2913 Prompts.py got slightly more complicated, but this very old and
2914 Prompts.py got slightly more complicated, but this very old and
2914 annoying bug is finally fixed.
2915 annoying bug is finally fixed.
2915
2916
2916 All the credit for nailing down the real origin of this problem
2917 All the credit for nailing down the real origin of this problem
2917 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2918 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2918 *Many* thanks to him for spending quite a bit of effort on this.
2919 *Many* thanks to him for spending quite a bit of effort on this.
2919
2920
2920 2003-03-05 *** Released version 0.2.15pre1
2921 2003-03-05 *** Released version 0.2.15pre1
2921
2922
2922 2003-03-03 Fernando Perez <fperez@colorado.edu>
2923 2003-03-03 Fernando Perez <fperez@colorado.edu>
2923
2924
2924 * IPython/FakeModule.py: Moved the former _FakeModule to a
2925 * IPython/FakeModule.py: Moved the former _FakeModule to a
2925 separate file, because it's also needed by Magic (to fix a similar
2926 separate file, because it's also needed by Magic (to fix a similar
2926 pickle-related issue in @run).
2927 pickle-related issue in @run).
2927
2928
2928 2003-03-02 Fernando Perez <fperez@colorado.edu>
2929 2003-03-02 Fernando Perez <fperez@colorado.edu>
2929
2930
2930 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2931 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2931 the autocall option at runtime.
2932 the autocall option at runtime.
2932 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2933 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2933 across Magic.py to start separating Magic from InteractiveShell.
2934 across Magic.py to start separating Magic from InteractiveShell.
2934 (Magic._ofind): Fixed to return proper namespace for dotted
2935 (Magic._ofind): Fixed to return proper namespace for dotted
2935 names. Before, a dotted name would always return 'not currently
2936 names. Before, a dotted name would always return 'not currently
2936 defined', because it would find the 'parent'. s.x would be found,
2937 defined', because it would find the 'parent'. s.x would be found,
2937 but since 'x' isn't defined by itself, it would get confused.
2938 but since 'x' isn't defined by itself, it would get confused.
2938 (Magic.magic_run): Fixed pickling problems reported by Ralf
2939 (Magic.magic_run): Fixed pickling problems reported by Ralf
2939 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2940 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2940 that I'd used when Mike Heeter reported similar issues at the
2941 that I'd used when Mike Heeter reported similar issues at the
2941 top-level, but now for @run. It boils down to injecting the
2942 top-level, but now for @run. It boils down to injecting the
2942 namespace where code is being executed with something that looks
2943 namespace where code is being executed with something that looks
2943 enough like a module to fool pickle.dump(). Since a pickle stores
2944 enough like a module to fool pickle.dump(). Since a pickle stores
2944 a named reference to the importing module, we need this for
2945 a named reference to the importing module, we need this for
2945 pickles to save something sensible.
2946 pickles to save something sensible.
2946
2947
2947 * IPython/ipmaker.py (make_IPython): added an autocall option.
2948 * IPython/ipmaker.py (make_IPython): added an autocall option.
2948
2949
2949 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2950 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2950 the auto-eval code. Now autocalling is an option, and the code is
2951 the auto-eval code. Now autocalling is an option, and the code is
2951 also vastly safer. There is no more eval() involved at all.
2952 also vastly safer. There is no more eval() involved at all.
2952
2953
2953 2003-03-01 Fernando Perez <fperez@colorado.edu>
2954 2003-03-01 Fernando Perez <fperez@colorado.edu>
2954
2955
2955 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2956 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2956 dict with named keys instead of a tuple.
2957 dict with named keys instead of a tuple.
2957
2958
2958 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2959 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2959
2960
2960 * setup.py (make_shortcut): Fixed message about directories
2961 * setup.py (make_shortcut): Fixed message about directories
2961 created during Windows installation (the directories were ok, just
2962 created during Windows installation (the directories were ok, just
2962 the printed message was misleading). Thanks to Chris Liechti
2963 the printed message was misleading). Thanks to Chris Liechti
2963 <cliechti-AT-gmx.net> for the heads up.
2964 <cliechti-AT-gmx.net> for the heads up.
2964
2965
2965 2003-02-21 Fernando Perez <fperez@colorado.edu>
2966 2003-02-21 Fernando Perez <fperez@colorado.edu>
2966
2967
2967 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2968 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2968 of ValueError exception when checking for auto-execution. This
2969 of ValueError exception when checking for auto-execution. This
2969 one is raised by things like Numeric arrays arr.flat when the
2970 one is raised by things like Numeric arrays arr.flat when the
2970 array is non-contiguous.
2971 array is non-contiguous.
2971
2972
2972 2003-01-31 Fernando Perez <fperez@colorado.edu>
2973 2003-01-31 Fernando Perez <fperez@colorado.edu>
2973
2974
2974 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2975 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2975 not return any value at all (even though the command would get
2976 not return any value at all (even though the command would get
2976 executed).
2977 executed).
2977 (xsys): Flush stdout right after printing the command to ensure
2978 (xsys): Flush stdout right after printing the command to ensure
2978 proper ordering of commands and command output in the total
2979 proper ordering of commands and command output in the total
2979 output.
2980 output.
2980 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2981 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2981 system/getoutput as defaults. The old ones are kept for
2982 system/getoutput as defaults. The old ones are kept for
2982 compatibility reasons, so no code which uses this library needs
2983 compatibility reasons, so no code which uses this library needs
2983 changing.
2984 changing.
2984
2985
2985 2003-01-27 *** Released version 0.2.14
2986 2003-01-27 *** Released version 0.2.14
2986
2987
2987 2003-01-25 Fernando Perez <fperez@colorado.edu>
2988 2003-01-25 Fernando Perez <fperez@colorado.edu>
2988
2989
2989 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2990 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2990 functions defined in previous edit sessions could not be re-edited
2991 functions defined in previous edit sessions could not be re-edited
2991 (because the temp files were immediately removed). Now temp files
2992 (because the temp files were immediately removed). Now temp files
2992 are removed only at IPython's exit.
2993 are removed only at IPython's exit.
2993 (Magic.magic_run): Improved @run to perform shell-like expansions
2994 (Magic.magic_run): Improved @run to perform shell-like expansions
2994 on its arguments (~users and $VARS). With this, @run becomes more
2995 on its arguments (~users and $VARS). With this, @run becomes more
2995 like a normal command-line.
2996 like a normal command-line.
2996
2997
2997 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2998 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2998 bugs related to embedding and cleaned up that code. A fairly
2999 bugs related to embedding and cleaned up that code. A fairly
2999 important one was the impossibility to access the global namespace
3000 important one was the impossibility to access the global namespace
3000 through the embedded IPython (only local variables were visible).
3001 through the embedded IPython (only local variables were visible).
3001
3002
3002 2003-01-14 Fernando Perez <fperez@colorado.edu>
3003 2003-01-14 Fernando Perez <fperez@colorado.edu>
3003
3004
3004 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
3005 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
3005 auto-calling to be a bit more conservative. Now it doesn't get
3006 auto-calling to be a bit more conservative. Now it doesn't get
3006 triggered if any of '!=()<>' are in the rest of the input line, to
3007 triggered if any of '!=()<>' are in the rest of the input line, to
3007 allow comparing callables. Thanks to Alex for the heads up.
3008 allow comparing callables. Thanks to Alex for the heads up.
3008
3009
3009 2003-01-07 Fernando Perez <fperez@colorado.edu>
3010 2003-01-07 Fernando Perez <fperez@colorado.edu>
3010
3011
3011 * IPython/genutils.py (page): fixed estimation of the number of
3012 * IPython/genutils.py (page): fixed estimation of the number of
3012 lines in a string to be paged to simply count newlines. This
3013 lines in a string to be paged to simply count newlines. This
3013 prevents over-guessing due to embedded escape sequences. A better
3014 prevents over-guessing due to embedded escape sequences. A better
3014 long-term solution would involve stripping out the control chars
3015 long-term solution would involve stripping out the control chars
3015 for the count, but it's potentially so expensive I just don't
3016 for the count, but it's potentially so expensive I just don't
3016 think it's worth doing.
3017 think it's worth doing.
3017
3018
3018 2002-12-19 *** Released version 0.2.14pre50
3019 2002-12-19 *** Released version 0.2.14pre50
3019
3020
3020 2002-12-19 Fernando Perez <fperez@colorado.edu>
3021 2002-12-19 Fernando Perez <fperez@colorado.edu>
3021
3022
3022 * tools/release (version): Changed release scripts to inform
3023 * tools/release (version): Changed release scripts to inform
3023 Andrea and build a NEWS file with a list of recent changes.
3024 Andrea and build a NEWS file with a list of recent changes.
3024
3025
3025 * IPython/ColorANSI.py (__all__): changed terminal detection
3026 * IPython/ColorANSI.py (__all__): changed terminal detection
3026 code. Seems to work better for xterms without breaking
3027 code. Seems to work better for xterms without breaking
3027 konsole. Will need more testing to determine if WinXP and Mac OSX
3028 konsole. Will need more testing to determine if WinXP and Mac OSX
3028 also work ok.
3029 also work ok.
3029
3030
3030 2002-12-18 *** Released version 0.2.14pre49
3031 2002-12-18 *** Released version 0.2.14pre49
3031
3032
3032 2002-12-18 Fernando Perez <fperez@colorado.edu>
3033 2002-12-18 Fernando Perez <fperez@colorado.edu>
3033
3034
3034 * Docs: added new info about Mac OSX, from Andrea.
3035 * Docs: added new info about Mac OSX, from Andrea.
3035
3036
3036 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
3037 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
3037 allow direct plotting of python strings whose format is the same
3038 allow direct plotting of python strings whose format is the same
3038 of gnuplot data files.
3039 of gnuplot data files.
3039
3040
3040 2002-12-16 Fernando Perez <fperez@colorado.edu>
3041 2002-12-16 Fernando Perez <fperez@colorado.edu>
3041
3042
3042 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
3043 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
3043 value of exit question to be acknowledged.
3044 value of exit question to be acknowledged.
3044
3045
3045 2002-12-03 Fernando Perez <fperez@colorado.edu>
3046 2002-12-03 Fernando Perez <fperez@colorado.edu>
3046
3047
3047 * IPython/ipmaker.py: removed generators, which had been added
3048 * IPython/ipmaker.py: removed generators, which had been added
3048 by mistake in an earlier debugging run. This was causing trouble
3049 by mistake in an earlier debugging run. This was causing trouble
3049 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
3050 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
3050 for pointing this out.
3051 for pointing this out.
3051
3052
3052 2002-11-17 Fernando Perez <fperez@colorado.edu>
3053 2002-11-17 Fernando Perez <fperez@colorado.edu>
3053
3054
3054 * Manual: updated the Gnuplot section.
3055 * Manual: updated the Gnuplot section.
3055
3056
3056 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
3057 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
3057 a much better split of what goes in Runtime and what goes in
3058 a much better split of what goes in Runtime and what goes in
3058 Interactive.
3059 Interactive.
3059
3060
3060 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
3061 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
3061 being imported from iplib.
3062 being imported from iplib.
3062
3063
3063 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
3064 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
3064 for command-passing. Now the global Gnuplot instance is called
3065 for command-passing. Now the global Gnuplot instance is called
3065 'gp' instead of 'g', which was really a far too fragile and
3066 'gp' instead of 'g', which was really a far too fragile and
3066 common name.
3067 common name.
3067
3068
3068 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
3069 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
3069 bounding boxes generated by Gnuplot for square plots.
3070 bounding boxes generated by Gnuplot for square plots.
3070
3071
3071 * IPython/genutils.py (popkey): new function added. I should
3072 * IPython/genutils.py (popkey): new function added. I should
3072 suggest this on c.l.py as a dict method, it seems useful.
3073 suggest this on c.l.py as a dict method, it seems useful.
3073
3074
3074 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
3075 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
3075 to transparently handle PostScript generation. MUCH better than
3076 to transparently handle PostScript generation. MUCH better than
3076 the previous plot_eps/replot_eps (which I removed now). The code
3077 the previous plot_eps/replot_eps (which I removed now). The code
3077 is also fairly clean and well documented now (including
3078 is also fairly clean and well documented now (including
3078 docstrings).
3079 docstrings).
3079
3080
3080 2002-11-13 Fernando Perez <fperez@colorado.edu>
3081 2002-11-13 Fernando Perez <fperez@colorado.edu>
3081
3082
3082 * IPython/Magic.py (Magic.magic_edit): fixed docstring
3083 * IPython/Magic.py (Magic.magic_edit): fixed docstring
3083 (inconsistent with options).
3084 (inconsistent with options).
3084
3085
3085 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
3086 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
3086 manually disabled, I don't know why. Fixed it.
3087 manually disabled, I don't know why. Fixed it.
3087 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
3088 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
3088 eps output.
3089 eps output.
3089
3090
3090 2002-11-12 Fernando Perez <fperez@colorado.edu>
3091 2002-11-12 Fernando Perez <fperez@colorado.edu>
3091
3092
3092 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
3093 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
3093 don't propagate up to caller. Fixes crash reported by François
3094 don't propagate up to caller. Fixes crash reported by François
3094 Pinard.
3095 Pinard.
3095
3096
3096 2002-11-09 Fernando Perez <fperez@colorado.edu>
3097 2002-11-09 Fernando Perez <fperez@colorado.edu>
3097
3098
3098 * IPython/ipmaker.py (make_IPython): fixed problem with writing
3099 * IPython/ipmaker.py (make_IPython): fixed problem with writing
3099 history file for new users.
3100 history file for new users.
3100 (make_IPython): fixed bug where initial install would leave the
3101 (make_IPython): fixed bug where initial install would leave the
3101 user running in the .ipython dir.
3102 user running in the .ipython dir.
3102 (make_IPython): fixed bug where config dir .ipython would be
3103 (make_IPython): fixed bug where config dir .ipython would be
3103 created regardless of the given -ipythondir option. Thanks to Cory
3104 created regardless of the given -ipythondir option. Thanks to Cory
3104 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
3105 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
3105
3106
3106 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
3107 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
3107 type confirmations. Will need to use it in all of IPython's code
3108 type confirmations. Will need to use it in all of IPython's code
3108 consistently.
3109 consistently.
3109
3110
3110 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
3111 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
3111 context to print 31 lines instead of the default 5. This will make
3112 context to print 31 lines instead of the default 5. This will make
3112 the crash reports extremely detailed in case the problem is in
3113 the crash reports extremely detailed in case the problem is in
3113 libraries I don't have access to.
3114 libraries I don't have access to.
3114
3115
3115 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
3116 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
3116 line of defense' code to still crash, but giving users fair
3117 line of defense' code to still crash, but giving users fair
3117 warning. I don't want internal errors to go unreported: if there's
3118 warning. I don't want internal errors to go unreported: if there's
3118 an internal problem, IPython should crash and generate a full
3119 an internal problem, IPython should crash and generate a full
3119 report.
3120 report.
3120
3121
3121 2002-11-08 Fernando Perez <fperez@colorado.edu>
3122 2002-11-08 Fernando Perez <fperez@colorado.edu>
3122
3123
3123 * IPython/iplib.py (InteractiveShell.interact): added code to trap
3124 * IPython/iplib.py (InteractiveShell.interact): added code to trap
3124 otherwise uncaught exceptions which can appear if people set
3125 otherwise uncaught exceptions which can appear if people set
3125 sys.stdout to something badly broken. Thanks to a crash report
3126 sys.stdout to something badly broken. Thanks to a crash report
3126 from henni-AT-mail.brainbot.com.
3127 from henni-AT-mail.brainbot.com.
3127
3128
3128 2002-11-04 Fernando Perez <fperez@colorado.edu>
3129 2002-11-04 Fernando Perez <fperez@colorado.edu>
3129
3130
3130 * IPython/iplib.py (InteractiveShell.interact): added
3131 * IPython/iplib.py (InteractiveShell.interact): added
3131 __IPYTHON__active to the builtins. It's a flag which goes on when
3132 __IPYTHON__active to the builtins. It's a flag which goes on when
3132 the interaction starts and goes off again when it stops. This
3133 the interaction starts and goes off again when it stops. This
3133 allows embedding code to detect being inside IPython. Before this
3134 allows embedding code to detect being inside IPython. Before this
3134 was done via __IPYTHON__, but that only shows that an IPython
3135 was done via __IPYTHON__, but that only shows that an IPython
3135 instance has been created.
3136 instance has been created.
3136
3137
3137 * IPython/Magic.py (Magic.magic_env): I realized that in a
3138 * IPython/Magic.py (Magic.magic_env): I realized that in a
3138 UserDict, instance.data holds the data as a normal dict. So I
3139 UserDict, instance.data holds the data as a normal dict. So I
3139 modified @env to return os.environ.data instead of rebuilding a
3140 modified @env to return os.environ.data instead of rebuilding a
3140 dict by hand.
3141 dict by hand.
3141
3142
3142 2002-11-02 Fernando Perez <fperez@colorado.edu>
3143 2002-11-02 Fernando Perez <fperez@colorado.edu>
3143
3144
3144 * IPython/genutils.py (warn): changed so that level 1 prints no
3145 * IPython/genutils.py (warn): changed so that level 1 prints no
3145 header. Level 2 is now the default (with 'WARNING' header, as
3146 header. Level 2 is now the default (with 'WARNING' header, as
3146 before). I think I tracked all places where changes were needed in
3147 before). I think I tracked all places where changes were needed in
3147 IPython, but outside code using the old level numbering may have
3148 IPython, but outside code using the old level numbering may have
3148 broken.
3149 broken.
3149
3150
3150 * IPython/iplib.py (InteractiveShell.runcode): added this to
3151 * IPython/iplib.py (InteractiveShell.runcode): added this to
3151 handle the tracebacks in SystemExit traps correctly. The previous
3152 handle the tracebacks in SystemExit traps correctly. The previous
3152 code (through interact) was printing more of the stack than
3153 code (through interact) was printing more of the stack than
3153 necessary, showing IPython internal code to the user.
3154 necessary, showing IPython internal code to the user.
3154
3155
3155 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
3156 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
3156 default. Now that the default at the confirmation prompt is yes,
3157 default. Now that the default at the confirmation prompt is yes,
3157 it's not so intrusive. François' argument that ipython sessions
3158 it's not so intrusive. François' argument that ipython sessions
3158 tend to be complex enough not to lose them from an accidental C-d,
3159 tend to be complex enough not to lose them from an accidental C-d,
3159 is a valid one.
3160 is a valid one.
3160
3161
3161 * IPython/iplib.py (InteractiveShell.interact): added a
3162 * IPython/iplib.py (InteractiveShell.interact): added a
3162 showtraceback() call to the SystemExit trap, and modified the exit
3163 showtraceback() call to the SystemExit trap, and modified the exit
3163 confirmation to have yes as the default.
3164 confirmation to have yes as the default.
3164
3165
3165 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
3166 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
3166 this file. It's been gone from the code for a long time, this was
3167 this file. It's been gone from the code for a long time, this was
3167 simply leftover junk.
3168 simply leftover junk.
3168
3169
3169 2002-11-01 Fernando Perez <fperez@colorado.edu>
3170 2002-11-01 Fernando Perez <fperez@colorado.edu>
3170
3171
3171 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
3172 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
3172 added. If set, IPython now traps EOF and asks for
3173 added. If set, IPython now traps EOF and asks for
3173 confirmation. After a request by François Pinard.
3174 confirmation. After a request by François Pinard.
3174
3175
3175 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
3176 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
3176 of @abort, and with a new (better) mechanism for handling the
3177 of @abort, and with a new (better) mechanism for handling the
3177 exceptions.
3178 exceptions.
3178
3179
3179 2002-10-27 Fernando Perez <fperez@colorado.edu>
3180 2002-10-27 Fernando Perez <fperez@colorado.edu>
3180
3181
3181 * IPython/usage.py (__doc__): updated the --help information and
3182 * IPython/usage.py (__doc__): updated the --help information and
3182 the ipythonrc file to indicate that -log generates
3183 the ipythonrc file to indicate that -log generates
3183 ./ipython.log. Also fixed the corresponding info in @logstart.
3184 ./ipython.log. Also fixed the corresponding info in @logstart.
3184 This and several other fixes in the manuals thanks to reports by
3185 This and several other fixes in the manuals thanks to reports by
3185 François Pinard <pinard-AT-iro.umontreal.ca>.
3186 François Pinard <pinard-AT-iro.umontreal.ca>.
3186
3187
3187 * IPython/Logger.py (Logger.switch_log): Fixed error message to
3188 * IPython/Logger.py (Logger.switch_log): Fixed error message to
3188 refer to @logstart (instead of @log, which doesn't exist).
3189 refer to @logstart (instead of @log, which doesn't exist).
3189
3190
3190 * IPython/iplib.py (InteractiveShell._prefilter): fixed
3191 * IPython/iplib.py (InteractiveShell._prefilter): fixed
3191 AttributeError crash. Thanks to Christopher Armstrong
3192 AttributeError crash. Thanks to Christopher Armstrong
3192 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
3193 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
3193 introduced recently (in 0.2.14pre37) with the fix to the eval
3194 introduced recently (in 0.2.14pre37) with the fix to the eval
3194 problem mentioned below.
3195 problem mentioned below.
3195
3196
3196 2002-10-17 Fernando Perez <fperez@colorado.edu>
3197 2002-10-17 Fernando Perez <fperez@colorado.edu>
3197
3198
3198 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
3199 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
3199 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
3200 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
3200
3201
3201 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
3202 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
3202 this function to fix a problem reported by Alex Schmolck. He saw
3203 this function to fix a problem reported by Alex Schmolck. He saw
3203 it with list comprehensions and generators, which were getting
3204 it with list comprehensions and generators, which were getting
3204 called twice. The real problem was an 'eval' call in testing for
3205 called twice. The real problem was an 'eval' call in testing for
3205 automagic which was evaluating the input line silently.
3206 automagic which was evaluating the input line silently.
3206
3207
3207 This is a potentially very nasty bug, if the input has side
3208 This is a potentially very nasty bug, if the input has side
3208 effects which must not be repeated. The code is much cleaner now,
3209 effects which must not be repeated. The code is much cleaner now,
3209 without any blanket 'except' left and with a regexp test for
3210 without any blanket 'except' left and with a regexp test for
3210 actual function names.
3211 actual function names.
3211
3212
3212 But an eval remains, which I'm not fully comfortable with. I just
3213 But an eval remains, which I'm not fully comfortable with. I just
3213 don't know how to find out if an expression could be a callable in
3214 don't know how to find out if an expression could be a callable in
3214 the user's namespace without doing an eval on the string. However
3215 the user's namespace without doing an eval on the string. However
3215 that string is now much more strictly checked so that no code
3216 that string is now much more strictly checked so that no code
3216 slips by, so the eval should only happen for things that can
3217 slips by, so the eval should only happen for things that can
3217 really be only function/method names.
3218 really be only function/method names.
3218
3219
3219 2002-10-15 Fernando Perez <fperez@colorado.edu>
3220 2002-10-15 Fernando Perez <fperez@colorado.edu>
3220
3221
3221 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
3222 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
3222 OSX information to main manual, removed README_Mac_OSX file from
3223 OSX information to main manual, removed README_Mac_OSX file from
3223 distribution. Also updated credits for recent additions.
3224 distribution. Also updated credits for recent additions.
3224
3225
3225 2002-10-10 Fernando Perez <fperez@colorado.edu>
3226 2002-10-10 Fernando Perez <fperez@colorado.edu>
3226
3227
3227 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3228 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3228 terminal-related issues. Many thanks to Andrea Riciputi
3229 terminal-related issues. Many thanks to Andrea Riciputi
3229 <andrea.riciputi-AT-libero.it> for writing it.
3230 <andrea.riciputi-AT-libero.it> for writing it.
3230
3231
3231 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3232 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3232 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3233 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3233
3234
3234 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3235 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3235 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3236 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3236 <syver-en-AT-online.no> who both submitted patches for this problem.
3237 <syver-en-AT-online.no> who both submitted patches for this problem.
3237
3238
3238 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3239 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3239 global embedding to make sure that things don't overwrite user
3240 global embedding to make sure that things don't overwrite user
3240 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3241 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3241
3242
3242 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3243 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3243 compatibility. Thanks to Hayden Callow
3244 compatibility. Thanks to Hayden Callow
3244 <h.callow-AT-elec.canterbury.ac.nz>
3245 <h.callow-AT-elec.canterbury.ac.nz>
3245
3246
3246 2002-10-04 Fernando Perez <fperez@colorado.edu>
3247 2002-10-04 Fernando Perez <fperez@colorado.edu>
3247
3248
3248 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3249 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3249 Gnuplot.File objects.
3250 Gnuplot.File objects.
3250
3251
3251 2002-07-23 Fernando Perez <fperez@colorado.edu>
3252 2002-07-23 Fernando Perez <fperez@colorado.edu>
3252
3253
3253 * IPython/genutils.py (timing): Added timings() and timing() for
3254 * IPython/genutils.py (timing): Added timings() and timing() for
3254 quick access to the most commonly needed data, the execution
3255 quick access to the most commonly needed data, the execution
3255 times. Old timing() renamed to timings_out().
3256 times. Old timing() renamed to timings_out().
3256
3257
3257 2002-07-18 Fernando Perez <fperez@colorado.edu>
3258 2002-07-18 Fernando Perez <fperez@colorado.edu>
3258
3259
3259 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3260 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3260 bug with nested instances disrupting the parent's tab completion.
3261 bug with nested instances disrupting the parent's tab completion.
3261
3262
3262 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3263 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3263 all_completions code to begin the emacs integration.
3264 all_completions code to begin the emacs integration.
3264
3265
3265 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3266 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3266 argument to allow titling individual arrays when plotting.
3267 argument to allow titling individual arrays when plotting.
3267
3268
3268 2002-07-15 Fernando Perez <fperez@colorado.edu>
3269 2002-07-15 Fernando Perez <fperez@colorado.edu>
3269
3270
3270 * setup.py (make_shortcut): changed to retrieve the value of
3271 * setup.py (make_shortcut): changed to retrieve the value of
3271 'Program Files' directory from the registry (this value changes in
3272 'Program Files' directory from the registry (this value changes in
3272 non-english versions of Windows). Thanks to Thomas Fanslau
3273 non-english versions of Windows). Thanks to Thomas Fanslau
3273 <tfanslau-AT-gmx.de> for the report.
3274 <tfanslau-AT-gmx.de> for the report.
3274
3275
3275 2002-07-10 Fernando Perez <fperez@colorado.edu>
3276 2002-07-10 Fernando Perez <fperez@colorado.edu>
3276
3277
3277 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3278 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3278 a bug in pdb, which crashes if a line with only whitespace is
3279 a bug in pdb, which crashes if a line with only whitespace is
3279 entered. Bug report submitted to sourceforge.
3280 entered. Bug report submitted to sourceforge.
3280
3281
3281 2002-07-09 Fernando Perez <fperez@colorado.edu>
3282 2002-07-09 Fernando Perez <fperez@colorado.edu>
3282
3283
3283 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3284 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3284 reporting exceptions (it's a bug in inspect.py, I just set a
3285 reporting exceptions (it's a bug in inspect.py, I just set a
3285 workaround).
3286 workaround).
3286
3287
3287 2002-07-08 Fernando Perez <fperez@colorado.edu>
3288 2002-07-08 Fernando Perez <fperez@colorado.edu>
3288
3289
3289 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3290 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3290 __IPYTHON__ in __builtins__ to show up in user_ns.
3291 __IPYTHON__ in __builtins__ to show up in user_ns.
3291
3292
3292 2002-07-03 Fernando Perez <fperez@colorado.edu>
3293 2002-07-03 Fernando Perez <fperez@colorado.edu>
3293
3294
3294 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3295 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3295 name from @gp_set_instance to @gp_set_default.
3296 name from @gp_set_instance to @gp_set_default.
3296
3297
3297 * IPython/ipmaker.py (make_IPython): default editor value set to
3298 * IPython/ipmaker.py (make_IPython): default editor value set to
3298 '0' (a string), to match the rc file. Otherwise will crash when
3299 '0' (a string), to match the rc file. Otherwise will crash when
3299 .strip() is called on it.
3300 .strip() is called on it.
3300
3301
3301
3302
3302 2002-06-28 Fernando Perez <fperez@colorado.edu>
3303 2002-06-28 Fernando Perez <fperez@colorado.edu>
3303
3304
3304 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3305 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3305 of files in current directory when a file is executed via
3306 of files in current directory when a file is executed via
3306 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3307 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3307
3308
3308 * setup.py (manfiles): fix for rpm builds, submitted by RA
3309 * setup.py (manfiles): fix for rpm builds, submitted by RA
3309 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3310 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3310
3311
3311 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3312 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3312 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3313 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3313 string!). A. Schmolck caught this one.
3314 string!). A. Schmolck caught this one.
3314
3315
3315 2002-06-27 Fernando Perez <fperez@colorado.edu>
3316 2002-06-27 Fernando Perez <fperez@colorado.edu>
3316
3317
3317 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3318 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3318 defined files at the cmd line. __name__ wasn't being set to
3319 defined files at the cmd line. __name__ wasn't being set to
3319 __main__.
3320 __main__.
3320
3321
3321 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3322 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3322 regular lists and tuples besides Numeric arrays.
3323 regular lists and tuples besides Numeric arrays.
3323
3324
3324 * IPython/Prompts.py (CachedOutput.__call__): Added output
3325 * IPython/Prompts.py (CachedOutput.__call__): Added output
3325 supression for input ending with ';'. Similar to Mathematica and
3326 supression for input ending with ';'. Similar to Mathematica and
3326 Matlab. The _* vars and Out[] list are still updated, just like
3327 Matlab. The _* vars and Out[] list are still updated, just like
3327 Mathematica behaves.
3328 Mathematica behaves.
3328
3329
3329 2002-06-25 Fernando Perez <fperez@colorado.edu>
3330 2002-06-25 Fernando Perez <fperez@colorado.edu>
3330
3331
3331 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3332 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3332 .ini extensions for profiels under Windows.
3333 .ini extensions for profiels under Windows.
3333
3334
3334 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3335 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3335 string form. Fix contributed by Alexander Schmolck
3336 string form. Fix contributed by Alexander Schmolck
3336 <a.schmolck-AT-gmx.net>
3337 <a.schmolck-AT-gmx.net>
3337
3338
3338 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3339 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3339 pre-configured Gnuplot instance.
3340 pre-configured Gnuplot instance.
3340
3341
3341 2002-06-21 Fernando Perez <fperez@colorado.edu>
3342 2002-06-21 Fernando Perez <fperez@colorado.edu>
3342
3343
3343 * IPython/numutils.py (exp_safe): new function, works around the
3344 * IPython/numutils.py (exp_safe): new function, works around the
3344 underflow problems in Numeric.
3345 underflow problems in Numeric.
3345 (log2): New fn. Safe log in base 2: returns exact integer answer
3346 (log2): New fn. Safe log in base 2: returns exact integer answer
3346 for exact integer powers of 2.
3347 for exact integer powers of 2.
3347
3348
3348 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3349 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3349 properly.
3350 properly.
3350
3351
3351 2002-06-20 Fernando Perez <fperez@colorado.edu>
3352 2002-06-20 Fernando Perez <fperez@colorado.edu>
3352
3353
3353 * IPython/genutils.py (timing): new function like
3354 * IPython/genutils.py (timing): new function like
3354 Mathematica's. Similar to time_test, but returns more info.
3355 Mathematica's. Similar to time_test, but returns more info.
3355
3356
3356 2002-06-18 Fernando Perez <fperez@colorado.edu>
3357 2002-06-18 Fernando Perez <fperez@colorado.edu>
3357
3358
3358 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3359 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3359 according to Mike Heeter's suggestions.
3360 according to Mike Heeter's suggestions.
3360
3361
3361 2002-06-16 Fernando Perez <fperez@colorado.edu>
3362 2002-06-16 Fernando Perez <fperez@colorado.edu>
3362
3363
3363 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3364 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3364 system. GnuplotMagic is gone as a user-directory option. New files
3365 system. GnuplotMagic is gone as a user-directory option. New files
3365 make it easier to use all the gnuplot stuff both from external
3366 make it easier to use all the gnuplot stuff both from external
3366 programs as well as from IPython. Had to rewrite part of
3367 programs as well as from IPython. Had to rewrite part of
3367 hardcopy() b/c of a strange bug: often the ps files simply don't
3368 hardcopy() b/c of a strange bug: often the ps files simply don't
3368 get created, and require a repeat of the command (often several
3369 get created, and require a repeat of the command (often several
3369 times).
3370 times).
3370
3371
3371 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3372 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3372 resolve output channel at call time, so that if sys.stderr has
3373 resolve output channel at call time, so that if sys.stderr has
3373 been redirected by user this gets honored.
3374 been redirected by user this gets honored.
3374
3375
3375 2002-06-13 Fernando Perez <fperez@colorado.edu>
3376 2002-06-13 Fernando Perez <fperez@colorado.edu>
3376
3377
3377 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3378 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3378 IPShell. Kept a copy with the old names to avoid breaking people's
3379 IPShell. Kept a copy with the old names to avoid breaking people's
3379 embedded code.
3380 embedded code.
3380
3381
3381 * IPython/ipython: simplified it to the bare minimum after
3382 * IPython/ipython: simplified it to the bare minimum after
3382 Holger's suggestions. Added info about how to use it in
3383 Holger's suggestions. Added info about how to use it in
3383 PYTHONSTARTUP.
3384 PYTHONSTARTUP.
3384
3385
3385 * IPython/Shell.py (IPythonShell): changed the options passing
3386 * IPython/Shell.py (IPythonShell): changed the options passing
3386 from a string with funky %s replacements to a straight list. Maybe
3387 from a string with funky %s replacements to a straight list. Maybe
3387 a bit more typing, but it follows sys.argv conventions, so there's
3388 a bit more typing, but it follows sys.argv conventions, so there's
3388 less special-casing to remember.
3389 less special-casing to remember.
3389
3390
3390 2002-06-12 Fernando Perez <fperez@colorado.edu>
3391 2002-06-12 Fernando Perez <fperez@colorado.edu>
3391
3392
3392 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3393 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3393 command. Thanks to a suggestion by Mike Heeter.
3394 command. Thanks to a suggestion by Mike Heeter.
3394 (Magic.magic_pfile): added behavior to look at filenames if given
3395 (Magic.magic_pfile): added behavior to look at filenames if given
3395 arg is not a defined object.
3396 arg is not a defined object.
3396 (Magic.magic_save): New @save function to save code snippets. Also
3397 (Magic.magic_save): New @save function to save code snippets. Also
3397 a Mike Heeter idea.
3398 a Mike Heeter idea.
3398
3399
3399 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3400 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3400 plot() and replot(). Much more convenient now, especially for
3401 plot() and replot(). Much more convenient now, especially for
3401 interactive use.
3402 interactive use.
3402
3403
3403 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3404 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3404 filenames.
3405 filenames.
3405
3406
3406 2002-06-02 Fernando Perez <fperez@colorado.edu>
3407 2002-06-02 Fernando Perez <fperez@colorado.edu>
3407
3408
3408 * IPython/Struct.py (Struct.__init__): modified to admit
3409 * IPython/Struct.py (Struct.__init__): modified to admit
3409 initialization via another struct.
3410 initialization via another struct.
3410
3411
3411 * IPython/genutils.py (SystemExec.__init__): New stateful
3412 * IPython/genutils.py (SystemExec.__init__): New stateful
3412 interface to xsys and bq. Useful for writing system scripts.
3413 interface to xsys and bq. Useful for writing system scripts.
3413
3414
3414 2002-05-30 Fernando Perez <fperez@colorado.edu>
3415 2002-05-30 Fernando Perez <fperez@colorado.edu>
3415
3416
3416 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3417 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3417 documents. This will make the user download smaller (it's getting
3418 documents. This will make the user download smaller (it's getting
3418 too big).
3419 too big).
3419
3420
3420 2002-05-29 Fernando Perez <fperez@colorado.edu>
3421 2002-05-29 Fernando Perez <fperez@colorado.edu>
3421
3422
3422 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3423 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3423 fix problems with shelve and pickle. Seems to work, but I don't
3424 fix problems with shelve and pickle. Seems to work, but I don't
3424 know if corner cases break it. Thanks to Mike Heeter
3425 know if corner cases break it. Thanks to Mike Heeter
3425 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3426 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3426
3427
3427 2002-05-24 Fernando Perez <fperez@colorado.edu>
3428 2002-05-24 Fernando Perez <fperez@colorado.edu>
3428
3429
3429 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3430 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3430 macros having broken.
3431 macros having broken.
3431
3432
3432 2002-05-21 Fernando Perez <fperez@colorado.edu>
3433 2002-05-21 Fernando Perez <fperez@colorado.edu>
3433
3434
3434 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3435 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3435 introduced logging bug: all history before logging started was
3436 introduced logging bug: all history before logging started was
3436 being written one character per line! This came from the redesign
3437 being written one character per line! This came from the redesign
3437 of the input history as a special list which slices to strings,
3438 of the input history as a special list which slices to strings,
3438 not to lists.
3439 not to lists.
3439
3440
3440 2002-05-20 Fernando Perez <fperez@colorado.edu>
3441 2002-05-20 Fernando Perez <fperez@colorado.edu>
3441
3442
3442 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3443 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3443 be an attribute of all classes in this module. The design of these
3444 be an attribute of all classes in this module. The design of these
3444 classes needs some serious overhauling.
3445 classes needs some serious overhauling.
3445
3446
3446 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3447 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3447 which was ignoring '_' in option names.
3448 which was ignoring '_' in option names.
3448
3449
3449 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3450 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3450 'Verbose_novars' to 'Context' and made it the new default. It's a
3451 'Verbose_novars' to 'Context' and made it the new default. It's a
3451 bit more readable and also safer than verbose.
3452 bit more readable and also safer than verbose.
3452
3453
3453 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3454 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3454 triple-quoted strings.
3455 triple-quoted strings.
3455
3456
3456 * IPython/OInspect.py (__all__): new module exposing the object
3457 * IPython/OInspect.py (__all__): new module exposing the object
3457 introspection facilities. Now the corresponding magics are dummy
3458 introspection facilities. Now the corresponding magics are dummy
3458 wrappers around this. Having this module will make it much easier
3459 wrappers around this. Having this module will make it much easier
3459 to put these functions into our modified pdb.
3460 to put these functions into our modified pdb.
3460 This new object inspector system uses the new colorizing module,
3461 This new object inspector system uses the new colorizing module,
3461 so source code and other things are nicely syntax highlighted.
3462 so source code and other things are nicely syntax highlighted.
3462
3463
3463 2002-05-18 Fernando Perez <fperez@colorado.edu>
3464 2002-05-18 Fernando Perez <fperez@colorado.edu>
3464
3465
3465 * IPython/ColorANSI.py: Split the coloring tools into a separate
3466 * IPython/ColorANSI.py: Split the coloring tools into a separate
3466 module so I can use them in other code easier (they were part of
3467 module so I can use them in other code easier (they were part of
3467 ultraTB).
3468 ultraTB).
3468
3469
3469 2002-05-17 Fernando Perez <fperez@colorado.edu>
3470 2002-05-17 Fernando Perez <fperez@colorado.edu>
3470
3471
3471 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3472 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3472 fixed it to set the global 'g' also to the called instance, as
3473 fixed it to set the global 'g' also to the called instance, as
3473 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3474 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3474 user's 'g' variables).
3475 user's 'g' variables).
3475
3476
3476 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3477 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3477 global variables (aliases to _ih,_oh) so that users which expect
3478 global variables (aliases to _ih,_oh) so that users which expect
3478 In[5] or Out[7] to work aren't unpleasantly surprised.
3479 In[5] or Out[7] to work aren't unpleasantly surprised.
3479 (InputList.__getslice__): new class to allow executing slices of
3480 (InputList.__getslice__): new class to allow executing slices of
3480 input history directly. Very simple class, complements the use of
3481 input history directly. Very simple class, complements the use of
3481 macros.
3482 macros.
3482
3483
3483 2002-05-16 Fernando Perez <fperez@colorado.edu>
3484 2002-05-16 Fernando Perez <fperez@colorado.edu>
3484
3485
3485 * setup.py (docdirbase): make doc directory be just doc/IPython
3486 * setup.py (docdirbase): make doc directory be just doc/IPython
3486 without version numbers, it will reduce clutter for users.
3487 without version numbers, it will reduce clutter for users.
3487
3488
3488 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3489 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3489 execfile call to prevent possible memory leak. See for details:
3490 execfile call to prevent possible memory leak. See for details:
3490 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3491 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3491
3492
3492 2002-05-15 Fernando Perez <fperez@colorado.edu>
3493 2002-05-15 Fernando Perez <fperez@colorado.edu>
3493
3494
3494 * IPython/Magic.py (Magic.magic_psource): made the object
3495 * IPython/Magic.py (Magic.magic_psource): made the object
3495 introspection names be more standard: pdoc, pdef, pfile and
3496 introspection names be more standard: pdoc, pdef, pfile and
3496 psource. They all print/page their output, and it makes
3497 psource. They all print/page their output, and it makes
3497 remembering them easier. Kept old names for compatibility as
3498 remembering them easier. Kept old names for compatibility as
3498 aliases.
3499 aliases.
3499
3500
3500 2002-05-14 Fernando Perez <fperez@colorado.edu>
3501 2002-05-14 Fernando Perez <fperez@colorado.edu>
3501
3502
3502 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3503 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3503 what the mouse problem was. The trick is to use gnuplot with temp
3504 what the mouse problem was. The trick is to use gnuplot with temp
3504 files and NOT with pipes (for data communication), because having
3505 files and NOT with pipes (for data communication), because having
3505 both pipes and the mouse on is bad news.
3506 both pipes and the mouse on is bad news.
3506
3507
3507 2002-05-13 Fernando Perez <fperez@colorado.edu>
3508 2002-05-13 Fernando Perez <fperez@colorado.edu>
3508
3509
3509 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3510 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3510 bug. Information would be reported about builtins even when
3511 bug. Information would be reported about builtins even when
3511 user-defined functions overrode them.
3512 user-defined functions overrode them.
3512
3513
3513 2002-05-11 Fernando Perez <fperez@colorado.edu>
3514 2002-05-11 Fernando Perez <fperez@colorado.edu>
3514
3515
3515 * IPython/__init__.py (__all__): removed FlexCompleter from
3516 * IPython/__init__.py (__all__): removed FlexCompleter from
3516 __all__ so that things don't fail in platforms without readline.
3517 __all__ so that things don't fail in platforms without readline.
3517
3518
3518 2002-05-10 Fernando Perez <fperez@colorado.edu>
3519 2002-05-10 Fernando Perez <fperez@colorado.edu>
3519
3520
3520 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3521 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3521 it requires Numeric, effectively making Numeric a dependency for
3522 it requires Numeric, effectively making Numeric a dependency for
3522 IPython.
3523 IPython.
3523
3524
3524 * Released 0.2.13
3525 * Released 0.2.13
3525
3526
3526 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3527 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3527 profiler interface. Now all the major options from the profiler
3528 profiler interface. Now all the major options from the profiler
3528 module are directly supported in IPython, both for single
3529 module are directly supported in IPython, both for single
3529 expressions (@prun) and for full programs (@run -p).
3530 expressions (@prun) and for full programs (@run -p).
3530
3531
3531 2002-05-09 Fernando Perez <fperez@colorado.edu>
3532 2002-05-09 Fernando Perez <fperez@colorado.edu>
3532
3533
3533 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3534 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3534 magic properly formatted for screen.
3535 magic properly formatted for screen.
3535
3536
3536 * setup.py (make_shortcut): Changed things to put pdf version in
3537 * setup.py (make_shortcut): Changed things to put pdf version in
3537 doc/ instead of doc/manual (had to change lyxport a bit).
3538 doc/ instead of doc/manual (had to change lyxport a bit).
3538
3539
3539 * IPython/Magic.py (Profile.string_stats): made profile runs go
3540 * IPython/Magic.py (Profile.string_stats): made profile runs go
3540 through pager (they are long and a pager allows searching, saving,
3541 through pager (they are long and a pager allows searching, saving,
3541 etc.)
3542 etc.)
3542
3543
3543 2002-05-08 Fernando Perez <fperez@colorado.edu>
3544 2002-05-08 Fernando Perez <fperez@colorado.edu>
3544
3545
3545 * Released 0.2.12
3546 * Released 0.2.12
3546
3547
3547 2002-05-06 Fernando Perez <fperez@colorado.edu>
3548 2002-05-06 Fernando Perez <fperez@colorado.edu>
3548
3549
3549 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3550 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3550 introduced); 'hist n1 n2' was broken.
3551 introduced); 'hist n1 n2' was broken.
3551 (Magic.magic_pdb): added optional on/off arguments to @pdb
3552 (Magic.magic_pdb): added optional on/off arguments to @pdb
3552 (Magic.magic_run): added option -i to @run, which executes code in
3553 (Magic.magic_run): added option -i to @run, which executes code in
3553 the IPython namespace instead of a clean one. Also added @irun as
3554 the IPython namespace instead of a clean one. Also added @irun as
3554 an alias to @run -i.
3555 an alias to @run -i.
3555
3556
3556 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3557 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3557 fixed (it didn't really do anything, the namespaces were wrong).
3558 fixed (it didn't really do anything, the namespaces were wrong).
3558
3559
3559 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3560 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3560
3561
3561 * IPython/__init__.py (__all__): Fixed package namespace, now
3562 * IPython/__init__.py (__all__): Fixed package namespace, now
3562 'import IPython' does give access to IPython.<all> as
3563 'import IPython' does give access to IPython.<all> as
3563 expected. Also renamed __release__ to Release.
3564 expected. Also renamed __release__ to Release.
3564
3565
3565 * IPython/Debugger.py (__license__): created new Pdb class which
3566 * IPython/Debugger.py (__license__): created new Pdb class which
3566 functions like a drop-in for the normal pdb.Pdb but does NOT
3567 functions like a drop-in for the normal pdb.Pdb but does NOT
3567 import readline by default. This way it doesn't muck up IPython's
3568 import readline by default. This way it doesn't muck up IPython's
3568 readline handling, and now tab-completion finally works in the
3569 readline handling, and now tab-completion finally works in the
3569 debugger -- sort of. It completes things globally visible, but the
3570 debugger -- sort of. It completes things globally visible, but the
3570 completer doesn't track the stack as pdb walks it. That's a bit
3571 completer doesn't track the stack as pdb walks it. That's a bit
3571 tricky, and I'll have to implement it later.
3572 tricky, and I'll have to implement it later.
3572
3573
3573 2002-05-05 Fernando Perez <fperez@colorado.edu>
3574 2002-05-05 Fernando Perez <fperez@colorado.edu>
3574
3575
3575 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3576 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3576 magic docstrings when printed via ? (explicit \'s were being
3577 magic docstrings when printed via ? (explicit \'s were being
3577 printed).
3578 printed).
3578
3579
3579 * IPython/ipmaker.py (make_IPython): fixed namespace
3580 * IPython/ipmaker.py (make_IPython): fixed namespace
3580 identification bug. Now variables loaded via logs or command-line
3581 identification bug. Now variables loaded via logs or command-line
3581 files are recognized in the interactive namespace by @who.
3582 files are recognized in the interactive namespace by @who.
3582
3583
3583 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3584 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3584 log replay system stemming from the string form of Structs.
3585 log replay system stemming from the string form of Structs.
3585
3586
3586 * IPython/Magic.py (Macro.__init__): improved macros to properly
3587 * IPython/Magic.py (Macro.__init__): improved macros to properly
3587 handle magic commands in them.
3588 handle magic commands in them.
3588 (Magic.magic_logstart): usernames are now expanded so 'logstart
3589 (Magic.magic_logstart): usernames are now expanded so 'logstart
3589 ~/mylog' now works.
3590 ~/mylog' now works.
3590
3591
3591 * IPython/iplib.py (complete): fixed bug where paths starting with
3592 * IPython/iplib.py (complete): fixed bug where paths starting with
3592 '/' would be completed as magic names.
3593 '/' would be completed as magic names.
3593
3594
3594 2002-05-04 Fernando Perez <fperez@colorado.edu>
3595 2002-05-04 Fernando Perez <fperez@colorado.edu>
3595
3596
3596 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3597 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3597 allow running full programs under the profiler's control.
3598 allow running full programs under the profiler's control.
3598
3599
3599 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3600 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3600 mode to report exceptions verbosely but without formatting
3601 mode to report exceptions verbosely but without formatting
3601 variables. This addresses the issue of ipython 'freezing' (it's
3602 variables. This addresses the issue of ipython 'freezing' (it's
3602 not frozen, but caught in an expensive formatting loop) when huge
3603 not frozen, but caught in an expensive formatting loop) when huge
3603 variables are in the context of an exception.
3604 variables are in the context of an exception.
3604 (VerboseTB.text): Added '--->' markers at line where exception was
3605 (VerboseTB.text): Added '--->' markers at line where exception was
3605 triggered. Much clearer to read, especially in NoColor modes.
3606 triggered. Much clearer to read, especially in NoColor modes.
3606
3607
3607 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3608 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3608 implemented in reverse when changing to the new parse_options().
3609 implemented in reverse when changing to the new parse_options().
3609
3610
3610 2002-05-03 Fernando Perez <fperez@colorado.edu>
3611 2002-05-03 Fernando Perez <fperez@colorado.edu>
3611
3612
3612 * IPython/Magic.py (Magic.parse_options): new function so that
3613 * IPython/Magic.py (Magic.parse_options): new function so that
3613 magics can parse options easier.
3614 magics can parse options easier.
3614 (Magic.magic_prun): new function similar to profile.run(),
3615 (Magic.magic_prun): new function similar to profile.run(),
3615 suggested by Chris Hart.
3616 suggested by Chris Hart.
3616 (Magic.magic_cd): fixed behavior so that it only changes if
3617 (Magic.magic_cd): fixed behavior so that it only changes if
3617 directory actually is in history.
3618 directory actually is in history.
3618
3619
3619 * IPython/usage.py (__doc__): added information about potential
3620 * IPython/usage.py (__doc__): added information about potential
3620 slowness of Verbose exception mode when there are huge data
3621 slowness of Verbose exception mode when there are huge data
3621 structures to be formatted (thanks to Archie Paulson).
3622 structures to be formatted (thanks to Archie Paulson).
3622
3623
3623 * IPython/ipmaker.py (make_IPython): Changed default logging
3624 * IPython/ipmaker.py (make_IPython): Changed default logging
3624 (when simply called with -log) to use curr_dir/ipython.log in
3625 (when simply called with -log) to use curr_dir/ipython.log in
3625 rotate mode. Fixed crash which was occuring with -log before
3626 rotate mode. Fixed crash which was occuring with -log before
3626 (thanks to Jim Boyle).
3627 (thanks to Jim Boyle).
3627
3628
3628 2002-05-01 Fernando Perez <fperez@colorado.edu>
3629 2002-05-01 Fernando Perez <fperez@colorado.edu>
3629
3630
3630 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3631 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3631 was nasty -- though somewhat of a corner case).
3632 was nasty -- though somewhat of a corner case).
3632
3633
3633 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3634 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3634 text (was a bug).
3635 text (was a bug).
3635
3636
3636 2002-04-30 Fernando Perez <fperez@colorado.edu>
3637 2002-04-30 Fernando Perez <fperez@colorado.edu>
3637
3638
3638 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3639 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3639 a print after ^D or ^C from the user so that the In[] prompt
3640 a print after ^D or ^C from the user so that the In[] prompt
3640 doesn't over-run the gnuplot one.
3641 doesn't over-run the gnuplot one.
3641
3642
3642 2002-04-29 Fernando Perez <fperez@colorado.edu>
3643 2002-04-29 Fernando Perez <fperez@colorado.edu>
3643
3644
3644 * Released 0.2.10
3645 * Released 0.2.10
3645
3646
3646 * IPython/__release__.py (version): get date dynamically.
3647 * IPython/__release__.py (version): get date dynamically.
3647
3648
3648 * Misc. documentation updates thanks to Arnd's comments. Also ran
3649 * Misc. documentation updates thanks to Arnd's comments. Also ran
3649 a full spellcheck on the manual (hadn't been done in a while).
3650 a full spellcheck on the manual (hadn't been done in a while).
3650
3651
3651 2002-04-27 Fernando Perez <fperez@colorado.edu>
3652 2002-04-27 Fernando Perez <fperez@colorado.edu>
3652
3653
3653 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3654 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3654 starting a log in mid-session would reset the input history list.
3655 starting a log in mid-session would reset the input history list.
3655
3656
3656 2002-04-26 Fernando Perez <fperez@colorado.edu>
3657 2002-04-26 Fernando Perez <fperez@colorado.edu>
3657
3658
3658 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3659 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3659 all files were being included in an update. Now anything in
3660 all files were being included in an update. Now anything in
3660 UserConfig that matches [A-Za-z]*.py will go (this excludes
3661 UserConfig that matches [A-Za-z]*.py will go (this excludes
3661 __init__.py)
3662 __init__.py)
3662
3663
3663 2002-04-25 Fernando Perez <fperez@colorado.edu>
3664 2002-04-25 Fernando Perez <fperez@colorado.edu>
3664
3665
3665 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3666 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3666 to __builtins__ so that any form of embedded or imported code can
3667 to __builtins__ so that any form of embedded or imported code can
3667 test for being inside IPython.
3668 test for being inside IPython.
3668
3669
3669 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3670 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3670 changed to GnuplotMagic because it's now an importable module,
3671 changed to GnuplotMagic because it's now an importable module,
3671 this makes the name follow that of the standard Gnuplot module.
3672 this makes the name follow that of the standard Gnuplot module.
3672 GnuplotMagic can now be loaded at any time in mid-session.
3673 GnuplotMagic can now be loaded at any time in mid-session.
3673
3674
3674 2002-04-24 Fernando Perez <fperez@colorado.edu>
3675 2002-04-24 Fernando Perez <fperez@colorado.edu>
3675
3676
3676 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3677 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3677 the globals (IPython has its own namespace) and the
3678 the globals (IPython has its own namespace) and the
3678 PhysicalQuantity stuff is much better anyway.
3679 PhysicalQuantity stuff is much better anyway.
3679
3680
3680 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3681 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3681 embedding example to standard user directory for
3682 embedding example to standard user directory for
3682 distribution. Also put it in the manual.
3683 distribution. Also put it in the manual.
3683
3684
3684 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3685 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3685 instance as first argument (so it doesn't rely on some obscure
3686 instance as first argument (so it doesn't rely on some obscure
3686 hidden global).
3687 hidden global).
3687
3688
3688 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3689 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3689 delimiters. While it prevents ().TAB from working, it allows
3690 delimiters. While it prevents ().TAB from working, it allows
3690 completions in open (... expressions. This is by far a more common
3691 completions in open (... expressions. This is by far a more common
3691 case.
3692 case.
3692
3693
3693 2002-04-23 Fernando Perez <fperez@colorado.edu>
3694 2002-04-23 Fernando Perez <fperez@colorado.edu>
3694
3695
3695 * IPython/Extensions/InterpreterPasteInput.py: new
3696 * IPython/Extensions/InterpreterPasteInput.py: new
3696 syntax-processing module for pasting lines with >>> or ... at the
3697 syntax-processing module for pasting lines with >>> or ... at the
3697 start.
3698 start.
3698
3699
3699 * IPython/Extensions/PhysicalQ_Interactive.py
3700 * IPython/Extensions/PhysicalQ_Interactive.py
3700 (PhysicalQuantityInteractive.__int__): fixed to work with either
3701 (PhysicalQuantityInteractive.__int__): fixed to work with either
3701 Numeric or math.
3702 Numeric or math.
3702
3703
3703 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3704 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3704 provided profiles. Now we have:
3705 provided profiles. Now we have:
3705 -math -> math module as * and cmath with its own namespace.
3706 -math -> math module as * and cmath with its own namespace.
3706 -numeric -> Numeric as *, plus gnuplot & grace
3707 -numeric -> Numeric as *, plus gnuplot & grace
3707 -physics -> same as before
3708 -physics -> same as before
3708
3709
3709 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3710 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3710 user-defined magics wouldn't be found by @magic if they were
3711 user-defined magics wouldn't be found by @magic if they were
3711 defined as class methods. Also cleaned up the namespace search
3712 defined as class methods. Also cleaned up the namespace search
3712 logic and the string building (to use %s instead of many repeated
3713 logic and the string building (to use %s instead of many repeated
3713 string adds).
3714 string adds).
3714
3715
3715 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3716 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3716 of user-defined magics to operate with class methods (cleaner, in
3717 of user-defined magics to operate with class methods (cleaner, in
3717 line with the gnuplot code).
3718 line with the gnuplot code).
3718
3719
3719 2002-04-22 Fernando Perez <fperez@colorado.edu>
3720 2002-04-22 Fernando Perez <fperez@colorado.edu>
3720
3721
3721 * setup.py: updated dependency list so that manual is updated when
3722 * setup.py: updated dependency list so that manual is updated when
3722 all included files change.
3723 all included files change.
3723
3724
3724 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3725 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3725 the delimiter removal option (the fix is ugly right now).
3726 the delimiter removal option (the fix is ugly right now).
3726
3727
3727 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3728 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3728 all of the math profile (quicker loading, no conflict between
3729 all of the math profile (quicker loading, no conflict between
3729 g-9.8 and g-gnuplot).
3730 g-9.8 and g-gnuplot).
3730
3731
3731 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3732 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3732 name of post-mortem files to IPython_crash_report.txt.
3733 name of post-mortem files to IPython_crash_report.txt.
3733
3734
3734 * Cleanup/update of the docs. Added all the new readline info and
3735 * Cleanup/update of the docs. Added all the new readline info and
3735 formatted all lists as 'real lists'.
3736 formatted all lists as 'real lists'.
3736
3737
3737 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3738 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3738 tab-completion options, since the full readline parse_and_bind is
3739 tab-completion options, since the full readline parse_and_bind is
3739 now accessible.
3740 now accessible.
3740
3741
3741 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3742 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3742 handling of readline options. Now users can specify any string to
3743 handling of readline options. Now users can specify any string to
3743 be passed to parse_and_bind(), as well as the delimiters to be
3744 be passed to parse_and_bind(), as well as the delimiters to be
3744 removed.
3745 removed.
3745 (InteractiveShell.__init__): Added __name__ to the global
3746 (InteractiveShell.__init__): Added __name__ to the global
3746 namespace so that things like Itpl which rely on its existence
3747 namespace so that things like Itpl which rely on its existence
3747 don't crash.
3748 don't crash.
3748 (InteractiveShell._prefilter): Defined the default with a _ so
3749 (InteractiveShell._prefilter): Defined the default with a _ so
3749 that prefilter() is easier to override, while the default one
3750 that prefilter() is easier to override, while the default one
3750 remains available.
3751 remains available.
3751
3752
3752 2002-04-18 Fernando Perez <fperez@colorado.edu>
3753 2002-04-18 Fernando Perez <fperez@colorado.edu>
3753
3754
3754 * Added information about pdb in the docs.
3755 * Added information about pdb in the docs.
3755
3756
3756 2002-04-17 Fernando Perez <fperez@colorado.edu>
3757 2002-04-17 Fernando Perez <fperez@colorado.edu>
3757
3758
3758 * IPython/ipmaker.py (make_IPython): added rc_override option to
3759 * IPython/ipmaker.py (make_IPython): added rc_override option to
3759 allow passing config options at creation time which may override
3760 allow passing config options at creation time which may override
3760 anything set in the config files or command line. This is
3761 anything set in the config files or command line. This is
3761 particularly useful for configuring embedded instances.
3762 particularly useful for configuring embedded instances.
3762
3763
3763 2002-04-15 Fernando Perez <fperez@colorado.edu>
3764 2002-04-15 Fernando Perez <fperez@colorado.edu>
3764
3765
3765 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3766 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3766 crash embedded instances because of the input cache falling out of
3767 crash embedded instances because of the input cache falling out of
3767 sync with the output counter.
3768 sync with the output counter.
3768
3769
3769 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3770 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3770 mode which calls pdb after an uncaught exception in IPython itself.
3771 mode which calls pdb after an uncaught exception in IPython itself.
3771
3772
3772 2002-04-14 Fernando Perez <fperez@colorado.edu>
3773 2002-04-14 Fernando Perez <fperez@colorado.edu>
3773
3774
3774 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3775 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3775 readline, fix it back after each call.
3776 readline, fix it back after each call.
3776
3777
3777 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3778 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3778 method to force all access via __call__(), which guarantees that
3779 method to force all access via __call__(), which guarantees that
3779 traceback references are properly deleted.
3780 traceback references are properly deleted.
3780
3781
3781 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3782 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3782 improve printing when pprint is in use.
3783 improve printing when pprint is in use.
3783
3784
3784 2002-04-13 Fernando Perez <fperez@colorado.edu>
3785 2002-04-13 Fernando Perez <fperez@colorado.edu>
3785
3786
3786 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3787 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3787 exceptions aren't caught anymore. If the user triggers one, he
3788 exceptions aren't caught anymore. If the user triggers one, he
3788 should know why he's doing it and it should go all the way up,
3789 should know why he's doing it and it should go all the way up,
3789 just like any other exception. So now @abort will fully kill the
3790 just like any other exception. So now @abort will fully kill the
3790 embedded interpreter and the embedding code (unless that happens
3791 embedded interpreter and the embedding code (unless that happens
3791 to catch SystemExit).
3792 to catch SystemExit).
3792
3793
3793 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3794 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3794 and a debugger() method to invoke the interactive pdb debugger
3795 and a debugger() method to invoke the interactive pdb debugger
3795 after printing exception information. Also added the corresponding
3796 after printing exception information. Also added the corresponding
3796 -pdb option and @pdb magic to control this feature, and updated
3797 -pdb option and @pdb magic to control this feature, and updated
3797 the docs. After a suggestion from Christopher Hart
3798 the docs. After a suggestion from Christopher Hart
3798 (hart-AT-caltech.edu).
3799 (hart-AT-caltech.edu).
3799
3800
3800 2002-04-12 Fernando Perez <fperez@colorado.edu>
3801 2002-04-12 Fernando Perez <fperez@colorado.edu>
3801
3802
3802 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3803 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3803 the exception handlers defined by the user (not the CrashHandler)
3804 the exception handlers defined by the user (not the CrashHandler)
3804 so that user exceptions don't trigger an ipython bug report.
3805 so that user exceptions don't trigger an ipython bug report.
3805
3806
3806 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3807 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3807 configurable (it should have always been so).
3808 configurable (it should have always been so).
3808
3809
3809 2002-03-26 Fernando Perez <fperez@colorado.edu>
3810 2002-03-26 Fernando Perez <fperez@colorado.edu>
3810
3811
3811 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3812 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3812 and there to fix embedding namespace issues. This should all be
3813 and there to fix embedding namespace issues. This should all be
3813 done in a more elegant way.
3814 done in a more elegant way.
3814
3815
3815 2002-03-25 Fernando Perez <fperez@colorado.edu>
3816 2002-03-25 Fernando Perez <fperez@colorado.edu>
3816
3817
3817 * IPython/genutils.py (get_home_dir): Try to make it work under
3818 * IPython/genutils.py (get_home_dir): Try to make it work under
3818 win9x also.
3819 win9x also.
3819
3820
3820 2002-03-20 Fernando Perez <fperez@colorado.edu>
3821 2002-03-20 Fernando Perez <fperez@colorado.edu>
3821
3822
3822 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3823 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3823 sys.displayhook untouched upon __init__.
3824 sys.displayhook untouched upon __init__.
3824
3825
3825 2002-03-19 Fernando Perez <fperez@colorado.edu>
3826 2002-03-19 Fernando Perez <fperez@colorado.edu>
3826
3827
3827 * Released 0.2.9 (for embedding bug, basically).
3828 * Released 0.2.9 (for embedding bug, basically).
3828
3829
3829 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3830 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3830 exceptions so that enclosing shell's state can be restored.
3831 exceptions so that enclosing shell's state can be restored.
3831
3832
3832 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3833 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3833 naming conventions in the .ipython/ dir.
3834 naming conventions in the .ipython/ dir.
3834
3835
3835 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3836 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3836 from delimiters list so filenames with - in them get expanded.
3837 from delimiters list so filenames with - in them get expanded.
3837
3838
3838 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3839 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3839 sys.displayhook not being properly restored after an embedded call.
3840 sys.displayhook not being properly restored after an embedded call.
3840
3841
3841 2002-03-18 Fernando Perez <fperez@colorado.edu>
3842 2002-03-18 Fernando Perez <fperez@colorado.edu>
3842
3843
3843 * Released 0.2.8
3844 * Released 0.2.8
3844
3845
3845 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3846 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3846 some files weren't being included in a -upgrade.
3847 some files weren't being included in a -upgrade.
3847 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3848 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3848 on' so that the first tab completes.
3849 on' so that the first tab completes.
3849 (InteractiveShell.handle_magic): fixed bug with spaces around
3850 (InteractiveShell.handle_magic): fixed bug with spaces around
3850 quotes breaking many magic commands.
3851 quotes breaking many magic commands.
3851
3852
3852 * setup.py: added note about ignoring the syntax error messages at
3853 * setup.py: added note about ignoring the syntax error messages at
3853 installation.
3854 installation.
3854
3855
3855 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3856 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3856 streamlining the gnuplot interface, now there's only one magic @gp.
3857 streamlining the gnuplot interface, now there's only one magic @gp.
3857
3858
3858 2002-03-17 Fernando Perez <fperez@colorado.edu>
3859 2002-03-17 Fernando Perez <fperez@colorado.edu>
3859
3860
3860 * IPython/UserConfig/magic_gnuplot.py: new name for the
3861 * IPython/UserConfig/magic_gnuplot.py: new name for the
3861 example-magic_pm.py file. Much enhanced system, now with a shell
3862 example-magic_pm.py file. Much enhanced system, now with a shell
3862 for communicating directly with gnuplot, one command at a time.
3863 for communicating directly with gnuplot, one command at a time.
3863
3864
3864 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3865 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3865 setting __name__=='__main__'.
3866 setting __name__=='__main__'.
3866
3867
3867 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3868 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3868 mini-shell for accessing gnuplot from inside ipython. Should
3869 mini-shell for accessing gnuplot from inside ipython. Should
3869 extend it later for grace access too. Inspired by Arnd's
3870 extend it later for grace access too. Inspired by Arnd's
3870 suggestion.
3871 suggestion.
3871
3872
3872 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3873 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3873 calling magic functions with () in their arguments. Thanks to Arnd
3874 calling magic functions with () in their arguments. Thanks to Arnd
3874 Baecker for pointing this to me.
3875 Baecker for pointing this to me.
3875
3876
3876 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3877 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3877 infinitely for integer or complex arrays (only worked with floats).
3878 infinitely for integer or complex arrays (only worked with floats).
3878
3879
3879 2002-03-16 Fernando Perez <fperez@colorado.edu>
3880 2002-03-16 Fernando Perez <fperez@colorado.edu>
3880
3881
3881 * setup.py: Merged setup and setup_windows into a single script
3882 * setup.py: Merged setup and setup_windows into a single script
3882 which properly handles things for windows users.
3883 which properly handles things for windows users.
3883
3884
3884 2002-03-15 Fernando Perez <fperez@colorado.edu>
3885 2002-03-15 Fernando Perez <fperez@colorado.edu>
3885
3886
3886 * Big change to the manual: now the magics are all automatically
3887 * Big change to the manual: now the magics are all automatically
3887 documented. This information is generated from their docstrings
3888 documented. This information is generated from their docstrings
3888 and put in a latex file included by the manual lyx file. This way
3889 and put in a latex file included by the manual lyx file. This way
3889 we get always up to date information for the magics. The manual
3890 we get always up to date information for the magics. The manual
3890 now also has proper version information, also auto-synced.
3891 now also has proper version information, also auto-synced.
3891
3892
3892 For this to work, an undocumented --magic_docstrings option was added.
3893 For this to work, an undocumented --magic_docstrings option was added.
3893
3894
3894 2002-03-13 Fernando Perez <fperez@colorado.edu>
3895 2002-03-13 Fernando Perez <fperez@colorado.edu>
3895
3896
3896 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3897 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3897 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3898 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3898
3899
3899 2002-03-12 Fernando Perez <fperez@colorado.edu>
3900 2002-03-12 Fernando Perez <fperez@colorado.edu>
3900
3901
3901 * IPython/ultraTB.py (TermColors): changed color escapes again to
3902 * IPython/ultraTB.py (TermColors): changed color escapes again to
3902 fix the (old, reintroduced) line-wrapping bug. Basically, if
3903 fix the (old, reintroduced) line-wrapping bug. Basically, if
3903 \001..\002 aren't given in the color escapes, lines get wrapped
3904 \001..\002 aren't given in the color escapes, lines get wrapped
3904 weirdly. But giving those screws up old xterms and emacs terms. So
3905 weirdly. But giving those screws up old xterms and emacs terms. So
3905 I added some logic for emacs terms to be ok, but I can't identify old
3906 I added some logic for emacs terms to be ok, but I can't identify old
3906 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3907 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3907
3908
3908 2002-03-10 Fernando Perez <fperez@colorado.edu>
3909 2002-03-10 Fernando Perez <fperez@colorado.edu>
3909
3910
3910 * IPython/usage.py (__doc__): Various documentation cleanups and
3911 * IPython/usage.py (__doc__): Various documentation cleanups and
3911 updates, both in usage docstrings and in the manual.
3912 updates, both in usage docstrings and in the manual.
3912
3913
3913 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3914 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3914 handling of caching. Set minimum acceptabe value for having a
3915 handling of caching. Set minimum acceptabe value for having a
3915 cache at 20 values.
3916 cache at 20 values.
3916
3917
3917 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3918 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3918 install_first_time function to a method, renamed it and added an
3919 install_first_time function to a method, renamed it and added an
3919 'upgrade' mode. Now people can update their config directory with
3920 'upgrade' mode. Now people can update their config directory with
3920 a simple command line switch (-upgrade, also new).
3921 a simple command line switch (-upgrade, also new).
3921
3922
3922 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3923 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3923 @file (convenient for automagic users under Python >= 2.2).
3924 @file (convenient for automagic users under Python >= 2.2).
3924 Removed @files (it seemed more like a plural than an abbrev. of
3925 Removed @files (it seemed more like a plural than an abbrev. of
3925 'file show').
3926 'file show').
3926
3927
3927 * IPython/iplib.py (install_first_time): Fixed crash if there were
3928 * IPython/iplib.py (install_first_time): Fixed crash if there were
3928 backup files ('~') in .ipython/ install directory.
3929 backup files ('~') in .ipython/ install directory.
3929
3930
3930 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3931 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3931 system. Things look fine, but these changes are fairly
3932 system. Things look fine, but these changes are fairly
3932 intrusive. Test them for a few days.
3933 intrusive. Test them for a few days.
3933
3934
3934 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3935 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3935 the prompts system. Now all in/out prompt strings are user
3936 the prompts system. Now all in/out prompt strings are user
3936 controllable. This is particularly useful for embedding, as one
3937 controllable. This is particularly useful for embedding, as one
3937 can tag embedded instances with particular prompts.
3938 can tag embedded instances with particular prompts.
3938
3939
3939 Also removed global use of sys.ps1/2, which now allows nested
3940 Also removed global use of sys.ps1/2, which now allows nested
3940 embeddings without any problems. Added command-line options for
3941 embeddings without any problems. Added command-line options for
3941 the prompt strings.
3942 the prompt strings.
3942
3943
3943 2002-03-08 Fernando Perez <fperez@colorado.edu>
3944 2002-03-08 Fernando Perez <fperez@colorado.edu>
3944
3945
3945 * IPython/UserConfig/example-embed-short.py (ipshell): added
3946 * IPython/UserConfig/example-embed-short.py (ipshell): added
3946 example file with the bare minimum code for embedding.
3947 example file with the bare minimum code for embedding.
3947
3948
3948 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3949 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3949 functionality for the embeddable shell to be activated/deactivated
3950 functionality for the embeddable shell to be activated/deactivated
3950 either globally or at each call.
3951 either globally or at each call.
3951
3952
3952 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3953 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3953 rewriting the prompt with '--->' for auto-inputs with proper
3954 rewriting the prompt with '--->' for auto-inputs with proper
3954 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3955 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3955 this is handled by the prompts class itself, as it should.
3956 this is handled by the prompts class itself, as it should.
3956
3957
3957 2002-03-05 Fernando Perez <fperez@colorado.edu>
3958 2002-03-05 Fernando Perez <fperez@colorado.edu>
3958
3959
3959 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3960 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3960 @logstart to avoid name clashes with the math log function.
3961 @logstart to avoid name clashes with the math log function.
3961
3962
3962 * Big updates to X/Emacs section of the manual.
3963 * Big updates to X/Emacs section of the manual.
3963
3964
3964 * Removed ipython_emacs. Milan explained to me how to pass
3965 * Removed ipython_emacs. Milan explained to me how to pass
3965 arguments to ipython through Emacs. Some day I'm going to end up
3966 arguments to ipython through Emacs. Some day I'm going to end up
3966 learning some lisp...
3967 learning some lisp...
3967
3968
3968 2002-03-04 Fernando Perez <fperez@colorado.edu>
3969 2002-03-04 Fernando Perez <fperez@colorado.edu>
3969
3970
3970 * IPython/ipython_emacs: Created script to be used as the
3971 * IPython/ipython_emacs: Created script to be used as the
3971 py-python-command Emacs variable so we can pass IPython
3972 py-python-command Emacs variable so we can pass IPython
3972 parameters. I can't figure out how to tell Emacs directly to pass
3973 parameters. I can't figure out how to tell Emacs directly to pass
3973 parameters to IPython, so a dummy shell script will do it.
3974 parameters to IPython, so a dummy shell script will do it.
3974
3975
3975 Other enhancements made for things to work better under Emacs'
3976 Other enhancements made for things to work better under Emacs'
3976 various types of terminals. Many thanks to Milan Zamazal
3977 various types of terminals. Many thanks to Milan Zamazal
3977 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3978 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3978
3979
3979 2002-03-01 Fernando Perez <fperez@colorado.edu>
3980 2002-03-01 Fernando Perez <fperez@colorado.edu>
3980
3981
3981 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3982 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3982 that loading of readline is now optional. This gives better
3983 that loading of readline is now optional. This gives better
3983 control to emacs users.
3984 control to emacs users.
3984
3985
3985 * IPython/ultraTB.py (__date__): Modified color escape sequences
3986 * IPython/ultraTB.py (__date__): Modified color escape sequences
3986 and now things work fine under xterm and in Emacs' term buffers
3987 and now things work fine under xterm and in Emacs' term buffers
3987 (though not shell ones). Well, in emacs you get colors, but all
3988 (though not shell ones). Well, in emacs you get colors, but all
3988 seem to be 'light' colors (no difference between dark and light
3989 seem to be 'light' colors (no difference between dark and light
3989 ones). But the garbage chars are gone, and also in xterms. It
3990 ones). But the garbage chars are gone, and also in xterms. It
3990 seems that now I'm using 'cleaner' ansi sequences.
3991 seems that now I'm using 'cleaner' ansi sequences.
3991
3992
3992 2002-02-21 Fernando Perez <fperez@colorado.edu>
3993 2002-02-21 Fernando Perez <fperez@colorado.edu>
3993
3994
3994 * Released 0.2.7 (mainly to publish the scoping fix).
3995 * Released 0.2.7 (mainly to publish the scoping fix).
3995
3996
3996 * IPython/Logger.py (Logger.logstate): added. A corresponding
3997 * IPython/Logger.py (Logger.logstate): added. A corresponding
3997 @logstate magic was created.
3998 @logstate magic was created.
3998
3999
3999 * IPython/Magic.py: fixed nested scoping problem under Python
4000 * IPython/Magic.py: fixed nested scoping problem under Python
4000 2.1.x (automagic wasn't working).
4001 2.1.x (automagic wasn't working).
4001
4002
4002 2002-02-20 Fernando Perez <fperez@colorado.edu>
4003 2002-02-20 Fernando Perez <fperez@colorado.edu>
4003
4004
4004 * Released 0.2.6.
4005 * Released 0.2.6.
4005
4006
4006 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
4007 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
4007 option so that logs can come out without any headers at all.
4008 option so that logs can come out without any headers at all.
4008
4009
4009 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
4010 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
4010 SciPy.
4011 SciPy.
4011
4012
4012 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
4013 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
4013 that embedded IPython calls don't require vars() to be explicitly
4014 that embedded IPython calls don't require vars() to be explicitly
4014 passed. Now they are extracted from the caller's frame (code
4015 passed. Now they are extracted from the caller's frame (code
4015 snatched from Eric Jones' weave). Added better documentation to
4016 snatched from Eric Jones' weave). Added better documentation to
4016 the section on embedding and the example file.
4017 the section on embedding and the example file.
4017
4018
4018 * IPython/genutils.py (page): Changed so that under emacs, it just
4019 * IPython/genutils.py (page): Changed so that under emacs, it just
4019 prints the string. You can then page up and down in the emacs
4020 prints the string. You can then page up and down in the emacs
4020 buffer itself. This is how the builtin help() works.
4021 buffer itself. This is how the builtin help() works.
4021
4022
4022 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
4023 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
4023 macro scoping: macros need to be executed in the user's namespace
4024 macro scoping: macros need to be executed in the user's namespace
4024 to work as if they had been typed by the user.
4025 to work as if they had been typed by the user.
4025
4026
4026 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
4027 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
4027 execute automatically (no need to type 'exec...'). They then
4028 execute automatically (no need to type 'exec...'). They then
4028 behave like 'true macros'. The printing system was also modified
4029 behave like 'true macros'. The printing system was also modified
4029 for this to work.
4030 for this to work.
4030
4031
4031 2002-02-19 Fernando Perez <fperez@colorado.edu>
4032 2002-02-19 Fernando Perez <fperez@colorado.edu>
4032
4033
4033 * IPython/genutils.py (page_file): new function for paging files
4034 * IPython/genutils.py (page_file): new function for paging files
4034 in an OS-independent way. Also necessary for file viewing to work
4035 in an OS-independent way. Also necessary for file viewing to work
4035 well inside Emacs buffers.
4036 well inside Emacs buffers.
4036 (page): Added checks for being in an emacs buffer.
4037 (page): Added checks for being in an emacs buffer.
4037 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
4038 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
4038 same bug in iplib.
4039 same bug in iplib.
4039
4040
4040 2002-02-18 Fernando Perez <fperez@colorado.edu>
4041 2002-02-18 Fernando Perez <fperez@colorado.edu>
4041
4042
4042 * IPython/iplib.py (InteractiveShell.init_readline): modified use
4043 * IPython/iplib.py (InteractiveShell.init_readline): modified use
4043 of readline so that IPython can work inside an Emacs buffer.
4044 of readline so that IPython can work inside an Emacs buffer.
4044
4045
4045 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
4046 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
4046 method signatures (they weren't really bugs, but it looks cleaner
4047 method signatures (they weren't really bugs, but it looks cleaner
4047 and keeps PyChecker happy).
4048 and keeps PyChecker happy).
4048
4049
4049 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
4050 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
4050 for implementing various user-defined hooks. Currently only
4051 for implementing various user-defined hooks. Currently only
4051 display is done.
4052 display is done.
4052
4053
4053 * IPython/Prompts.py (CachedOutput._display): changed display
4054 * IPython/Prompts.py (CachedOutput._display): changed display
4054 functions so that they can be dynamically changed by users easily.
4055 functions so that they can be dynamically changed by users easily.
4055
4056
4056 * IPython/Extensions/numeric_formats.py (num_display): added an
4057 * IPython/Extensions/numeric_formats.py (num_display): added an
4057 extension for printing NumPy arrays in flexible manners. It
4058 extension for printing NumPy arrays in flexible manners. It
4058 doesn't do anything yet, but all the structure is in
4059 doesn't do anything yet, but all the structure is in
4059 place. Ultimately the plan is to implement output format control
4060 place. Ultimately the plan is to implement output format control
4060 like in Octave.
4061 like in Octave.
4061
4062
4062 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
4063 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
4063 methods are found at run-time by all the automatic machinery.
4064 methods are found at run-time by all the automatic machinery.
4064
4065
4065 2002-02-17 Fernando Perez <fperez@colorado.edu>
4066 2002-02-17 Fernando Perez <fperez@colorado.edu>
4066
4067
4067 * setup_Windows.py (make_shortcut): documented. Cleaned up the
4068 * setup_Windows.py (make_shortcut): documented. Cleaned up the
4068 whole file a little.
4069 whole file a little.
4069
4070
4070 * ToDo: closed this document. Now there's a new_design.lyx
4071 * ToDo: closed this document. Now there's a new_design.lyx
4071 document for all new ideas. Added making a pdf of it for the
4072 document for all new ideas. Added making a pdf of it for the
4072 end-user distro.
4073 end-user distro.
4073
4074
4074 * IPython/Logger.py (Logger.switch_log): Created this to replace
4075 * IPython/Logger.py (Logger.switch_log): Created this to replace
4075 logon() and logoff(). It also fixes a nasty crash reported by
4076 logon() and logoff(). It also fixes a nasty crash reported by
4076 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
4077 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
4077
4078
4078 * IPython/iplib.py (complete): got auto-completion to work with
4079 * IPython/iplib.py (complete): got auto-completion to work with
4079 automagic (I had wanted this for a long time).
4080 automagic (I had wanted this for a long time).
4080
4081
4081 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
4082 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
4082 to @file, since file() is now a builtin and clashes with automagic
4083 to @file, since file() is now a builtin and clashes with automagic
4083 for @file.
4084 for @file.
4084
4085
4085 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
4086 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
4086 of this was previously in iplib, which had grown to more than 2000
4087 of this was previously in iplib, which had grown to more than 2000
4087 lines, way too long. No new functionality, but it makes managing
4088 lines, way too long. No new functionality, but it makes managing
4088 the code a bit easier.
4089 the code a bit easier.
4089
4090
4090 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
4091 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
4091 information to crash reports.
4092 information to crash reports.
4092
4093
4093 2002-02-12 Fernando Perez <fperez@colorado.edu>
4094 2002-02-12 Fernando Perez <fperez@colorado.edu>
4094
4095
4095 * Released 0.2.5.
4096 * Released 0.2.5.
4096
4097
4097 2002-02-11 Fernando Perez <fperez@colorado.edu>
4098 2002-02-11 Fernando Perez <fperez@colorado.edu>
4098
4099
4099 * Wrote a relatively complete Windows installer. It puts
4100 * Wrote a relatively complete Windows installer. It puts
4100 everything in place, creates Start Menu entries and fixes the
4101 everything in place, creates Start Menu entries and fixes the
4101 color issues. Nothing fancy, but it works.
4102 color issues. Nothing fancy, but it works.
4102
4103
4103 2002-02-10 Fernando Perez <fperez@colorado.edu>
4104 2002-02-10 Fernando Perez <fperez@colorado.edu>
4104
4105
4105 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
4106 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
4106 os.path.expanduser() call so that we can type @run ~/myfile.py and
4107 os.path.expanduser() call so that we can type @run ~/myfile.py and
4107 have thigs work as expected.
4108 have thigs work as expected.
4108
4109
4109 * IPython/genutils.py (page): fixed exception handling so things
4110 * IPython/genutils.py (page): fixed exception handling so things
4110 work both in Unix and Windows correctly. Quitting a pager triggers
4111 work both in Unix and Windows correctly. Quitting a pager triggers
4111 an IOError/broken pipe in Unix, and in windows not finding a pager
4112 an IOError/broken pipe in Unix, and in windows not finding a pager
4112 is also an IOError, so I had to actually look at the return value
4113 is also an IOError, so I had to actually look at the return value
4113 of the exception, not just the exception itself. Should be ok now.
4114 of the exception, not just the exception itself. Should be ok now.
4114
4115
4115 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
4116 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
4116 modified to allow case-insensitive color scheme changes.
4117 modified to allow case-insensitive color scheme changes.
4117
4118
4118 2002-02-09 Fernando Perez <fperez@colorado.edu>
4119 2002-02-09 Fernando Perez <fperez@colorado.edu>
4119
4120
4120 * IPython/genutils.py (native_line_ends): new function to leave
4121 * IPython/genutils.py (native_line_ends): new function to leave
4121 user config files with os-native line-endings.
4122 user config files with os-native line-endings.
4122
4123
4123 * README and manual updates.
4124 * README and manual updates.
4124
4125
4125 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
4126 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
4126 instead of StringType to catch Unicode strings.
4127 instead of StringType to catch Unicode strings.
4127
4128
4128 * IPython/genutils.py (filefind): fixed bug for paths with
4129 * IPython/genutils.py (filefind): fixed bug for paths with
4129 embedded spaces (very common in Windows).
4130 embedded spaces (very common in Windows).
4130
4131
4131 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
4132 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
4132 files under Windows, so that they get automatically associated
4133 files under Windows, so that they get automatically associated
4133 with a text editor. Windows makes it a pain to handle
4134 with a text editor. Windows makes it a pain to handle
4134 extension-less files.
4135 extension-less files.
4135
4136
4136 * IPython/iplib.py (InteractiveShell.init_readline): Made the
4137 * IPython/iplib.py (InteractiveShell.init_readline): Made the
4137 warning about readline only occur for Posix. In Windows there's no
4138 warning about readline only occur for Posix. In Windows there's no
4138 way to get readline, so why bother with the warning.
4139 way to get readline, so why bother with the warning.
4139
4140
4140 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
4141 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
4141 for __str__ instead of dir(self), since dir() changed in 2.2.
4142 for __str__ instead of dir(self), since dir() changed in 2.2.
4142
4143
4143 * Ported to Windows! Tested on XP, I suspect it should work fine
4144 * Ported to Windows! Tested on XP, I suspect it should work fine
4144 on NT/2000, but I don't think it will work on 98 et al. That
4145 on NT/2000, but I don't think it will work on 98 et al. That
4145 series of Windows is such a piece of junk anyway that I won't try
4146 series of Windows is such a piece of junk anyway that I won't try
4146 porting it there. The XP port was straightforward, showed a few
4147 porting it there. The XP port was straightforward, showed a few
4147 bugs here and there (fixed all), in particular some string
4148 bugs here and there (fixed all), in particular some string
4148 handling stuff which required considering Unicode strings (which
4149 handling stuff which required considering Unicode strings (which
4149 Windows uses). This is good, but hasn't been too tested :) No
4150 Windows uses). This is good, but hasn't been too tested :) No
4150 fancy installer yet, I'll put a note in the manual so people at
4151 fancy installer yet, I'll put a note in the manual so people at
4151 least make manually a shortcut.
4152 least make manually a shortcut.
4152
4153
4153 * IPython/iplib.py (Magic.magic_colors): Unified the color options
4154 * IPython/iplib.py (Magic.magic_colors): Unified the color options
4154 into a single one, "colors". This now controls both prompt and
4155 into a single one, "colors". This now controls both prompt and
4155 exception color schemes, and can be changed both at startup
4156 exception color schemes, and can be changed both at startup
4156 (either via command-line switches or via ipythonrc files) and at
4157 (either via command-line switches or via ipythonrc files) and at
4157 runtime, with @colors.
4158 runtime, with @colors.
4158 (Magic.magic_run): renamed @prun to @run and removed the old
4159 (Magic.magic_run): renamed @prun to @run and removed the old
4159 @run. The two were too similar to warrant keeping both.
4160 @run. The two were too similar to warrant keeping both.
4160
4161
4161 2002-02-03 Fernando Perez <fperez@colorado.edu>
4162 2002-02-03 Fernando Perez <fperez@colorado.edu>
4162
4163
4163 * IPython/iplib.py (install_first_time): Added comment on how to
4164 * IPython/iplib.py (install_first_time): Added comment on how to
4164 configure the color options for first-time users. Put a <return>
4165 configure the color options for first-time users. Put a <return>
4165 request at the end so that small-terminal users get a chance to
4166 request at the end so that small-terminal users get a chance to
4166 read the startup info.
4167 read the startup info.
4167
4168
4168 2002-01-23 Fernando Perez <fperez@colorado.edu>
4169 2002-01-23 Fernando Perez <fperez@colorado.edu>
4169
4170
4170 * IPython/iplib.py (CachedOutput.update): Changed output memory
4171 * IPython/iplib.py (CachedOutput.update): Changed output memory
4171 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
4172 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
4172 input history we still use _i. Did this b/c these variable are
4173 input history we still use _i. Did this b/c these variable are
4173 very commonly used in interactive work, so the less we need to
4174 very commonly used in interactive work, so the less we need to
4174 type the better off we are.
4175 type the better off we are.
4175 (Magic.magic_prun): updated @prun to better handle the namespaces
4176 (Magic.magic_prun): updated @prun to better handle the namespaces
4176 the file will run in, including a fix for __name__ not being set
4177 the file will run in, including a fix for __name__ not being set
4177 before.
4178 before.
4178
4179
4179 2002-01-20 Fernando Perez <fperez@colorado.edu>
4180 2002-01-20 Fernando Perez <fperez@colorado.edu>
4180
4181
4181 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
4182 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
4182 extra garbage for Python 2.2. Need to look more carefully into
4183 extra garbage for Python 2.2. Need to look more carefully into
4183 this later.
4184 this later.
4184
4185
4185 2002-01-19 Fernando Perez <fperez@colorado.edu>
4186 2002-01-19 Fernando Perez <fperez@colorado.edu>
4186
4187
4187 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
4188 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
4188 display SyntaxError exceptions properly formatted when they occur
4189 display SyntaxError exceptions properly formatted when they occur
4189 (they can be triggered by imported code).
4190 (they can be triggered by imported code).
4190
4191
4191 2002-01-18 Fernando Perez <fperez@colorado.edu>
4192 2002-01-18 Fernando Perez <fperez@colorado.edu>
4192
4193
4193 * IPython/iplib.py (InteractiveShell.safe_execfile): now
4194 * IPython/iplib.py (InteractiveShell.safe_execfile): now
4194 SyntaxError exceptions are reported nicely formatted, instead of
4195 SyntaxError exceptions are reported nicely formatted, instead of
4195 spitting out only offset information as before.
4196 spitting out only offset information as before.
4196 (Magic.magic_prun): Added the @prun function for executing
4197 (Magic.magic_prun): Added the @prun function for executing
4197 programs with command line args inside IPython.
4198 programs with command line args inside IPython.
4198
4199
4199 2002-01-16 Fernando Perez <fperez@colorado.edu>
4200 2002-01-16 Fernando Perez <fperez@colorado.edu>
4200
4201
4201 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
4202 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
4202 to *not* include the last item given in a range. This brings their
4203 to *not* include the last item given in a range. This brings their
4203 behavior in line with Python's slicing:
4204 behavior in line with Python's slicing:
4204 a[n1:n2] -> a[n1]...a[n2-1]
4205 a[n1:n2] -> a[n1]...a[n2-1]
4205 It may be a bit less convenient, but I prefer to stick to Python's
4206 It may be a bit less convenient, but I prefer to stick to Python's
4206 conventions *everywhere*, so users never have to wonder.
4207 conventions *everywhere*, so users never have to wonder.
4207 (Magic.magic_macro): Added @macro function to ease the creation of
4208 (Magic.magic_macro): Added @macro function to ease the creation of
4208 macros.
4209 macros.
4209
4210
4210 2002-01-05 Fernando Perez <fperez@colorado.edu>
4211 2002-01-05 Fernando Perez <fperez@colorado.edu>
4211
4212
4212 * Released 0.2.4.
4213 * Released 0.2.4.
4213
4214
4214 * IPython/iplib.py (Magic.magic_pdef):
4215 * IPython/iplib.py (Magic.magic_pdef):
4215 (InteractiveShell.safe_execfile): report magic lines and error
4216 (InteractiveShell.safe_execfile): report magic lines and error
4216 lines without line numbers so one can easily copy/paste them for
4217 lines without line numbers so one can easily copy/paste them for
4217 re-execution.
4218 re-execution.
4218
4219
4219 * Updated manual with recent changes.
4220 * Updated manual with recent changes.
4220
4221
4221 * IPython/iplib.py (Magic.magic_oinfo): added constructor
4222 * IPython/iplib.py (Magic.magic_oinfo): added constructor
4222 docstring printing when class? is called. Very handy for knowing
4223 docstring printing when class? is called. Very handy for knowing
4223 how to create class instances (as long as __init__ is well
4224 how to create class instances (as long as __init__ is well
4224 documented, of course :)
4225 documented, of course :)
4225 (Magic.magic_doc): print both class and constructor docstrings.
4226 (Magic.magic_doc): print both class and constructor docstrings.
4226 (Magic.magic_pdef): give constructor info if passed a class and
4227 (Magic.magic_pdef): give constructor info if passed a class and
4227 __call__ info for callable object instances.
4228 __call__ info for callable object instances.
4228
4229
4229 2002-01-04 Fernando Perez <fperez@colorado.edu>
4230 2002-01-04 Fernando Perez <fperez@colorado.edu>
4230
4231
4231 * Made deep_reload() off by default. It doesn't always work
4232 * Made deep_reload() off by default. It doesn't always work
4232 exactly as intended, so it's probably safer to have it off. It's
4233 exactly as intended, so it's probably safer to have it off. It's
4233 still available as dreload() anyway, so nothing is lost.
4234 still available as dreload() anyway, so nothing is lost.
4234
4235
4235 2002-01-02 Fernando Perez <fperez@colorado.edu>
4236 2002-01-02 Fernando Perez <fperez@colorado.edu>
4236
4237
4237 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4238 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4238 so I wanted an updated release).
4239 so I wanted an updated release).
4239
4240
4240 2001-12-27 Fernando Perez <fperez@colorado.edu>
4241 2001-12-27 Fernando Perez <fperez@colorado.edu>
4241
4242
4242 * IPython/iplib.py (InteractiveShell.interact): Added the original
4243 * IPython/iplib.py (InteractiveShell.interact): Added the original
4243 code from 'code.py' for this module in order to change the
4244 code from 'code.py' for this module in order to change the
4244 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4245 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4245 the history cache would break when the user hit Ctrl-C, and
4246 the history cache would break when the user hit Ctrl-C, and
4246 interact() offers no way to add any hooks to it.
4247 interact() offers no way to add any hooks to it.
4247
4248
4248 2001-12-23 Fernando Perez <fperez@colorado.edu>
4249 2001-12-23 Fernando Perez <fperez@colorado.edu>
4249
4250
4250 * setup.py: added check for 'MANIFEST' before trying to remove
4251 * setup.py: added check for 'MANIFEST' before trying to remove
4251 it. Thanks to Sean Reifschneider.
4252 it. Thanks to Sean Reifschneider.
4252
4253
4253 2001-12-22 Fernando Perez <fperez@colorado.edu>
4254 2001-12-22 Fernando Perez <fperez@colorado.edu>
4254
4255
4255 * Released 0.2.2.
4256 * Released 0.2.2.
4256
4257
4257 * Finished (reasonably) writing the manual. Later will add the
4258 * Finished (reasonably) writing the manual. Later will add the
4258 python-standard navigation stylesheets, but for the time being
4259 python-standard navigation stylesheets, but for the time being
4259 it's fairly complete. Distribution will include html and pdf
4260 it's fairly complete. Distribution will include html and pdf
4260 versions.
4261 versions.
4261
4262
4262 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4263 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4263 (MayaVi author).
4264 (MayaVi author).
4264
4265
4265 2001-12-21 Fernando Perez <fperez@colorado.edu>
4266 2001-12-21 Fernando Perez <fperez@colorado.edu>
4266
4267
4267 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4268 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4268 good public release, I think (with the manual and the distutils
4269 good public release, I think (with the manual and the distutils
4269 installer). The manual can use some work, but that can go
4270 installer). The manual can use some work, but that can go
4270 slowly. Otherwise I think it's quite nice for end users. Next
4271 slowly. Otherwise I think it's quite nice for end users. Next
4271 summer, rewrite the guts of it...
4272 summer, rewrite the guts of it...
4272
4273
4273 * Changed format of ipythonrc files to use whitespace as the
4274 * Changed format of ipythonrc files to use whitespace as the
4274 separator instead of an explicit '='. Cleaner.
4275 separator instead of an explicit '='. Cleaner.
4275
4276
4276 2001-12-20 Fernando Perez <fperez@colorado.edu>
4277 2001-12-20 Fernando Perez <fperez@colorado.edu>
4277
4278
4278 * Started a manual in LyX. For now it's just a quick merge of the
4279 * Started a manual in LyX. For now it's just a quick merge of the
4279 various internal docstrings and READMEs. Later it may grow into a
4280 various internal docstrings and READMEs. Later it may grow into a
4280 nice, full-blown manual.
4281 nice, full-blown manual.
4281
4282
4282 * Set up a distutils based installer. Installation should now be
4283 * Set up a distutils based installer. Installation should now be
4283 trivially simple for end-users.
4284 trivially simple for end-users.
4284
4285
4285 2001-12-11 Fernando Perez <fperez@colorado.edu>
4286 2001-12-11 Fernando Perez <fperez@colorado.edu>
4286
4287
4287 * Released 0.2.0. First public release, announced it at
4288 * Released 0.2.0. First public release, announced it at
4288 comp.lang.python. From now on, just bugfixes...
4289 comp.lang.python. From now on, just bugfixes...
4289
4290
4290 * Went through all the files, set copyright/license notices and
4291 * Went through all the files, set copyright/license notices and
4291 cleaned up things. Ready for release.
4292 cleaned up things. Ready for release.
4292
4293
4293 2001-12-10 Fernando Perez <fperez@colorado.edu>
4294 2001-12-10 Fernando Perez <fperez@colorado.edu>
4294
4295
4295 * Changed the first-time installer not to use tarfiles. It's more
4296 * Changed the first-time installer not to use tarfiles. It's more
4296 robust now and less unix-dependent. Also makes it easier for
4297 robust now and less unix-dependent. Also makes it easier for
4297 people to later upgrade versions.
4298 people to later upgrade versions.
4298
4299
4299 * Changed @exit to @abort to reflect the fact that it's pretty
4300 * Changed @exit to @abort to reflect the fact that it's pretty
4300 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4301 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4301 becomes significant only when IPyhton is embedded: in that case,
4302 becomes significant only when IPyhton is embedded: in that case,
4302 C-D closes IPython only, but @abort kills the enclosing program
4303 C-D closes IPython only, but @abort kills the enclosing program
4303 too (unless it had called IPython inside a try catching
4304 too (unless it had called IPython inside a try catching
4304 SystemExit).
4305 SystemExit).
4305
4306
4306 * Created Shell module which exposes the actuall IPython Shell
4307 * Created Shell module which exposes the actuall IPython Shell
4307 classes, currently the normal and the embeddable one. This at
4308 classes, currently the normal and the embeddable one. This at
4308 least offers a stable interface we won't need to change when
4309 least offers a stable interface we won't need to change when
4309 (later) the internals are rewritten. That rewrite will be confined
4310 (later) the internals are rewritten. That rewrite will be confined
4310 to iplib and ipmaker, but the Shell interface should remain as is.
4311 to iplib and ipmaker, but the Shell interface should remain as is.
4311
4312
4312 * Added embed module which offers an embeddable IPShell object,
4313 * Added embed module which offers an embeddable IPShell object,
4313 useful to fire up IPython *inside* a running program. Great for
4314 useful to fire up IPython *inside* a running program. Great for
4314 debugging or dynamical data analysis.
4315 debugging or dynamical data analysis.
4315
4316
4316 2001-12-08 Fernando Perez <fperez@colorado.edu>
4317 2001-12-08 Fernando Perez <fperez@colorado.edu>
4317
4318
4318 * Fixed small bug preventing seeing info from methods of defined
4319 * Fixed small bug preventing seeing info from methods of defined
4319 objects (incorrect namespace in _ofind()).
4320 objects (incorrect namespace in _ofind()).
4320
4321
4321 * Documentation cleanup. Moved the main usage docstrings to a
4322 * Documentation cleanup. Moved the main usage docstrings to a
4322 separate file, usage.py (cleaner to maintain, and hopefully in the
4323 separate file, usage.py (cleaner to maintain, and hopefully in the
4323 future some perlpod-like way of producing interactive, man and
4324 future some perlpod-like way of producing interactive, man and
4324 html docs out of it will be found).
4325 html docs out of it will be found).
4325
4326
4326 * Added @profile to see your profile at any time.
4327 * Added @profile to see your profile at any time.
4327
4328
4328 * Added @p as an alias for 'print'. It's especially convenient if
4329 * Added @p as an alias for 'print'. It's especially convenient if
4329 using automagic ('p x' prints x).
4330 using automagic ('p x' prints x).
4330
4331
4331 * Small cleanups and fixes after a pychecker run.
4332 * Small cleanups and fixes after a pychecker run.
4332
4333
4333 * Changed the @cd command to handle @cd - and @cd -<n> for
4334 * Changed the @cd command to handle @cd - and @cd -<n> for
4334 visiting any directory in _dh.
4335 visiting any directory in _dh.
4335
4336
4336 * Introduced _dh, a history of visited directories. @dhist prints
4337 * Introduced _dh, a history of visited directories. @dhist prints
4337 it out with numbers.
4338 it out with numbers.
4338
4339
4339 2001-12-07 Fernando Perez <fperez@colorado.edu>
4340 2001-12-07 Fernando Perez <fperez@colorado.edu>
4340
4341
4341 * Released 0.1.22
4342 * Released 0.1.22
4342
4343
4343 * Made initialization a bit more robust against invalid color
4344 * Made initialization a bit more robust against invalid color
4344 options in user input (exit, not traceback-crash).
4345 options in user input (exit, not traceback-crash).
4345
4346
4346 * Changed the bug crash reporter to write the report only in the
4347 * Changed the bug crash reporter to write the report only in the
4347 user's .ipython directory. That way IPython won't litter people's
4348 user's .ipython directory. That way IPython won't litter people's
4348 hard disks with crash files all over the place. Also print on
4349 hard disks with crash files all over the place. Also print on
4349 screen the necessary mail command.
4350 screen the necessary mail command.
4350
4351
4351 * With the new ultraTB, implemented LightBG color scheme for light
4352 * With the new ultraTB, implemented LightBG color scheme for light
4352 background terminals. A lot of people like white backgrounds, so I
4353 background terminals. A lot of people like white backgrounds, so I
4353 guess we should at least give them something readable.
4354 guess we should at least give them something readable.
4354
4355
4355 2001-12-06 Fernando Perez <fperez@colorado.edu>
4356 2001-12-06 Fernando Perez <fperez@colorado.edu>
4356
4357
4357 * Modified the structure of ultraTB. Now there's a proper class
4358 * Modified the structure of ultraTB. Now there's a proper class
4358 for tables of color schemes which allow adding schemes easily and
4359 for tables of color schemes which allow adding schemes easily and
4359 switching the active scheme without creating a new instance every
4360 switching the active scheme without creating a new instance every
4360 time (which was ridiculous). The syntax for creating new schemes
4361 time (which was ridiculous). The syntax for creating new schemes
4361 is also cleaner. I think ultraTB is finally done, with a clean
4362 is also cleaner. I think ultraTB is finally done, with a clean
4362 class structure. Names are also much cleaner (now there's proper
4363 class structure. Names are also much cleaner (now there's proper
4363 color tables, no need for every variable to also have 'color' in
4364 color tables, no need for every variable to also have 'color' in
4364 its name).
4365 its name).
4365
4366
4366 * Broke down genutils into separate files. Now genutils only
4367 * Broke down genutils into separate files. Now genutils only
4367 contains utility functions, and classes have been moved to their
4368 contains utility functions, and classes have been moved to their
4368 own files (they had enough independent functionality to warrant
4369 own files (they had enough independent functionality to warrant
4369 it): ConfigLoader, OutputTrap, Struct.
4370 it): ConfigLoader, OutputTrap, Struct.
4370
4371
4371 2001-12-05 Fernando Perez <fperez@colorado.edu>
4372 2001-12-05 Fernando Perez <fperez@colorado.edu>
4372
4373
4373 * IPython turns 21! Released version 0.1.21, as a candidate for
4374 * IPython turns 21! Released version 0.1.21, as a candidate for
4374 public consumption. If all goes well, release in a few days.
4375 public consumption. If all goes well, release in a few days.
4375
4376
4376 * Fixed path bug (files in Extensions/ directory wouldn't be found
4377 * Fixed path bug (files in Extensions/ directory wouldn't be found
4377 unless IPython/ was explicitly in sys.path).
4378 unless IPython/ was explicitly in sys.path).
4378
4379
4379 * Extended the FlexCompleter class as MagicCompleter to allow
4380 * Extended the FlexCompleter class as MagicCompleter to allow
4380 completion of @-starting lines.
4381 completion of @-starting lines.
4381
4382
4382 * Created __release__.py file as a central repository for release
4383 * Created __release__.py file as a central repository for release
4383 info that other files can read from.
4384 info that other files can read from.
4384
4385
4385 * Fixed small bug in logging: when logging was turned on in
4386 * Fixed small bug in logging: when logging was turned on in
4386 mid-session, old lines with special meanings (!@?) were being
4387 mid-session, old lines with special meanings (!@?) were being
4387 logged without the prepended comment, which is necessary since
4388 logged without the prepended comment, which is necessary since
4388 they are not truly valid python syntax. This should make session
4389 they are not truly valid python syntax. This should make session
4389 restores produce less errors.
4390 restores produce less errors.
4390
4391
4391 * The namespace cleanup forced me to make a FlexCompleter class
4392 * The namespace cleanup forced me to make a FlexCompleter class
4392 which is nothing but a ripoff of rlcompleter, but with selectable
4393 which is nothing but a ripoff of rlcompleter, but with selectable
4393 namespace (rlcompleter only works in __main__.__dict__). I'll try
4394 namespace (rlcompleter only works in __main__.__dict__). I'll try
4394 to submit a note to the authors to see if this change can be
4395 to submit a note to the authors to see if this change can be
4395 incorporated in future rlcompleter releases (Dec.6: done)
4396 incorporated in future rlcompleter releases (Dec.6: done)
4396
4397
4397 * More fixes to namespace handling. It was a mess! Now all
4398 * More fixes to namespace handling. It was a mess! Now all
4398 explicit references to __main__.__dict__ are gone (except when
4399 explicit references to __main__.__dict__ are gone (except when
4399 really needed) and everything is handled through the namespace
4400 really needed) and everything is handled through the namespace
4400 dicts in the IPython instance. We seem to be getting somewhere
4401 dicts in the IPython instance. We seem to be getting somewhere
4401 with this, finally...
4402 with this, finally...
4402
4403
4403 * Small documentation updates.
4404 * Small documentation updates.
4404
4405
4405 * Created the Extensions directory under IPython (with an
4406 * Created the Extensions directory under IPython (with an
4406 __init__.py). Put the PhysicalQ stuff there. This directory should
4407 __init__.py). Put the PhysicalQ stuff there. This directory should
4407 be used for all special-purpose extensions.
4408 be used for all special-purpose extensions.
4408
4409
4409 * File renaming:
4410 * File renaming:
4410 ipythonlib --> ipmaker
4411 ipythonlib --> ipmaker
4411 ipplib --> iplib
4412 ipplib --> iplib
4412 This makes a bit more sense in terms of what these files actually do.
4413 This makes a bit more sense in terms of what these files actually do.
4413
4414
4414 * Moved all the classes and functions in ipythonlib to ipplib, so
4415 * Moved all the classes and functions in ipythonlib to ipplib, so
4415 now ipythonlib only has make_IPython(). This will ease up its
4416 now ipythonlib only has make_IPython(). This will ease up its
4416 splitting in smaller functional chunks later.
4417 splitting in smaller functional chunks later.
4417
4418
4418 * Cleaned up (done, I think) output of @whos. Better column
4419 * Cleaned up (done, I think) output of @whos. Better column
4419 formatting, and now shows str(var) for as much as it can, which is
4420 formatting, and now shows str(var) for as much as it can, which is
4420 typically what one gets with a 'print var'.
4421 typically what one gets with a 'print var'.
4421
4422
4422 2001-12-04 Fernando Perez <fperez@colorado.edu>
4423 2001-12-04 Fernando Perez <fperez@colorado.edu>
4423
4424
4424 * Fixed namespace problems. Now builtin/IPyhton/user names get
4425 * Fixed namespace problems. Now builtin/IPyhton/user names get
4425 properly reported in their namespace. Internal namespace handling
4426 properly reported in their namespace. Internal namespace handling
4426 is finally getting decent (not perfect yet, but much better than
4427 is finally getting decent (not perfect yet, but much better than
4427 the ad-hoc mess we had).
4428 the ad-hoc mess we had).
4428
4429
4429 * Removed -exit option. If people just want to run a python
4430 * Removed -exit option. If people just want to run a python
4430 script, that's what the normal interpreter is for. Less
4431 script, that's what the normal interpreter is for. Less
4431 unnecessary options, less chances for bugs.
4432 unnecessary options, less chances for bugs.
4432
4433
4433 * Added a crash handler which generates a complete post-mortem if
4434 * Added a crash handler which generates a complete post-mortem if
4434 IPython crashes. This will help a lot in tracking bugs down the
4435 IPython crashes. This will help a lot in tracking bugs down the
4435 road.
4436 road.
4436
4437
4437 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4438 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4438 which were boud to functions being reassigned would bypass the
4439 which were boud to functions being reassigned would bypass the
4439 logger, breaking the sync of _il with the prompt counter. This
4440 logger, breaking the sync of _il with the prompt counter. This
4440 would then crash IPython later when a new line was logged.
4441 would then crash IPython later when a new line was logged.
4441
4442
4442 2001-12-02 Fernando Perez <fperez@colorado.edu>
4443 2001-12-02 Fernando Perez <fperez@colorado.edu>
4443
4444
4444 * Made IPython a package. This means people don't have to clutter
4445 * Made IPython a package. This means people don't have to clutter
4445 their sys.path with yet another directory. Changed the INSTALL
4446 their sys.path with yet another directory. Changed the INSTALL
4446 file accordingly.
4447 file accordingly.
4447
4448
4448 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4449 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4449 sorts its output (so @who shows it sorted) and @whos formats the
4450 sorts its output (so @who shows it sorted) and @whos formats the
4450 table according to the width of the first column. Nicer, easier to
4451 table according to the width of the first column. Nicer, easier to
4451 read. Todo: write a generic table_format() which takes a list of
4452 read. Todo: write a generic table_format() which takes a list of
4452 lists and prints it nicely formatted, with optional row/column
4453 lists and prints it nicely formatted, with optional row/column
4453 separators and proper padding and justification.
4454 separators and proper padding and justification.
4454
4455
4455 * Released 0.1.20
4456 * Released 0.1.20
4456
4457
4457 * Fixed bug in @log which would reverse the inputcache list (a
4458 * Fixed bug in @log which would reverse the inputcache list (a
4458 copy operation was missing).
4459 copy operation was missing).
4459
4460
4460 * Code cleanup. @config was changed to use page(). Better, since
4461 * Code cleanup. @config was changed to use page(). Better, since
4461 its output is always quite long.
4462 its output is always quite long.
4462
4463
4463 * Itpl is back as a dependency. I was having too many problems
4464 * Itpl is back as a dependency. I was having too many problems
4464 getting the parametric aliases to work reliably, and it's just
4465 getting the parametric aliases to work reliably, and it's just
4465 easier to code weird string operations with it than playing %()s
4466 easier to code weird string operations with it than playing %()s
4466 games. It's only ~6k, so I don't think it's too big a deal.
4467 games. It's only ~6k, so I don't think it's too big a deal.
4467
4468
4468 * Found (and fixed) a very nasty bug with history. !lines weren't
4469 * Found (and fixed) a very nasty bug with history. !lines weren't
4469 getting cached, and the out of sync caches would crash
4470 getting cached, and the out of sync caches would crash
4470 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4471 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4471 division of labor a bit better. Bug fixed, cleaner structure.
4472 division of labor a bit better. Bug fixed, cleaner structure.
4472
4473
4473 2001-12-01 Fernando Perez <fperez@colorado.edu>
4474 2001-12-01 Fernando Perez <fperez@colorado.edu>
4474
4475
4475 * Released 0.1.19
4476 * Released 0.1.19
4476
4477
4477 * Added option -n to @hist to prevent line number printing. Much
4478 * Added option -n to @hist to prevent line number printing. Much
4478 easier to copy/paste code this way.
4479 easier to copy/paste code this way.
4479
4480
4480 * Created global _il to hold the input list. Allows easy
4481 * Created global _il to hold the input list. Allows easy
4481 re-execution of blocks of code by slicing it (inspired by Janko's
4482 re-execution of blocks of code by slicing it (inspired by Janko's
4482 comment on 'macros').
4483 comment on 'macros').
4483
4484
4484 * Small fixes and doc updates.
4485 * Small fixes and doc updates.
4485
4486
4486 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4487 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4487 much too fragile with automagic. Handles properly multi-line
4488 much too fragile with automagic. Handles properly multi-line
4488 statements and takes parameters.
4489 statements and takes parameters.
4489
4490
4490 2001-11-30 Fernando Perez <fperez@colorado.edu>
4491 2001-11-30 Fernando Perez <fperez@colorado.edu>
4491
4492
4492 * Version 0.1.18 released.
4493 * Version 0.1.18 released.
4493
4494
4494 * Fixed nasty namespace bug in initial module imports.
4495 * Fixed nasty namespace bug in initial module imports.
4495
4496
4496 * Added copyright/license notes to all code files (except
4497 * Added copyright/license notes to all code files (except
4497 DPyGetOpt). For the time being, LGPL. That could change.
4498 DPyGetOpt). For the time being, LGPL. That could change.
4498
4499
4499 * Rewrote a much nicer README, updated INSTALL, cleaned up
4500 * Rewrote a much nicer README, updated INSTALL, cleaned up
4500 ipythonrc-* samples.
4501 ipythonrc-* samples.
4501
4502
4502 * Overall code/documentation cleanup. Basically ready for
4503 * Overall code/documentation cleanup. Basically ready for
4503 release. Only remaining thing: licence decision (LGPL?).
4504 release. Only remaining thing: licence decision (LGPL?).
4504
4505
4505 * Converted load_config to a class, ConfigLoader. Now recursion
4506 * Converted load_config to a class, ConfigLoader. Now recursion
4506 control is better organized. Doesn't include the same file twice.
4507 control is better organized. Doesn't include the same file twice.
4507
4508
4508 2001-11-29 Fernando Perez <fperez@colorado.edu>
4509 2001-11-29 Fernando Perez <fperez@colorado.edu>
4509
4510
4510 * Got input history working. Changed output history variables from
4511 * Got input history working. Changed output history variables from
4511 _p to _o so that _i is for input and _o for output. Just cleaner
4512 _p to _o so that _i is for input and _o for output. Just cleaner
4512 convention.
4513 convention.
4513
4514
4514 * Implemented parametric aliases. This pretty much allows the
4515 * Implemented parametric aliases. This pretty much allows the
4515 alias system to offer full-blown shell convenience, I think.
4516 alias system to offer full-blown shell convenience, I think.
4516
4517
4517 * Version 0.1.17 released, 0.1.18 opened.
4518 * Version 0.1.17 released, 0.1.18 opened.
4518
4519
4519 * dot_ipython/ipythonrc (alias): added documentation.
4520 * dot_ipython/ipythonrc (alias): added documentation.
4520 (xcolor): Fixed small bug (xcolors -> xcolor)
4521 (xcolor): Fixed small bug (xcolors -> xcolor)
4521
4522
4522 * Changed the alias system. Now alias is a magic command to define
4523 * Changed the alias system. Now alias is a magic command to define
4523 aliases just like the shell. Rationale: the builtin magics should
4524 aliases just like the shell. Rationale: the builtin magics should
4524 be there for things deeply connected to IPython's
4525 be there for things deeply connected to IPython's
4525 architecture. And this is a much lighter system for what I think
4526 architecture. And this is a much lighter system for what I think
4526 is the really important feature: allowing users to define quickly
4527 is the really important feature: allowing users to define quickly
4527 magics that will do shell things for them, so they can customize
4528 magics that will do shell things for them, so they can customize
4528 IPython easily to match their work habits. If someone is really
4529 IPython easily to match their work habits. If someone is really
4529 desperate to have another name for a builtin alias, they can
4530 desperate to have another name for a builtin alias, they can
4530 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4531 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4531 works.
4532 works.
4532
4533
4533 2001-11-28 Fernando Perez <fperez@colorado.edu>
4534 2001-11-28 Fernando Perez <fperez@colorado.edu>
4534
4535
4535 * Changed @file so that it opens the source file at the proper
4536 * Changed @file so that it opens the source file at the proper
4536 line. Since it uses less, if your EDITOR environment is
4537 line. Since it uses less, if your EDITOR environment is
4537 configured, typing v will immediately open your editor of choice
4538 configured, typing v will immediately open your editor of choice
4538 right at the line where the object is defined. Not as quick as
4539 right at the line where the object is defined. Not as quick as
4539 having a direct @edit command, but for all intents and purposes it
4540 having a direct @edit command, but for all intents and purposes it
4540 works. And I don't have to worry about writing @edit to deal with
4541 works. And I don't have to worry about writing @edit to deal with
4541 all the editors, less does that.
4542 all the editors, less does that.
4542
4543
4543 * Version 0.1.16 released, 0.1.17 opened.
4544 * Version 0.1.16 released, 0.1.17 opened.
4544
4545
4545 * Fixed some nasty bugs in the page/page_dumb combo that could
4546 * Fixed some nasty bugs in the page/page_dumb combo that could
4546 crash IPython.
4547 crash IPython.
4547
4548
4548 2001-11-27 Fernando Perez <fperez@colorado.edu>
4549 2001-11-27 Fernando Perez <fperez@colorado.edu>
4549
4550
4550 * Version 0.1.15 released, 0.1.16 opened.
4551 * Version 0.1.15 released, 0.1.16 opened.
4551
4552
4552 * Finally got ? and ?? to work for undefined things: now it's
4553 * Finally got ? and ?? to work for undefined things: now it's
4553 possible to type {}.get? and get information about the get method
4554 possible to type {}.get? and get information about the get method
4554 of dicts, or os.path? even if only os is defined (so technically
4555 of dicts, or os.path? even if only os is defined (so technically
4555 os.path isn't). Works at any level. For example, after import os,
4556 os.path isn't). Works at any level. For example, after import os,
4556 os?, os.path?, os.path.abspath? all work. This is great, took some
4557 os?, os.path?, os.path.abspath? all work. This is great, took some
4557 work in _ofind.
4558 work in _ofind.
4558
4559
4559 * Fixed more bugs with logging. The sanest way to do it was to add
4560 * Fixed more bugs with logging. The sanest way to do it was to add
4560 to @log a 'mode' parameter. Killed two in one shot (this mode
4561 to @log a 'mode' parameter. Killed two in one shot (this mode
4561 option was a request of Janko's). I think it's finally clean
4562 option was a request of Janko's). I think it's finally clean
4562 (famous last words).
4563 (famous last words).
4563
4564
4564 * Added a page_dumb() pager which does a decent job of paging on
4565 * Added a page_dumb() pager which does a decent job of paging on
4565 screen, if better things (like less) aren't available. One less
4566 screen, if better things (like less) aren't available. One less
4566 unix dependency (someday maybe somebody will port this to
4567 unix dependency (someday maybe somebody will port this to
4567 windows).
4568 windows).
4568
4569
4569 * Fixed problem in magic_log: would lock of logging out if log
4570 * Fixed problem in magic_log: would lock of logging out if log
4570 creation failed (because it would still think it had succeeded).
4571 creation failed (because it would still think it had succeeded).
4571
4572
4572 * Improved the page() function using curses to auto-detect screen
4573 * Improved the page() function using curses to auto-detect screen
4573 size. Now it can make a much better decision on whether to print
4574 size. Now it can make a much better decision on whether to print
4574 or page a string. Option screen_length was modified: a value 0
4575 or page a string. Option screen_length was modified: a value 0
4575 means auto-detect, and that's the default now.
4576 means auto-detect, and that's the default now.
4576
4577
4577 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4578 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4578 go out. I'll test it for a few days, then talk to Janko about
4579 go out. I'll test it for a few days, then talk to Janko about
4579 licences and announce it.
4580 licences and announce it.
4580
4581
4581 * Fixed the length of the auto-generated ---> prompt which appears
4582 * Fixed the length of the auto-generated ---> prompt which appears
4582 for auto-parens and auto-quotes. Getting this right isn't trivial,
4583 for auto-parens and auto-quotes. Getting this right isn't trivial,
4583 with all the color escapes, different prompt types and optional
4584 with all the color escapes, different prompt types and optional
4584 separators. But it seems to be working in all the combinations.
4585 separators. But it seems to be working in all the combinations.
4585
4586
4586 2001-11-26 Fernando Perez <fperez@colorado.edu>
4587 2001-11-26 Fernando Perez <fperez@colorado.edu>
4587
4588
4588 * Wrote a regexp filter to get option types from the option names
4589 * Wrote a regexp filter to get option types from the option names
4589 string. This eliminates the need to manually keep two duplicate
4590 string. This eliminates the need to manually keep two duplicate
4590 lists.
4591 lists.
4591
4592
4592 * Removed the unneeded check_option_names. Now options are handled
4593 * Removed the unneeded check_option_names. Now options are handled
4593 in a much saner manner and it's easy to visually check that things
4594 in a much saner manner and it's easy to visually check that things
4594 are ok.
4595 are ok.
4595
4596
4596 * Updated version numbers on all files I modified to carry a
4597 * Updated version numbers on all files I modified to carry a
4597 notice so Janko and Nathan have clear version markers.
4598 notice so Janko and Nathan have clear version markers.
4598
4599
4599 * Updated docstring for ultraTB with my changes. I should send
4600 * Updated docstring for ultraTB with my changes. I should send
4600 this to Nathan.
4601 this to Nathan.
4601
4602
4602 * Lots of small fixes. Ran everything through pychecker again.
4603 * Lots of small fixes. Ran everything through pychecker again.
4603
4604
4604 * Made loading of deep_reload an cmd line option. If it's not too
4605 * Made loading of deep_reload an cmd line option. If it's not too
4605 kosher, now people can just disable it. With -nodeep_reload it's
4606 kosher, now people can just disable it. With -nodeep_reload it's
4606 still available as dreload(), it just won't overwrite reload().
4607 still available as dreload(), it just won't overwrite reload().
4607
4608
4608 * Moved many options to the no| form (-opt and -noopt
4609 * Moved many options to the no| form (-opt and -noopt
4609 accepted). Cleaner.
4610 accepted). Cleaner.
4610
4611
4611 * Changed magic_log so that if called with no parameters, it uses
4612 * Changed magic_log so that if called with no parameters, it uses
4612 'rotate' mode. That way auto-generated logs aren't automatically
4613 'rotate' mode. That way auto-generated logs aren't automatically
4613 over-written. For normal logs, now a backup is made if it exists
4614 over-written. For normal logs, now a backup is made if it exists
4614 (only 1 level of backups). A new 'backup' mode was added to the
4615 (only 1 level of backups). A new 'backup' mode was added to the
4615 Logger class to support this. This was a request by Janko.
4616 Logger class to support this. This was a request by Janko.
4616
4617
4617 * Added @logoff/@logon to stop/restart an active log.
4618 * Added @logoff/@logon to stop/restart an active log.
4618
4619
4619 * Fixed a lot of bugs in log saving/replay. It was pretty
4620 * Fixed a lot of bugs in log saving/replay. It was pretty
4620 broken. Now special lines (!@,/) appear properly in the command
4621 broken. Now special lines (!@,/) appear properly in the command
4621 history after a log replay.
4622 history after a log replay.
4622
4623
4623 * Tried and failed to implement full session saving via pickle. My
4624 * Tried and failed to implement full session saving via pickle. My
4624 idea was to pickle __main__.__dict__, but modules can't be
4625 idea was to pickle __main__.__dict__, but modules can't be
4625 pickled. This would be a better alternative to replaying logs, but
4626 pickled. This would be a better alternative to replaying logs, but
4626 seems quite tricky to get to work. Changed -session to be called
4627 seems quite tricky to get to work. Changed -session to be called
4627 -logplay, which more accurately reflects what it does. And if we
4628 -logplay, which more accurately reflects what it does. And if we
4628 ever get real session saving working, -session is now available.
4629 ever get real session saving working, -session is now available.
4629
4630
4630 * Implemented color schemes for prompts also. As for tracebacks,
4631 * Implemented color schemes for prompts also. As for tracebacks,
4631 currently only NoColor and Linux are supported. But now the
4632 currently only NoColor and Linux are supported. But now the
4632 infrastructure is in place, based on a generic ColorScheme
4633 infrastructure is in place, based on a generic ColorScheme
4633 class. So writing and activating new schemes both for the prompts
4634 class. So writing and activating new schemes both for the prompts
4634 and the tracebacks should be straightforward.
4635 and the tracebacks should be straightforward.
4635
4636
4636 * Version 0.1.13 released, 0.1.14 opened.
4637 * Version 0.1.13 released, 0.1.14 opened.
4637
4638
4638 * Changed handling of options for output cache. Now counter is
4639 * Changed handling of options for output cache. Now counter is
4639 hardwired starting at 1 and one specifies the maximum number of
4640 hardwired starting at 1 and one specifies the maximum number of
4640 entries *in the outcache* (not the max prompt counter). This is
4641 entries *in the outcache* (not the max prompt counter). This is
4641 much better, since many statements won't increase the cache
4642 much better, since many statements won't increase the cache
4642 count. It also eliminated some confusing options, now there's only
4643 count. It also eliminated some confusing options, now there's only
4643 one: cache_size.
4644 one: cache_size.
4644
4645
4645 * Added 'alias' magic function and magic_alias option in the
4646 * Added 'alias' magic function and magic_alias option in the
4646 ipythonrc file. Now the user can easily define whatever names he
4647 ipythonrc file. Now the user can easily define whatever names he
4647 wants for the magic functions without having to play weird
4648 wants for the magic functions without having to play weird
4648 namespace games. This gives IPython a real shell-like feel.
4649 namespace games. This gives IPython a real shell-like feel.
4649
4650
4650 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4651 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4651 @ or not).
4652 @ or not).
4652
4653
4653 This was one of the last remaining 'visible' bugs (that I know
4654 This was one of the last remaining 'visible' bugs (that I know
4654 of). I think if I can clean up the session loading so it works
4655 of). I think if I can clean up the session loading so it works
4655 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4656 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4656 about licensing).
4657 about licensing).
4657
4658
4658 2001-11-25 Fernando Perez <fperez@colorado.edu>
4659 2001-11-25 Fernando Perez <fperez@colorado.edu>
4659
4660
4660 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4661 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4661 there's a cleaner distinction between what ? and ?? show.
4662 there's a cleaner distinction between what ? and ?? show.
4662
4663
4663 * Added screen_length option. Now the user can define his own
4664 * Added screen_length option. Now the user can define his own
4664 screen size for page() operations.
4665 screen size for page() operations.
4665
4666
4666 * Implemented magic shell-like functions with automatic code
4667 * Implemented magic shell-like functions with automatic code
4667 generation. Now adding another function is just a matter of adding
4668 generation. Now adding another function is just a matter of adding
4668 an entry to a dict, and the function is dynamically generated at
4669 an entry to a dict, and the function is dynamically generated at
4669 run-time. Python has some really cool features!
4670 run-time. Python has some really cool features!
4670
4671
4671 * Renamed many options to cleanup conventions a little. Now all
4672 * Renamed many options to cleanup conventions a little. Now all
4672 are lowercase, and only underscores where needed. Also in the code
4673 are lowercase, and only underscores where needed. Also in the code
4673 option name tables are clearer.
4674 option name tables are clearer.
4674
4675
4675 * Changed prompts a little. Now input is 'In [n]:' instead of
4676 * Changed prompts a little. Now input is 'In [n]:' instead of
4676 'In[n]:='. This allows it the numbers to be aligned with the
4677 'In[n]:='. This allows it the numbers to be aligned with the
4677 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4678 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4678 Python (it was a Mathematica thing). The '...' continuation prompt
4679 Python (it was a Mathematica thing). The '...' continuation prompt
4679 was also changed a little to align better.
4680 was also changed a little to align better.
4680
4681
4681 * Fixed bug when flushing output cache. Not all _p<n> variables
4682 * Fixed bug when flushing output cache. Not all _p<n> variables
4682 exist, so their deletion needs to be wrapped in a try:
4683 exist, so their deletion needs to be wrapped in a try:
4683
4684
4684 * Figured out how to properly use inspect.formatargspec() (it
4685 * Figured out how to properly use inspect.formatargspec() (it
4685 requires the args preceded by *). So I removed all the code from
4686 requires the args preceded by *). So I removed all the code from
4686 _get_pdef in Magic, which was just replicating that.
4687 _get_pdef in Magic, which was just replicating that.
4687
4688
4688 * Added test to prefilter to allow redefining magic function names
4689 * Added test to prefilter to allow redefining magic function names
4689 as variables. This is ok, since the @ form is always available,
4690 as variables. This is ok, since the @ form is always available,
4690 but whe should allow the user to define a variable called 'ls' if
4691 but whe should allow the user to define a variable called 'ls' if
4691 he needs it.
4692 he needs it.
4692
4693
4693 * Moved the ToDo information from README into a separate ToDo.
4694 * Moved the ToDo information from README into a separate ToDo.
4694
4695
4695 * General code cleanup and small bugfixes. I think it's close to a
4696 * General code cleanup and small bugfixes. I think it's close to a
4696 state where it can be released, obviously with a big 'beta'
4697 state where it can be released, obviously with a big 'beta'
4697 warning on it.
4698 warning on it.
4698
4699
4699 * Got the magic function split to work. Now all magics are defined
4700 * Got the magic function split to work. Now all magics are defined
4700 in a separate class. It just organizes things a bit, and now
4701 in a separate class. It just organizes things a bit, and now
4701 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4702 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4702 was too long).
4703 was too long).
4703
4704
4704 * Changed @clear to @reset to avoid potential confusions with
4705 * Changed @clear to @reset to avoid potential confusions with
4705 the shell command clear. Also renamed @cl to @clear, which does
4706 the shell command clear. Also renamed @cl to @clear, which does
4706 exactly what people expect it to from their shell experience.
4707 exactly what people expect it to from their shell experience.
4707
4708
4708 Added a check to the @reset command (since it's so
4709 Added a check to the @reset command (since it's so
4709 destructive, it's probably a good idea to ask for confirmation).
4710 destructive, it's probably a good idea to ask for confirmation).
4710 But now reset only works for full namespace resetting. Since the
4711 But now reset only works for full namespace resetting. Since the
4711 del keyword is already there for deleting a few specific
4712 del keyword is already there for deleting a few specific
4712 variables, I don't see the point of having a redundant magic
4713 variables, I don't see the point of having a redundant magic
4713 function for the same task.
4714 function for the same task.
4714
4715
4715 2001-11-24 Fernando Perez <fperez@colorado.edu>
4716 2001-11-24 Fernando Perez <fperez@colorado.edu>
4716
4717
4717 * Updated the builtin docs (esp. the ? ones).
4718 * Updated the builtin docs (esp. the ? ones).
4718
4719
4719 * Ran all the code through pychecker. Not terribly impressed with
4720 * Ran all the code through pychecker. Not terribly impressed with
4720 it: lots of spurious warnings and didn't really find anything of
4721 it: lots of spurious warnings and didn't really find anything of
4721 substance (just a few modules being imported and not used).
4722 substance (just a few modules being imported and not used).
4722
4723
4723 * Implemented the new ultraTB functionality into IPython. New
4724 * Implemented the new ultraTB functionality into IPython. New
4724 option: xcolors. This chooses color scheme. xmode now only selects
4725 option: xcolors. This chooses color scheme. xmode now only selects
4725 between Plain and Verbose. Better orthogonality.
4726 between Plain and Verbose. Better orthogonality.
4726
4727
4727 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4728 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4728 mode and color scheme for the exception handlers. Now it's
4729 mode and color scheme for the exception handlers. Now it's
4729 possible to have the verbose traceback with no coloring.
4730 possible to have the verbose traceback with no coloring.
4730
4731
4731 2001-11-23 Fernando Perez <fperez@colorado.edu>
4732 2001-11-23 Fernando Perez <fperez@colorado.edu>
4732
4733
4733 * Version 0.1.12 released, 0.1.13 opened.
4734 * Version 0.1.12 released, 0.1.13 opened.
4734
4735
4735 * Removed option to set auto-quote and auto-paren escapes by
4736 * Removed option to set auto-quote and auto-paren escapes by
4736 user. The chances of breaking valid syntax are just too high. If
4737 user. The chances of breaking valid syntax are just too high. If
4737 someone *really* wants, they can always dig into the code.
4738 someone *really* wants, they can always dig into the code.
4738
4739
4739 * Made prompt separators configurable.
4740 * Made prompt separators configurable.
4740
4741
4741 2001-11-22 Fernando Perez <fperez@colorado.edu>
4742 2001-11-22 Fernando Perez <fperez@colorado.edu>
4742
4743
4743 * Small bugfixes in many places.
4744 * Small bugfixes in many places.
4744
4745
4745 * Removed the MyCompleter class from ipplib. It seemed redundant
4746 * Removed the MyCompleter class from ipplib. It seemed redundant
4746 with the C-p,C-n history search functionality. Less code to
4747 with the C-p,C-n history search functionality. Less code to
4747 maintain.
4748 maintain.
4748
4749
4749 * Moved all the original ipython.py code into ipythonlib.py. Right
4750 * Moved all the original ipython.py code into ipythonlib.py. Right
4750 now it's just one big dump into a function called make_IPython, so
4751 now it's just one big dump into a function called make_IPython, so
4751 no real modularity has been gained. But at least it makes the
4752 no real modularity has been gained. But at least it makes the
4752 wrapper script tiny, and since ipythonlib is a module, it gets
4753 wrapper script tiny, and since ipythonlib is a module, it gets
4753 compiled and startup is much faster.
4754 compiled and startup is much faster.
4754
4755
4755 This is a reasobably 'deep' change, so we should test it for a
4756 This is a reasobably 'deep' change, so we should test it for a
4756 while without messing too much more with the code.
4757 while without messing too much more with the code.
4757
4758
4758 2001-11-21 Fernando Perez <fperez@colorado.edu>
4759 2001-11-21 Fernando Perez <fperez@colorado.edu>
4759
4760
4760 * Version 0.1.11 released, 0.1.12 opened for further work.
4761 * Version 0.1.11 released, 0.1.12 opened for further work.
4761
4762
4762 * Removed dependency on Itpl. It was only needed in one place. It
4763 * Removed dependency on Itpl. It was only needed in one place. It
4763 would be nice if this became part of python, though. It makes life
4764 would be nice if this became part of python, though. It makes life
4764 *a lot* easier in some cases.
4765 *a lot* easier in some cases.
4765
4766
4766 * Simplified the prefilter code a bit. Now all handlers are
4767 * Simplified the prefilter code a bit. Now all handlers are
4767 expected to explicitly return a value (at least a blank string).
4768 expected to explicitly return a value (at least a blank string).
4768
4769
4769 * Heavy edits in ipplib. Removed the help system altogether. Now
4770 * Heavy edits in ipplib. Removed the help system altogether. Now
4770 obj?/?? is used for inspecting objects, a magic @doc prints
4771 obj?/?? is used for inspecting objects, a magic @doc prints
4771 docstrings, and full-blown Python help is accessed via the 'help'
4772 docstrings, and full-blown Python help is accessed via the 'help'
4772 keyword. This cleans up a lot of code (less to maintain) and does
4773 keyword. This cleans up a lot of code (less to maintain) and does
4773 the job. Since 'help' is now a standard Python component, might as
4774 the job. Since 'help' is now a standard Python component, might as
4774 well use it and remove duplicate functionality.
4775 well use it and remove duplicate functionality.
4775
4776
4776 Also removed the option to use ipplib as a standalone program. By
4777 Also removed the option to use ipplib as a standalone program. By
4777 now it's too dependent on other parts of IPython to function alone.
4778 now it's too dependent on other parts of IPython to function alone.
4778
4779
4779 * Fixed bug in genutils.pager. It would crash if the pager was
4780 * Fixed bug in genutils.pager. It would crash if the pager was
4780 exited immediately after opening (broken pipe).
4781 exited immediately after opening (broken pipe).
4781
4782
4782 * Trimmed down the VerboseTB reporting a little. The header is
4783 * Trimmed down the VerboseTB reporting a little. The header is
4783 much shorter now and the repeated exception arguments at the end
4784 much shorter now and the repeated exception arguments at the end
4784 have been removed. For interactive use the old header seemed a bit
4785 have been removed. For interactive use the old header seemed a bit
4785 excessive.
4786 excessive.
4786
4787
4787 * Fixed small bug in output of @whos for variables with multi-word
4788 * Fixed small bug in output of @whos for variables with multi-word
4788 types (only first word was displayed).
4789 types (only first word was displayed).
4789
4790
4790 2001-11-17 Fernando Perez <fperez@colorado.edu>
4791 2001-11-17 Fernando Perez <fperez@colorado.edu>
4791
4792
4792 * Version 0.1.10 released, 0.1.11 opened for further work.
4793 * Version 0.1.10 released, 0.1.11 opened for further work.
4793
4794
4794 * Modified dirs and friends. dirs now *returns* the stack (not
4795 * Modified dirs and friends. dirs now *returns* the stack (not
4795 prints), so one can manipulate it as a variable. Convenient to
4796 prints), so one can manipulate it as a variable. Convenient to
4796 travel along many directories.
4797 travel along many directories.
4797
4798
4798 * Fixed bug in magic_pdef: would only work with functions with
4799 * Fixed bug in magic_pdef: would only work with functions with
4799 arguments with default values.
4800 arguments with default values.
4800
4801
4801 2001-11-14 Fernando Perez <fperez@colorado.edu>
4802 2001-11-14 Fernando Perez <fperez@colorado.edu>
4802
4803
4803 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4804 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4804 example with IPython. Various other minor fixes and cleanups.
4805 example with IPython. Various other minor fixes and cleanups.
4805
4806
4806 * Version 0.1.9 released, 0.1.10 opened for further work.
4807 * Version 0.1.9 released, 0.1.10 opened for further work.
4807
4808
4808 * Added sys.path to the list of directories searched in the
4809 * Added sys.path to the list of directories searched in the
4809 execfile= option. It used to be the current directory and the
4810 execfile= option. It used to be the current directory and the
4810 user's IPYTHONDIR only.
4811 user's IPYTHONDIR only.
4811
4812
4812 2001-11-13 Fernando Perez <fperez@colorado.edu>
4813 2001-11-13 Fernando Perez <fperez@colorado.edu>
4813
4814
4814 * Reinstated the raw_input/prefilter separation that Janko had
4815 * Reinstated the raw_input/prefilter separation that Janko had
4815 initially. This gives a more convenient setup for extending the
4816 initially. This gives a more convenient setup for extending the
4816 pre-processor from the outside: raw_input always gets a string,
4817 pre-processor from the outside: raw_input always gets a string,
4817 and prefilter has to process it. We can then redefine prefilter
4818 and prefilter has to process it. We can then redefine prefilter
4818 from the outside and implement extensions for special
4819 from the outside and implement extensions for special
4819 purposes.
4820 purposes.
4820
4821
4821 Today I got one for inputting PhysicalQuantity objects
4822 Today I got one for inputting PhysicalQuantity objects
4822 (from Scientific) without needing any function calls at
4823 (from Scientific) without needing any function calls at
4823 all. Extremely convenient, and it's all done as a user-level
4824 all. Extremely convenient, and it's all done as a user-level
4824 extension (no IPython code was touched). Now instead of:
4825 extension (no IPython code was touched). Now instead of:
4825 a = PhysicalQuantity(4.2,'m/s**2')
4826 a = PhysicalQuantity(4.2,'m/s**2')
4826 one can simply say
4827 one can simply say
4827 a = 4.2 m/s**2
4828 a = 4.2 m/s**2
4828 or even
4829 or even
4829 a = 4.2 m/s^2
4830 a = 4.2 m/s^2
4830
4831
4831 I use this, but it's also a proof of concept: IPython really is
4832 I use this, but it's also a proof of concept: IPython really is
4832 fully user-extensible, even at the level of the parsing of the
4833 fully user-extensible, even at the level of the parsing of the
4833 command line. It's not trivial, but it's perfectly doable.
4834 command line. It's not trivial, but it's perfectly doable.
4834
4835
4835 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4836 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4836 the problem of modules being loaded in the inverse order in which
4837 the problem of modules being loaded in the inverse order in which
4837 they were defined in
4838 they were defined in
4838
4839
4839 * Version 0.1.8 released, 0.1.9 opened for further work.
4840 * Version 0.1.8 released, 0.1.9 opened for further work.
4840
4841
4841 * Added magics pdef, source and file. They respectively show the
4842 * Added magics pdef, source and file. They respectively show the
4842 definition line ('prototype' in C), source code and full python
4843 definition line ('prototype' in C), source code and full python
4843 file for any callable object. The object inspector oinfo uses
4844 file for any callable object. The object inspector oinfo uses
4844 these to show the same information.
4845 these to show the same information.
4845
4846
4846 * Version 0.1.7 released, 0.1.8 opened for further work.
4847 * Version 0.1.7 released, 0.1.8 opened for further work.
4847
4848
4848 * Separated all the magic functions into a class called Magic. The
4849 * Separated all the magic functions into a class called Magic. The
4849 InteractiveShell class was becoming too big for Xemacs to handle
4850 InteractiveShell class was becoming too big for Xemacs to handle
4850 (de-indenting a line would lock it up for 10 seconds while it
4851 (de-indenting a line would lock it up for 10 seconds while it
4851 backtracked on the whole class!)
4852 backtracked on the whole class!)
4852
4853
4853 FIXME: didn't work. It can be done, but right now namespaces are
4854 FIXME: didn't work. It can be done, but right now namespaces are
4854 all messed up. Do it later (reverted it for now, so at least
4855 all messed up. Do it later (reverted it for now, so at least
4855 everything works as before).
4856 everything works as before).
4856
4857
4857 * Got the object introspection system (magic_oinfo) working! I
4858 * Got the object introspection system (magic_oinfo) working! I
4858 think this is pretty much ready for release to Janko, so he can
4859 think this is pretty much ready for release to Janko, so he can
4859 test it for a while and then announce it. Pretty much 100% of what
4860 test it for a while and then announce it. Pretty much 100% of what
4860 I wanted for the 'phase 1' release is ready. Happy, tired.
4861 I wanted for the 'phase 1' release is ready. Happy, tired.
4861
4862
4862 2001-11-12 Fernando Perez <fperez@colorado.edu>
4863 2001-11-12 Fernando Perez <fperez@colorado.edu>
4863
4864
4864 * Version 0.1.6 released, 0.1.7 opened for further work.
4865 * Version 0.1.6 released, 0.1.7 opened for further work.
4865
4866
4866 * Fixed bug in printing: it used to test for truth before
4867 * Fixed bug in printing: it used to test for truth before
4867 printing, so 0 wouldn't print. Now checks for None.
4868 printing, so 0 wouldn't print. Now checks for None.
4868
4869
4869 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4870 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4870 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4871 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4871 reaches by hand into the outputcache. Think of a better way to do
4872 reaches by hand into the outputcache. Think of a better way to do
4872 this later.
4873 this later.
4873
4874
4874 * Various small fixes thanks to Nathan's comments.
4875 * Various small fixes thanks to Nathan's comments.
4875
4876
4876 * Changed magic_pprint to magic_Pprint. This way it doesn't
4877 * Changed magic_pprint to magic_Pprint. This way it doesn't
4877 collide with pprint() and the name is consistent with the command
4878 collide with pprint() and the name is consistent with the command
4878 line option.
4879 line option.
4879
4880
4880 * Changed prompt counter behavior to be fully like
4881 * Changed prompt counter behavior to be fully like
4881 Mathematica's. That is, even input that doesn't return a result
4882 Mathematica's. That is, even input that doesn't return a result
4882 raises the prompt counter. The old behavior was kind of confusing
4883 raises the prompt counter. The old behavior was kind of confusing
4883 (getting the same prompt number several times if the operation
4884 (getting the same prompt number several times if the operation
4884 didn't return a result).
4885 didn't return a result).
4885
4886
4886 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4887 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4887
4888
4888 * Fixed -Classic mode (wasn't working anymore).
4889 * Fixed -Classic mode (wasn't working anymore).
4889
4890
4890 * Added colored prompts using Nathan's new code. Colors are
4891 * Added colored prompts using Nathan's new code. Colors are
4891 currently hardwired, they can be user-configurable. For
4892 currently hardwired, they can be user-configurable. For
4892 developers, they can be chosen in file ipythonlib.py, at the
4893 developers, they can be chosen in file ipythonlib.py, at the
4893 beginning of the CachedOutput class def.
4894 beginning of the CachedOutput class def.
4894
4895
4895 2001-11-11 Fernando Perez <fperez@colorado.edu>
4896 2001-11-11 Fernando Perez <fperez@colorado.edu>
4896
4897
4897 * Version 0.1.5 released, 0.1.6 opened for further work.
4898 * Version 0.1.5 released, 0.1.6 opened for further work.
4898
4899
4899 * Changed magic_env to *return* the environment as a dict (not to
4900 * Changed magic_env to *return* the environment as a dict (not to
4900 print it). This way it prints, but it can also be processed.
4901 print it). This way it prints, but it can also be processed.
4901
4902
4902 * Added Verbose exception reporting to interactive
4903 * Added Verbose exception reporting to interactive
4903 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4904 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4904 traceback. Had to make some changes to the ultraTB file. This is
4905 traceback. Had to make some changes to the ultraTB file. This is
4905 probably the last 'big' thing in my mental todo list. This ties
4906 probably the last 'big' thing in my mental todo list. This ties
4906 in with the next entry:
4907 in with the next entry:
4907
4908
4908 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4909 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4909 has to specify is Plain, Color or Verbose for all exception
4910 has to specify is Plain, Color or Verbose for all exception
4910 handling.
4911 handling.
4911
4912
4912 * Removed ShellServices option. All this can really be done via
4913 * Removed ShellServices option. All this can really be done via
4913 the magic system. It's easier to extend, cleaner and has automatic
4914 the magic system. It's easier to extend, cleaner and has automatic
4914 namespace protection and documentation.
4915 namespace protection and documentation.
4915
4916
4916 2001-11-09 Fernando Perez <fperez@colorado.edu>
4917 2001-11-09 Fernando Perez <fperez@colorado.edu>
4917
4918
4918 * Fixed bug in output cache flushing (missing parameter to
4919 * Fixed bug in output cache flushing (missing parameter to
4919 __init__). Other small bugs fixed (found using pychecker).
4920 __init__). Other small bugs fixed (found using pychecker).
4920
4921
4921 * Version 0.1.4 opened for bugfixing.
4922 * Version 0.1.4 opened for bugfixing.
4922
4923
4923 2001-11-07 Fernando Perez <fperez@colorado.edu>
4924 2001-11-07 Fernando Perez <fperez@colorado.edu>
4924
4925
4925 * Version 0.1.3 released, mainly because of the raw_input bug.
4926 * Version 0.1.3 released, mainly because of the raw_input bug.
4926
4927
4927 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4928 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4928 and when testing for whether things were callable, a call could
4929 and when testing for whether things were callable, a call could
4929 actually be made to certain functions. They would get called again
4930 actually be made to certain functions. They would get called again
4930 once 'really' executed, with a resulting double call. A disaster
4931 once 'really' executed, with a resulting double call. A disaster
4931 in many cases (list.reverse() would never work!).
4932 in many cases (list.reverse() would never work!).
4932
4933
4933 * Removed prefilter() function, moved its code to raw_input (which
4934 * Removed prefilter() function, moved its code to raw_input (which
4934 after all was just a near-empty caller for prefilter). This saves
4935 after all was just a near-empty caller for prefilter). This saves
4935 a function call on every prompt, and simplifies the class a tiny bit.
4936 a function call on every prompt, and simplifies the class a tiny bit.
4936
4937
4937 * Fix _ip to __ip name in magic example file.
4938 * Fix _ip to __ip name in magic example file.
4938
4939
4939 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4940 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4940 work with non-gnu versions of tar.
4941 work with non-gnu versions of tar.
4941
4942
4942 2001-11-06 Fernando Perez <fperez@colorado.edu>
4943 2001-11-06 Fernando Perez <fperez@colorado.edu>
4943
4944
4944 * Version 0.1.2. Just to keep track of the recent changes.
4945 * Version 0.1.2. Just to keep track of the recent changes.
4945
4946
4946 * Fixed nasty bug in output prompt routine. It used to check 'if
4947 * Fixed nasty bug in output prompt routine. It used to check 'if
4947 arg != None...'. Problem is, this fails if arg implements a
4948 arg != None...'. Problem is, this fails if arg implements a
4948 special comparison (__cmp__) which disallows comparing to
4949 special comparison (__cmp__) which disallows comparing to
4949 None. Found it when trying to use the PhysicalQuantity module from
4950 None. Found it when trying to use the PhysicalQuantity module from
4950 ScientificPython.
4951 ScientificPython.
4951
4952
4952 2001-11-05 Fernando Perez <fperez@colorado.edu>
4953 2001-11-05 Fernando Perez <fperez@colorado.edu>
4953
4954
4954 * Also added dirs. Now the pushd/popd/dirs family functions
4955 * Also added dirs. Now the pushd/popd/dirs family functions
4955 basically like the shell, with the added convenience of going home
4956 basically like the shell, with the added convenience of going home
4956 when called with no args.
4957 when called with no args.
4957
4958
4958 * pushd/popd slightly modified to mimic shell behavior more
4959 * pushd/popd slightly modified to mimic shell behavior more
4959 closely.
4960 closely.
4960
4961
4961 * Added env,pushd,popd from ShellServices as magic functions. I
4962 * Added env,pushd,popd from ShellServices as magic functions. I
4962 think the cleanest will be to port all desired functions from
4963 think the cleanest will be to port all desired functions from
4963 ShellServices as magics and remove ShellServices altogether. This
4964 ShellServices as magics and remove ShellServices altogether. This
4964 will provide a single, clean way of adding functionality
4965 will provide a single, clean way of adding functionality
4965 (shell-type or otherwise) to IP.
4966 (shell-type or otherwise) to IP.
4966
4967
4967 2001-11-04 Fernando Perez <fperez@colorado.edu>
4968 2001-11-04 Fernando Perez <fperez@colorado.edu>
4968
4969
4969 * Added .ipython/ directory to sys.path. This way users can keep
4970 * Added .ipython/ directory to sys.path. This way users can keep
4970 customizations there and access them via import.
4971 customizations there and access them via import.
4971
4972
4972 2001-11-03 Fernando Perez <fperez@colorado.edu>
4973 2001-11-03 Fernando Perez <fperez@colorado.edu>
4973
4974
4974 * Opened version 0.1.1 for new changes.
4975 * Opened version 0.1.1 for new changes.
4975
4976
4976 * Changed version number to 0.1.0: first 'public' release, sent to
4977 * Changed version number to 0.1.0: first 'public' release, sent to
4977 Nathan and Janko.
4978 Nathan and Janko.
4978
4979
4979 * Lots of small fixes and tweaks.
4980 * Lots of small fixes and tweaks.
4980
4981
4981 * Minor changes to whos format. Now strings are shown, snipped if
4982 * Minor changes to whos format. Now strings are shown, snipped if
4982 too long.
4983 too long.
4983
4984
4984 * Changed ShellServices to work on __main__ so they show up in @who
4985 * Changed ShellServices to work on __main__ so they show up in @who
4985
4986
4986 * Help also works with ? at the end of a line:
4987 * Help also works with ? at the end of a line:
4987 ?sin and sin?
4988 ?sin and sin?
4988 both produce the same effect. This is nice, as often I use the
4989 both produce the same effect. This is nice, as often I use the
4989 tab-complete to find the name of a method, but I used to then have
4990 tab-complete to find the name of a method, but I used to then have
4990 to go to the beginning of the line to put a ? if I wanted more
4991 to go to the beginning of the line to put a ? if I wanted more
4991 info. Now I can just add the ? and hit return. Convenient.
4992 info. Now I can just add the ? and hit return. Convenient.
4992
4993
4993 2001-11-02 Fernando Perez <fperez@colorado.edu>
4994 2001-11-02 Fernando Perez <fperez@colorado.edu>
4994
4995
4995 * Python version check (>=2.1) added.
4996 * Python version check (>=2.1) added.
4996
4997
4997 * Added LazyPython documentation. At this point the docs are quite
4998 * Added LazyPython documentation. At this point the docs are quite
4998 a mess. A cleanup is in order.
4999 a mess. A cleanup is in order.
4999
5000
5000 * Auto-installer created. For some bizarre reason, the zipfiles
5001 * Auto-installer created. For some bizarre reason, the zipfiles
5001 module isn't working on my system. So I made a tar version
5002 module isn't working on my system. So I made a tar version
5002 (hopefully the command line options in various systems won't kill
5003 (hopefully the command line options in various systems won't kill
5003 me).
5004 me).
5004
5005
5005 * Fixes to Struct in genutils. Now all dictionary-like methods are
5006 * Fixes to Struct in genutils. Now all dictionary-like methods are
5006 protected (reasonably).
5007 protected (reasonably).
5007
5008
5008 * Added pager function to genutils and changed ? to print usage
5009 * Added pager function to genutils and changed ? to print usage
5009 note through it (it was too long).
5010 note through it (it was too long).
5010
5011
5011 * Added the LazyPython functionality. Works great! I changed the
5012 * Added the LazyPython functionality. Works great! I changed the
5012 auto-quote escape to ';', it's on home row and next to '. But
5013 auto-quote escape to ';', it's on home row and next to '. But
5013 both auto-quote and auto-paren (still /) escapes are command-line
5014 both auto-quote and auto-paren (still /) escapes are command-line
5014 parameters.
5015 parameters.
5015
5016
5016
5017
5017 2001-11-01 Fernando Perez <fperez@colorado.edu>
5018 2001-11-01 Fernando Perez <fperez@colorado.edu>
5018
5019
5019 * Version changed to 0.0.7. Fairly large change: configuration now
5020 * Version changed to 0.0.7. Fairly large change: configuration now
5020 is all stored in a directory, by default .ipython. There, all
5021 is all stored in a directory, by default .ipython. There, all
5021 config files have normal looking names (not .names)
5022 config files have normal looking names (not .names)
5022
5023
5023 * Version 0.0.6 Released first to Lucas and Archie as a test
5024 * Version 0.0.6 Released first to Lucas and Archie as a test
5024 run. Since it's the first 'semi-public' release, change version to
5025 run. Since it's the first 'semi-public' release, change version to
5025 > 0.0.6 for any changes now.
5026 > 0.0.6 for any changes now.
5026
5027
5027 * Stuff I had put in the ipplib.py changelog:
5028 * Stuff I had put in the ipplib.py changelog:
5028
5029
5029 Changes to InteractiveShell:
5030 Changes to InteractiveShell:
5030
5031
5031 - Made the usage message a parameter.
5032 - Made the usage message a parameter.
5032
5033
5033 - Require the name of the shell variable to be given. It's a bit
5034 - Require the name of the shell variable to be given. It's a bit
5034 of a hack, but allows the name 'shell' not to be hardwire in the
5035 of a hack, but allows the name 'shell' not to be hardwire in the
5035 magic (@) handler, which is problematic b/c it requires
5036 magic (@) handler, which is problematic b/c it requires
5036 polluting the global namespace with 'shell'. This in turn is
5037 polluting the global namespace with 'shell'. This in turn is
5037 fragile: if a user redefines a variable called shell, things
5038 fragile: if a user redefines a variable called shell, things
5038 break.
5039 break.
5039
5040
5040 - magic @: all functions available through @ need to be defined
5041 - magic @: all functions available through @ need to be defined
5041 as magic_<name>, even though they can be called simply as
5042 as magic_<name>, even though they can be called simply as
5042 @<name>. This allows the special command @magic to gather
5043 @<name>. This allows the special command @magic to gather
5043 information automatically about all existing magic functions,
5044 information automatically about all existing magic functions,
5044 even if they are run-time user extensions, by parsing the shell
5045 even if they are run-time user extensions, by parsing the shell
5045 instance __dict__ looking for special magic_ names.
5046 instance __dict__ looking for special magic_ names.
5046
5047
5047 - mainloop: added *two* local namespace parameters. This allows
5048 - mainloop: added *two* local namespace parameters. This allows
5048 the class to differentiate between parameters which were there
5049 the class to differentiate between parameters which were there
5049 before and after command line initialization was processed. This
5050 before and after command line initialization was processed. This
5050 way, later @who can show things loaded at startup by the
5051 way, later @who can show things loaded at startup by the
5051 user. This trick was necessary to make session saving/reloading
5052 user. This trick was necessary to make session saving/reloading
5052 really work: ideally after saving/exiting/reloading a session,
5053 really work: ideally after saving/exiting/reloading a session,
5053 *everythin* should look the same, including the output of @who. I
5054 *everythin* should look the same, including the output of @who. I
5054 was only able to make this work with this double namespace
5055 was only able to make this work with this double namespace
5055 trick.
5056 trick.
5056
5057
5057 - added a header to the logfile which allows (almost) full
5058 - added a header to the logfile which allows (almost) full
5058 session restoring.
5059 session restoring.
5059
5060
5060 - prepend lines beginning with @ or !, with a and log
5061 - prepend lines beginning with @ or !, with a and log
5061 them. Why? !lines: may be useful to know what you did @lines:
5062 them. Why? !lines: may be useful to know what you did @lines:
5062 they may affect session state. So when restoring a session, at
5063 they may affect session state. So when restoring a session, at
5063 least inform the user of their presence. I couldn't quite get
5064 least inform the user of their presence. I couldn't quite get
5064 them to properly re-execute, but at least the user is warned.
5065 them to properly re-execute, but at least the user is warned.
5065
5066
5066 * Started ChangeLog.
5067 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now