##// END OF EJS Templates
Merge from branches/0.7.1 into trunk, revs 1052-1057
vivainio -
r136:f7e4c31d
parent child
Show More
@@ -6,7 +6,7 Uses syntax highlighting for presenting the various information elements.
6 Similar in spirit to the inspect module, but all calls take a name argument to
6 Similar in spirit to the inspect module, but all calls take a name argument to
7 reference the name under which an object is being read.
7 reference the name under which an object is being read.
8
8
9 $Id: OInspect.py 1016 2006-01-14 00:54:23Z vivainio $
9 $Id: OInspect.py 1058 2006-01-22 14:30:01Z vivainio $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
@@ -234,8 +234,15 class Inspector:
234 self.noinfo('file',oname)
234 self.noinfo('file',oname)
235 else:
235 else:
236 # run contents of file through pager starting at line
236 # run contents of file through pager starting at line
237 # where the object is defined
237 # where the object is defined
238 page(self.format(open(inspect.getabsfile(obj)).read()),lineno)
238 ofile = inspect.getabsfile(obj)
239
240 if (ofile.endswith('.so') or ofile.endswith('.dll')):
241 print 'File %r is binary, not printing.' % ofile
242 else:
243 # Print only text files, not extension binaries.
244 page(self.format(open(ofile).read()),lineno)
245 #page(self.format(open(inspect.getabsfile(obj)).read()),lineno)
239
246
240 def pinfo(self,obj,oname='',formatter=None,info=None,detail_level=0):
247 def pinfo(self,obj,oname='',formatter=None,info=None,detail_level=0):
241 """Show detailed information about an object.
248 """Show detailed information about an object.
@@ -319,12 +326,18 class Inspector:
319 except: pass
326 except: pass
320
327
321 # Filename where object was defined
328 # Filename where object was defined
329 binary_file = False
322 try:
330 try:
323 file = inspect.getabsfile(obj)
331 fname = inspect.getabsfile(obj)
324 if file.endswith('<string>'):
332 if fname.endswith('<string>'):
325 file = 'Dynamically generated function. No source code available.'
333 fname = 'Dynamically generated function. No source code available.'
326 out.writeln(header('File:\t\t')+file)
334 if fname.endswith('.so') or fname.endswith('.dll'):
327 except: pass
335 binary_file = True
336 out.writeln(header('File:\t\t')+fname)
337 except:
338 # if anything goes wrong, we don't want to show source, so it's as
339 # if the file was binary
340 binary_file = True
328
341
329 # reconstruct the function definition and print it:
342 # reconstruct the function definition and print it:
330 defln = self.__getdef(obj,oname)
343 defln = self.__getdef(obj,oname)
@@ -341,8 +354,9 class Inspector:
341 # Flush the source cache because inspect can return out-of-date source
354 # Flush the source cache because inspect can return out-of-date source
342 linecache.checkcache()
355 linecache.checkcache()
343 try:
356 try:
344 source = self.format(inspect.getsource(obj))
357 if not binary_file:
345 out.write(header('Source:\n')+source.rstrip())
358 source = self.format(inspect.getsource(obj))
359 out.write(header('Source:\n')+source.rstrip())
346 except:
360 except:
347 if ds:
361 if ds:
348 out.writeln(header('Docstring:\n') + indent(ds))
362 out.writeln(header('Docstring:\n') + indent(ds))
@@ -1,7 +1,7
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Release data for the IPython project.
2 """Release data for the IPython project.
3
3
4 $Id: Release.py 1014 2006-01-13 19:16:41Z vivainio $"""
4 $Id: Release.py 1058 2006-01-22 14:30:01Z vivainio $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
7 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -22,9 +22,9 name = 'ipython'
22 # because bdist_rpm does not accept dashes (an RPM) convention, and
22 # because bdist_rpm does not accept dashes (an RPM) convention, and
23 # bdist_deb does not accept underscores (a Debian convention).
23 # bdist_deb does not accept underscores (a Debian convention).
24
24
25 version = '0.7.1.svn'
25 version = '0.7.2.svn'
26
26
27 revision = '$Revision: 1014 $'
27 revision = '$Revision: 1058 $'
28
28
29 description = "An enhanced interactive Python shell."
29 description = "An enhanced interactive Python shell."
30
30
@@ -4,7 +4,7
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 1005 2006-01-12 08:39:26Z fperez $"""
7 $Id: Shell.py 1058 2006-01-22 14:30:01Z 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>
@@ -18,13 +18,14 __author__ = '%s <%s>' % Release.authors['Fernando']
18 __license__ = Release.license
18 __license__ = Release.license
19
19
20 # Code begins
20 # Code begins
21 import __main__
22 import __builtin__
21 import __builtin__
22 import __main__
23 import Queue
23 import os
24 import os
24 import sys
25 import signal
25 import signal
26 import time
26 import sys
27 import threading
27 import threading
28 import time
28
29
29 import IPython
30 import IPython
30 from IPython import ultraTB
31 from IPython import ultraTB
@@ -272,9 +273,15 class MTInteractiveShell(InteractiveShell):
272 InteractiveShell.__init__(self,name,usage,rc,user_ns,
273 InteractiveShell.__init__(self,name,usage,rc,user_ns,
273 user_global_ns,banner2)
274 user_global_ns,banner2)
274
275
275 # Locking control variable
276 # Locking control variable. We need to use a norma lock, not an RLock
276 self.thread_ready = threading.Condition()
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...
279 self.thread_ready = threading.Condition(threading.Lock())
277
280
281 # A queue to hold the code to be executed. A scalar variable is NOT
282 # enough, because uses like macros cause reentrancy.
283 self.code_queue = Queue.Queue()
284
278 # Stuff to do at closing time
285 # Stuff to do at closing time
279 self._kill = False
286 self._kill = False
280 on_kill = kw.get('on_kill')
287 on_kill = kw.get('on_kill')
@@ -311,11 +318,16 class MTInteractiveShell(InteractiveShell):
311 return True
318 return True
312
319
313 # Case 3
320 # Case 3
314 # Store code in self, so the execution thread can handle it
321 # Store code in queue, so the execution thread can handle it.
315 self.thread_ready.acquire()
322
316 self.code_to_run = code
323 # Note that with macros and other applications, we MAY re-enter this
317 self.thread_ready.wait() # Wait until processed in timeout interval
324 # section, so we have to acquire the lock with non-blocking semantics,
318 self.thread_ready.release()
325 # else we deadlock.
326 got_lock = self.thread_ready.acquire(False)
327 self.code_queue.put(code)
328 if got_lock:
329 self.thread_ready.wait() # Wait until processed in timeout interval
330 self.thread_ready.release()
319
331
320 return False
332 return False
321
333
@@ -325,7 +337,7 class MTInteractiveShell(InteractiveShell):
325 Multithreaded wrapper around IPython's runcode()."""
337 Multithreaded wrapper around IPython's runcode()."""
326
338
327 # lock thread-protected stuff
339 # lock thread-protected stuff
328 self.thread_ready.acquire()
340 self.thread_ready.acquire(False)
329
341
330 # Install sigint handler
342 # Install sigint handler
331 try:
343 try:
@@ -342,10 +354,15 class MTInteractiveShell(InteractiveShell):
342 tokill()
354 tokill()
343 print >>Term.cout, 'Done.'
355 print >>Term.cout, 'Done.'
344
356
345 # Run pending code by calling parent class
357 # Flush queue of pending code by calling the run methood of the parent
346 if self.code_to_run is not None:
358 # class with all items which may be in the queue.
359 while 1:
360 try:
361 code_to_run = self.code_queue.get_nowait()
362 except Queue.Empty:
363 break
347 self.thread_ready.notify()
364 self.thread_ready.notify()
348 InteractiveShell.runcode(self,self.code_to_run)
365 InteractiveShell.runcode(self,code_to_run)
349
366
350 # We're done with thread-protected variables
367 # We're done with thread-protected variables
351 self.thread_ready.release()
368 self.thread_ready.release()
@@ -354,7 +371,7 class MTInteractiveShell(InteractiveShell):
354
371
355 def kill (self):
372 def kill (self):
356 """Kill the thread, returning when it has been shut down."""
373 """Kill the thread, returning when it has been shut down."""
357 self.thread_ready.acquire()
374 self.thread_ready.acquire(False)
358 self._kill = True
375 self._kill = True
359 self.thread_ready.release()
376 self.thread_ready.release()
360
377
@@ -366,7 +383,7 class MatplotlibShellBase:
366 inheritance hierarchy, so that it overrides the relevant methods."""
383 inheritance hierarchy, so that it overrides the relevant methods."""
367
384
368 def _matplotlib_config(self,name):
385 def _matplotlib_config(self,name):
369 """Return various items needed to setup the user's shell with matplotlib"""
386 """Return items needed to setup the user's shell with matplotlib"""
370
387
371 # Initialize matplotlib to interactive mode always
388 # Initialize matplotlib to interactive mode always
372 import matplotlib
389 import matplotlib
@@ -408,7 +425,6 class MatplotlibShellBase:
408 # overwrite the original matplotlib.use with our wrapper
425 # overwrite the original matplotlib.use with our wrapper
409 matplotlib.use = use
426 matplotlib.use = use
410
427
411
412 # This must be imported last in the matplotlib series, after
428 # This must be imported last in the matplotlib series, after
413 # backend/interactivity choices have been made
429 # backend/interactivity choices have been made
414 try:
430 try:
@@ -5,7 +5,7 General purpose utilities.
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
6 these things are also convenient when working at the command line.
6 these things are also convenient when working at the command line.
7
7
8 $Id: genutils.py 1032 2006-01-20 09:03:57Z fperez $"""
8 $Id: genutils.py 1058 2006-01-22 14:30:01Z vivainio $"""
9
9
10 #*****************************************************************************
10 #*****************************************************************************
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
@@ -213,14 +213,18 def debugp(expr,pre_msg=''):
213 """Print the value of an expression from the caller's frame.
213 """Print the value of an expression from the caller's frame.
214
214
215 Takes an expression, evaluates it in the caller's frame and prints both
215 Takes an expression, evaluates it in the caller's frame and prints both
216 the given expression and the resulting value. The input must be of a form
216 the given expression and the resulting value (as well as a debug mark
217 suitable for eval()."""
217 indicating the name of the calling function. The input must be of a form
218 suitable for eval().
219
220 An optional message can be passed, which will be prepended to the printed
221 expr->value pair."""
218
222
219 cf = sys._getframe(1)
223 cf = sys._getframe(1)
220 print '[DBG] %s %s -> %r' % (pre_msg,expr,
224 print '[DBG:%s] %s%s -> %r' % (cf.f_code.co_name,pre_msg,expr,
221 eval(expr,cf.f_globals,cf.f_locals))
225 eval(expr,cf.f_globals,cf.f_locals))
222
226
223 # deactivate it from here:
227 # deactivate it by uncommenting the following line, which makes it a no-op
224 def debugp(expr,pre_msg=''): pass
228 def debugp(expr,pre_msg=''): pass
225
229
226 #----------------------------------------------------------------------------
230 #----------------------------------------------------------------------------
@@ -6,7 +6,7 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 1038 2006-01-20 23:43:35Z vivainio $
9 $Id: iplib.py 1058 2006-01-22 14:30:01Z vivainio $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
@@ -274,7 +274,7 class InteractiveShell(object,Magic):
274 # intentional (or sensible), I don't know. In any case, the idea is
274 # 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
275 # that if you need to access the built-in namespace directly, you
276 # should start with "import __builtin__" (note, no 's') which will
276 # should start with "import __builtin__" (note, no 's') which will
277 # definitely give you a module. Yeah, it's somewhat confusing:-(.
277 # definitely give you a module. Yeah, it's somewhat confusing:-(.
278
278
279 if user_ns is None:
279 if user_ns is None:
280 # Set __name__ to __main__ to better match the behavior of the
280 # Set __name__ to __main__ to better match the behavior of the
@@ -1460,6 +1460,10 want to merge them back into the new files.""" % locals()
1460 self.readline_startup_hook(None)
1460 self.readline_startup_hook(None)
1461 self.write("\n")
1461 self.write("\n")
1462 self.exit()
1462 self.exit()
1463 except:
1464 # exceptions here are VERY RARE, but they can be triggered
1465 # asynchronously by signal handlers, for example.
1466 self.showtraceback()
1463 else:
1467 else:
1464 more = self.push(line)
1468 more = self.push(line)
1465
1469
@@ -1550,7 +1554,8 want to merge them back into the new files.""" % locals()
1550 def autoindent_update(self,line):
1554 def autoindent_update(self,line):
1551 """Keep track of the indent level."""
1555 """Keep track of the indent level."""
1552
1556
1553 debugp('line','autoindent_update:')
1557 #import traceback; traceback.print_stack() # dbg
1558 debugp('line')
1554 debugp('self.indent_current_nsp')
1559 debugp('self.indent_current_nsp')
1555 if self.autoindent:
1560 if self.autoindent:
1556 if line:
1561 if line:
@@ -1761,7 +1766,9 want to merge them back into the new files.""" % locals()
1761 debugp('self.indent_current_nsp')
1766 debugp('self.indent_current_nsp')
1762
1767
1763 debugp('line')
1768 debugp('line')
1764 return self.prefilter(line,continue_prompt)
1769 lineout = self.prefilter(line,continue_prompt)
1770 debugp('lineout')
1771 return lineout
1765
1772
1766 def split_user_input(self,line):
1773 def split_user_input(self,line):
1767 """Split user input into pre-char, function part and rest."""
1774 """Split user input into pre-char, function part and rest."""
@@ -1938,8 +1945,9 want to merge them back into the new files.""" % locals()
1938 # of a size different to the indent level, will exit the input loop.
1945 # of a size different to the indent level, will exit the input loop.
1939
1946
1940 if (continue_prompt and self.autoindent and line.isspace() and
1947 if (continue_prompt and self.autoindent and line.isspace() and
1941 (line != self.indent_current_str() or
1948 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
1942 (self.buffer[-1]).isspace() )):
1949 (self.buffer[-1]).isspace() )):
1950 #print 'reset line' # dbg
1943 line = ''
1951 line = ''
1944
1952
1945 self.log(line,continue_prompt)
1953 self.log(line,continue_prompt)
@@ -9,7 +9,7 Requirements
9
9
10 IPython runs under (as far as the Windows family is concerned):
10 IPython runs under (as far as the Windows family is concerned):
11
11
12 - Windows XP (I think WinNT/2000 are ok): works well. It needs:
12 - Windows XP, 2000 (and probably WinNT): works well. It needs:
13
13
14 * PyWin32, the win32 Python extensions from
14 * PyWin32, the win32 Python extensions from
15 http://starship.python.net/crew/mhammond.
15 http://starship.python.net/crew/mhammond.
@@ -33,10 +33,18 Installation
33 Double-click the supplied .exe installer file. If all goes well, that's all
33 Double-click the supplied .exe installer file. If all goes well, that's all
34 you need to do. You should now have an IPython entry in your Start Menu.
34 you need to do. You should now have an IPython entry in your Start Menu.
35
35
36
37 Installation from source distribution
38 -------------------------------------
39
36 In case the automatic installer does not work for some reason, you can
40 In case the automatic installer does not work for some reason, you can
37 download the ipython-XXX.tar.gz file, which contains the full IPython source
41 download the ipython-XXX.tar.gz file, which contains the full IPython source
38 distribution (the popular WinZip can read .tar.gz files). After uncompressing
42 distribution (the popular WinZip can read .tar.gz files).
39 the archive, you can install it at a command terminal just like any other
43
40 Python module, by using python setup.py install'. After this completes, you
44 After uncompressing the archive, you can install it at a command terminal just
41 can run the supplied win32_manual_post_install.py script which will add
45 like any other Python module, by using python setup.py install'. After this
42 the relevant shortcuts to your startup menu.
46 completes, you can run the supplied win32_manual_post_install.py script which
47 will add the relevant shortcuts to your startup menu.
48
49 Optionally, you may skip installation altogether and just launch "ipython.py"
50 from the root folder of the extracted source distribution.
@@ -1,3 +1,38
1 2006-01-22 Ville Vainio <vivainio@gmail.com>
2
3 * Merge from branches/0.7.1 into trunk, revs 1052-1057
4
5 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
6
7 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
8 %pfile foo would print the file for foo even if it was a binary.
9 Now, extensions '.so' and '.dll' are skipped.
10
11 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
12 bug, where macros would fail in all threaded modes. I'm not 100%
13 sure, so I'm going to put out an rc instead of making a release
14 today, and wait for feedback for at least a few days.
15
16 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
17 it...) the handling of pasting external code with autoindent on.
18 To get out of a multiline input, the rule will appear for most
19 users unchanged: two blank lines or change the indent level
20 proposed by IPython. But there is a twist now: you can
21 add/subtract only *one or two spaces*. If you add/subtract three
22 or more (unless you completely delete the line), IPython will
23 accept that line, and you'll need to enter a second one of pure
24 whitespace. I know it sounds complicated, but I can't find a
25 different solution that covers all the cases, with the right
26 heuristics. Hopefully in actual use, nobody will really notice
27 all these strange rules and things will 'just work'.
28
29 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
30
31 * IPython/iplib.py (interact): catch exceptions which can be
32 triggered asynchronously by signal handlers. Thanks to an
33 automatic crash report, submitted by Colin Kingsley
34 <tercel-AT-gentoo.org>.
35
1 2006-01-20 Ville Vainio <vivainio@gmail.com>
36 2006-01-20 Ville Vainio <vivainio@gmail.com>
2
37
3 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
38 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
General Comments 0
You need to be logged in to leave comments. Login now