##// 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 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 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 136 ds = '%s\n%s' % (ds,ds2)
137 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 161 # Class definitions
141 162
@@ -262,7 +283,7 b' class Inspector:'
262 283 # Flush the source cache because inspect can return out-of-date source
263 284 linecache.checkcache()
264 285 try:
265 src = inspect.getsource(obj)
286 src = getsource(obj)
266 287 except:
267 288 self.noinfo('source',oname)
268 289 else:
@@ -402,15 +423,16 b' class Inspector:'
402 423 linecache.checkcache()
403 424 source_success = False
404 425 try:
405 if not binary_file:
406 source = self.format(inspect.getsource(obj))
426 source = self.format(getsource(obj,binary_file))
427 if source:
407 428 out.write(header('Source:\n')+source.rstrip())
408 429 source_success = True
409 except:
430 except Exception, msg:
410 431 pass
411 432
412 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 437 # Constructor docstring for classes
416 438 if obj_type is types.ClassType:
@@ -2,7 +2,7 b''
2 2 """
3 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 8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -244,7 +244,7 b' class BasePrompt:'
244 244 ('${self.sep}${self.col_p}',
245 245 multiple_replace(prompt_specials, self.p_template),
246 246 '${self.col_norm}'),self.cache.user_ns,loc)
247
247
248 248 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
249 249 self.p_template),
250 250 self.cache.user_ns,loc)
@@ -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 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,12 +665,14 b' class InteractiveShell(object,Magic):'
665 665 except AttributeError:
666 666 pass
667 667
668 # I don't like assigning globally to sys, because it means when embedding
669 # instances, each embedded instance overrides the previous choice. But
670 # sys.displayhook seems to be called internally by exec, so I don't see a
671 # way around it.
668 # I don't like assigning globally to sys, because it means when
669 # embedding instances, each embedded instance overrides the previous
670 # choice. But sys.displayhook seems to be called internally by exec,
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 674 sys.displayhook = self.outputcache
673
675
674 676 # Set user colors (don't do it in the constructor above so that it
675 677 # doesn't crash if colors option is invalid)
676 678 self.magic_colors(rc.colors)
@@ -136,6 +136,14 b' class InteractiveRunner(object):'
136 136
137 137 c = pexpect.spawn(self.program,self.args,timeout=None)
138 138 c.delaybeforesend = self.delaybeforesend
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)
139 147
140 148 prompts = c.compile_pattern_list(self.prompts)
141 149
@@ -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 13 2006-10-28 Ville Vainio <vivainio@gmail.com>
2 14
3 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