##// END OF EJS Templates
Merge from branches/0.7.1 into trunk, revs 1052-1057
vivainio -
Show More
@@ -6,7 +6,7 b' Uses syntax highlighting for presenting the various information elements.'
6 6 Similar in spirit to the inspect module, but all calls take a name argument to
7 7 reference the name under which an object is being read.
8 8
9 $Id: OInspect.py 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 b' class Inspector:'
234 234 self.noinfo('file',oname)
235 235 else:
236 236 # run contents of file through pager starting at line
237 # where the object is defined
238 page(self.format(open(inspect.getabsfile(obj)).read()),lineno)
237 # where the object is defined
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 247 def pinfo(self,obj,oname='',formatter=None,info=None,detail_level=0):
241 248 """Show detailed information about an object.
@@ -319,12 +326,18 b' class Inspector:'
319 326 except: pass
320 327
321 328 # Filename where object was defined
329 binary_file = False
322 330 try:
323 file = inspect.getabsfile(obj)
324 if file.endswith('<string>'):
325 file = 'Dynamically generated function. No source code available.'
326 out.writeln(header('File:\t\t')+file)
327 except: pass
331 fname = inspect.getabsfile(obj)
332 if fname.endswith('<string>'):
333 fname = 'Dynamically generated function. No source code available.'
334 if fname.endswith('.so') or fname.endswith('.dll'):
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 342 # reconstruct the function definition and print it:
330 343 defln = self.__getdef(obj,oname)
@@ -341,8 +354,9 b' class Inspector:'
341 354 # Flush the source cache because inspect can return out-of-date source
342 355 linecache.checkcache()
343 356 try:
344 source = self.format(inspect.getsource(obj))
345 out.write(header('Source:\n')+source.rstrip())
357 if not binary_file:
358 source = self.format(inspect.getsource(obj))
359 out.write(header('Source:\n')+source.rstrip())
346 360 except:
347 361 if ds:
348 362 out.writeln(header('Docstring:\n') + indent(ds))
@@ -1,7 +1,7 b''
1 1 # -*- coding: utf-8 -*-
2 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 7 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -22,9 +22,9 b" name = 'ipython'"
22 22 # because bdist_rpm does not accept dashes (an RPM) convention, and
23 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 29 description = "An enhanced interactive Python shell."
30 30
@@ -4,7 +4,7 b''
4 4 All the matplotlib support code was co-developed with John Hunter,
5 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 10 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -18,13 +18,14 b" __author__ = '%s <%s>' % Release.authors['Fernando']"
18 18 __license__ = Release.license
19 19
20 20 # Code begins
21 import __main__
22 21 import __builtin__
22 import __main__
23 import Queue
23 24 import os
24 import sys
25 25 import signal
26 import time
26 import sys
27 27 import threading
28 import time
28 29
29 30 import IPython
30 31 from IPython import ultraTB
@@ -272,9 +273,15 b' class MTInteractiveShell(InteractiveShell):'
272 273 InteractiveShell.__init__(self,name,usage,rc,user_ns,
273 274 user_global_ns,banner2)
274 275
275 # Locking control variable
276 self.thread_ready = threading.Condition()
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
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 285 # Stuff to do at closing time
279 286 self._kill = False
280 287 on_kill = kw.get('on_kill')
@@ -311,11 +318,16 b' class MTInteractiveShell(InteractiveShell):'
311 318 return True
312 319
313 320 # Case 3
314 # Store code in self, so the execution thread can handle it
315 self.thread_ready.acquire()
316 self.code_to_run = code
317 self.thread_ready.wait() # Wait until processed in timeout interval
318 self.thread_ready.release()
321 # Store code in queue, so the execution thread can handle it.
322
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,
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 332 return False
321 333
@@ -325,7 +337,7 b' class MTInteractiveShell(InteractiveShell):'
325 337 Multithreaded wrapper around IPython's runcode()."""
326 338
327 339 # lock thread-protected stuff
328 self.thread_ready.acquire()
340 self.thread_ready.acquire(False)
329 341
330 342 # Install sigint handler
331 343 try:
@@ -342,10 +354,15 b' class MTInteractiveShell(InteractiveShell):'
342 354 tokill()
343 355 print >>Term.cout, 'Done.'
344 356
345 # Run pending code by calling parent class
346 if self.code_to_run is not None:
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.
359 while 1:
360 try:
361 code_to_run = self.code_queue.get_nowait()
362 except Queue.Empty:
363 break
347 364 self.thread_ready.notify()
348 InteractiveShell.runcode(self,self.code_to_run)
365 InteractiveShell.runcode(self,code_to_run)
349 366
350 367 # We're done with thread-protected variables
351 368 self.thread_ready.release()
@@ -354,7 +371,7 b' class MTInteractiveShell(InteractiveShell):'
354 371
355 372 def kill (self):
356 373 """Kill the thread, returning when it has been shut down."""
357 self.thread_ready.acquire()
374 self.thread_ready.acquire(False)
358 375 self._kill = True
359 376 self.thread_ready.release()
360 377
@@ -366,7 +383,7 b' class MatplotlibShellBase:'
366 383 inheritance hierarchy, so that it overrides the relevant methods."""
367 384
368 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 388 # Initialize matplotlib to interactive mode always
372 389 import matplotlib
@@ -408,7 +425,6 b' class MatplotlibShellBase:'
408 425 # overwrite the original matplotlib.use with our wrapper
409 426 matplotlib.use = use
410 427
411
412 428 # This must be imported last in the matplotlib series, after
413 429 # backend/interactivity choices have been made
414 430 try:
@@ -5,7 +5,7 b' General purpose utilities.'
5 5 This is a grab-bag of stuff I find useful in most programs I write. Some of
6 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 11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
@@ -213,14 +213,18 b" def debugp(expr,pre_msg=''):"
213 213 """Print the value of an expression from the caller's frame.
214 214
215 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
217 suitable for eval()."""
216 the given expression and the resulting value (as well as a debug mark
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 223 cf = sys._getframe(1)
220 print '[DBG] %s %s -> %r' % (pre_msg,expr,
221 eval(expr,cf.f_globals,cf.f_locals))
224 print '[DBG:%s] %s%s -> %r' % (cf.f_code.co_name,pre_msg,expr,
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 228 def debugp(expr,pre_msg=''): pass
225 229
226 230 #----------------------------------------------------------------------------
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.'
6 6
7 7 This file contains all the classes and helper functions specific to IPython.
8 8
9 $Id: iplib.py 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 b' class InteractiveShell(object,Magic):'
274 274 # intentional (or sensible), I don't know. In any case, the idea is
275 275 # that if you need to access the built-in namespace directly, you
276 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 279 if user_ns is None:
280 280 # Set __name__ to __main__ to better match the behavior of the
@@ -1460,6 +1460,10 b' want to merge them back into the new files.""" % locals()'
1460 1460 self.readline_startup_hook(None)
1461 1461 self.write("\n")
1462 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 1467 else:
1464 1468 more = self.push(line)
1465 1469
@@ -1550,7 +1554,8 b' want to merge them back into the new files.""" % locals()'
1550 1554 def autoindent_update(self,line):
1551 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 1559 debugp('self.indent_current_nsp')
1555 1560 if self.autoindent:
1556 1561 if line:
@@ -1761,7 +1766,9 b' want to merge them back into the new files.""" % locals()'
1761 1766 debugp('self.indent_current_nsp')
1762 1767
1763 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 1773 def split_user_input(self,line):
1767 1774 """Split user input into pre-char, function part and rest."""
@@ -1938,8 +1945,9 b' want to merge them back into the new files.""" % locals()'
1938 1945 # of a size different to the indent level, will exit the input loop.
1939 1946
1940 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 1949 (self.buffer[-1]).isspace() )):
1950 #print 'reset line' # dbg
1943 1951 line = ''
1944 1952
1945 1953 self.log(line,continue_prompt)
@@ -9,7 +9,7 b' Requirements'
9 9
10 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 14 * PyWin32, the win32 Python extensions from
15 15 http://starship.python.net/crew/mhammond.
@@ -33,10 +33,18 b' Installation'
33 33 Double-click the supplied .exe installer file. If all goes well, that's all
34 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 40 In case the automatic installer does not work for some reason, you can
37 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
39 the archive, you can install it at a command terminal just like any other
40 Python module, by using python setup.py install'. After this completes, you
41 can run the supplied win32_manual_post_install.py script which will add
42 the relevant shortcuts to your startup menu.
42 distribution (the popular WinZip can read .tar.gz files).
43
44 After uncompressing the archive, you can install it at a command terminal just
45 like any other Python module, by using python setup.py install'. After this
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 b''
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 36 2006-01-20 Ville Vainio <vivainio@gmail.com>
2 37
3 38 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
General Comments 0
You need to be logged in to leave comments. Login now