##// END OF EJS Templates
Fix http://www.scipy.net/roundup/ipython/issue53, test added (though it must...
fperez -
Show More
@@ -0,0 +1,16 b''
1 """This should be run directly from ipython, and it should NOT crash.
2
3 It can't currently be run via runtests b/c exception handling changes there,
4 and this is precisely testing exception handling problems."""
5
6 ipmagic('xmode verbose')
7
8 src = """
9 class suck(object):
10 def __repr__(self):
11 raise ValueError("who needs repr anyway")
12
13 suck()
14 """
15
16 __IPYTHON__.runlines(src)
@@ -60,7 +60,7 b' You can implement other color schemes easily, the syntax is fairly'
60 60 self-explanatory. Please send back new schemes you develop to the author for
61 61 possible inclusion in future releases.
62 62
63 $Id: ultraTB.py 1005 2006-01-12 08:39:26Z fperez $"""
63 $Id: ultraTB.py 1154 2006-02-11 23:20:05Z fperez $"""
64 64
65 65 #*****************************************************************************
66 66 # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu>
@@ -394,12 +394,38 b' class VerboseTB(TBTools):'
394 394 Colors = self.Colors # just a shorthand + quicker name lookup
395 395 ColorsNormal = Colors.Normal # used a lot
396 396 indent = ' '*INDENT_SIZE
397 text_repr = pydoc.text.repr
398 397 exc = '%s%s%s' % (Colors.excName, str(etype), ColorsNormal)
399 398 em_normal = '%s\n%s%s' % (Colors.valEm, indent,ColorsNormal)
400 399 undefined = '%sundefined%s' % (Colors.em, ColorsNormal)
401 400
402 401 # some internal-use functions
402 def text_repr(value):
403 """Hopefully pretty robust repr equivalent."""
404 # this is pretty horrible but should always return *something*
405 try:
406 return pydoc.text.repr(value)
407 except KeyboardInterrupt:
408 raise
409 except:
410 try:
411 return repr(value)
412 except KeyboardInterrupt:
413 raise
414 except:
415 try:
416 # all still in an except block so we catch
417 # getattr raising
418 name = getattr(value, '__name__', None)
419 if name:
420 # ick, recursion
421 return text_repr(name)
422 klass = getattr(value, '__class__', None)
423 if klass:
424 return '%s instance' % text_repr(klass)
425 except KeyboardInterrupt:
426 raise
427 except:
428 return 'UNRECOVERABLE REPR FAILURE'
403 429 def eqrepr(value, repr=text_repr): return '=%s' % repr(value)
404 430 def nullrepr(value, repr=text_repr): return ''
405 431
@@ -1,3 +1,9 b''
1 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
4 contributed by marienz to close
5 http://www.scipy.net/roundup/ipython/issue53.
6
1 7 2006-02-10 Ville Vainio <vivainio@gmail.com>
2 8
3 9 * genutils.py: getoutput now works in win32 too
General Comments 0
You need to be logged in to leave comments. Login now