##// END OF EJS Templates
- Work around pexcept buglet which causes wraparound problems with long...
fptest -
Show More
@@ -6,7 +6,7 b' 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 1625 2006-08-12 10:34:44Z vivainio $
9 $Id: OInspect.py 1850 2006-10-28 19:48:13Z fptest $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
@@ -136,6 +136,27 b' def getdoc(obj):'
136 ds = '%s\n%s' % (ds,ds2)
136 ds = '%s\n%s' % (ds,ds2)
137 return ds
137 return ds
138
138
139 def getsource(obj,is_binary=False):
140 """Wrapper around inspect.getsource.
141
142 This can be modified by other projects to provide customized source
143 extraction.
144
145 Inputs:
146
147 - obj: an object whose source code we will attempt to extract.
148
149 Optional inputs:
150
151 - is_binary: whether the object is known to come from a binary source.
152 This implementation will skip returning any output for binary objects, but
153 custom extractors may know how to meaninfully process them."""
154
155 if is_binary:
156 return None
157 else:
158 return inspect.getsource(obj)
159
139 #****************************************************************************
160 #****************************************************************************
140 # Class definitions
161 # Class definitions
141
162
@@ -262,7 +283,7 b' class Inspector:'
262 # Flush the source cache because inspect can return out-of-date source
283 # Flush the source cache because inspect can return out-of-date source
263 linecache.checkcache()
284 linecache.checkcache()
264 try:
285 try:
265 src = inspect.getsource(obj)
286 src = getsource(obj)
266 except:
287 except:
267 self.noinfo('source',oname)
288 self.noinfo('source',oname)
268 else:
289 else:
@@ -402,15 +423,16 b' class Inspector:'
402 linecache.checkcache()
423 linecache.checkcache()
403 source_success = False
424 source_success = False
404 try:
425 try:
405 if not binary_file:
426 source = self.format(getsource(obj,binary_file))
406 source = self.format(inspect.getsource(obj))
427 if source:
407 out.write(header('Source:\n')+source.rstrip())
428 out.write(header('Source:\n')+source.rstrip())
408 source_success = True
429 source_success = True
409 except:
430 except Exception, msg:
410 pass
431 pass
411
432
412 if ds and not source_success:
433 if ds and not source_success:
413 out.writeln(header('Docstring [source file open failed]:\n') + indent(ds))
434 out.writeln(header('Docstring [source file open failed]:\n')
435 + indent(ds))
414
436
415 # Constructor docstring for classes
437 # Constructor docstring for classes
416 if obj_type is types.ClassType:
438 if obj_type is types.ClassType:
@@ -2,7 +2,7 b''
2 """
2 """
3 Classes for handling input/output prompts.
3 Classes for handling input/output prompts.
4
4
5 $Id: Prompts.py 1366 2006-06-15 19:45:50Z vivainio $"""
5 $Id: Prompts.py 1850 2006-10-28 19:48:13Z fptest $"""
6
6
7 #*****************************************************************************
7 #*****************************************************************************
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -6,7 +6,7 b' 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 1828 2006-10-16 02:04:33Z fptest $
9 $Id: iplib.py 1850 2006-10-28 19:48:13Z fptest $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
@@ -665,10 +665,12 b' class InteractiveShell(object,Magic):'
665 except AttributeError:
665 except AttributeError:
666 pass
666 pass
667
667
668 # I don't like assigning globally to sys, because it means when embedding
668 # I don't like assigning globally to sys, because it means when
669 # instances, each embedded instance overrides the previous choice. But
669 # embedding instances, each embedded instance overrides the previous
670 # sys.displayhook seems to be called internally by exec, so I don't see a
670 # choice. But sys.displayhook seems to be called internally by exec,
671 # way around it.
671 # so I don't see a way around it. We first save the original and then
672 # overwrite it.
673 self.sys_displayhook = sys.displayhook
672 sys.displayhook = self.outputcache
674 sys.displayhook = self.outputcache
673
675
674 # Set user colors (don't do it in the constructor above so that it
676 # Set user colors (don't do it in the constructor above so that it
@@ -137,6 +137,14 b' class InteractiveRunner(object):'
137 c = pexpect.spawn(self.program,self.args,timeout=None)
137 c = pexpect.spawn(self.program,self.args,timeout=None)
138 c.delaybeforesend = self.delaybeforesend
138 c.delaybeforesend = self.delaybeforesend
139
139
140 # pexpect hard-codes the terminal size as (24,80) (rows,columns).
141 # This causes problems because any line longer than 80 characters gets
142 # completely overwrapped on the printed outptut (even though
143 # internally the code runs fine). We reset this to 99 rows X 200
144 # columns (arbitrarily chosen), which should avoid problems in all
145 # reasonable cases.
146 c.setwinsize(99,200)
147
140 prompts = c.compile_pattern_list(self.prompts)
148 prompts = c.compile_pattern_list(self.prompts)
141
149
142 prompt_idx = c.expect_list(prompts)
150 prompt_idx = c.expect_list(prompts)
@@ -1,3 +1,15 b''
1 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/genutils.py (arg_split): moved to genutils, since it's a
4 pretty generic function and useful for other things.
5
6 * IPython/OInspect.py (getsource): Add customizable source
7 extractor. After a request/patch form W. Stein (SAGE).
8
9 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
10 window size to a more reasonable value from what pexpect does,
11 since their choice causes wrapping bugs with long input lines.
12
1 2006-10-28 Ville Vainio <vivainio@gmail.com>
13 2006-10-28 Ville Vainio <vivainio@gmail.com>
2
14
3 * Magic.py (%run): Save and restore the readline history from
15 * Magic.py (%run): Save and restore the readline history from
General Comments 0
You need to be logged in to leave comments. Login now