diff --git a/IPython/ultraTB.py b/IPython/ultraTB.py index 20e6f4c..db50c48 100644 --- a/IPython/ultraTB.py +++ b/IPython/ultraTB.py @@ -60,7 +60,7 @@ You can implement other color schemes easily, the syntax is fairly self-explanatory. Please send back new schemes you develop to the author for possible inclusion in future releases. -$Id: ultraTB.py 951 2005-12-25 00:57:24Z fperez $""" +$Id: ultraTB.py 954 2005-12-26 19:40:50Z fperez $""" #***************************************************************************** # Copyright (C) 2001 Nathaniel Gray @@ -550,7 +550,18 @@ class VerboseTB(TBTools): exception = ['%s%s%s: %s' % (Colors.excName, etype_str, ColorsNormal, evalue_str)] if type(evalue) is types.InstanceType: - names = [w for w in dir(evalue) if isinstance(w, basestring)] + try: + names = [w for w in dir(evalue) if isinstance(w, basestring)] + except: + # Every now and then, an object with funny inernals blows up + # when dir() is called on it. We do the best we can to report + # the problem and continue + _m = '%sException reporting error (object with broken dir())%s:' + exception.append(_m % (Colors.excName,ColorsNormal)) + etype_str,evalue_str = map(str,sys.exc_info()[:2]) + exception.append('%s%s%s: %s' % (Colors.excName,etype_str, + ColorsNormal, evalue_str)) + names = [] for name in names: value = text_repr(getattr(evalue, name)) exception.append('\n%s%s = %s' % (indent, name, value)) diff --git a/doc/ChangeLog b/doc/ChangeLog index 5b7411d..45d96c3 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,8 @@ 2005-12-26 Fernando Perez + * IPython/ultraTB.py (VerboseTB.text): harden reporting against + failures for objects which break when dir() is called on them. + * IPython/FlexCompleter.py (Completer.__init__): Added support for distinct local and global namespaces in the completer API. This change allows us top properly handle completion with distinct