Rev 2457: Fix the 'Unprintable error' message display to use the repr of the in http://people.ubuntu.com/~robertc/baz2.0/integration

Robert Collins robertc at robertcollins.net
Thu Apr 26 02:48:50 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/integration

------------------------------------------------------------
revno: 2457
revision-id: robertc at robertcollins.net-20070426014829-znbzqzsk1gq68xqh
parent: pqm at pqm.ubuntu.com-20070425143732-c4aa489eylhhfnzg
committer: Robert Collins <robertc at robertcollins.net>
branch nick: integration
timestamp: Thu 2007-04-26 11:48:29 +1000
message:
  Fix the 'Unprintable error' message display to use the repr of the
  exception that prevented printing the error because the str value for it
  is often not useful in debugging (e.g.  KeyError('foo') has a str() of
  'foo' but a repr of 'KeyError('foo')' which is much more useful.
  (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
=== modified file 'NEWS'
--- a/NEWS	2007-04-25 14:37:32 +0000
+++ b/NEWS	2007-04-26 01:48:29 +0000
@@ -159,6 +159,12 @@
       sense to generate them from a ``Branch`` object.
       (John Arbash Meinel)
 
+    * Fix the 'Unprintable error' message display to use the repr of the 
+      exception that prevented printing the error because the str value
+      for it is often not useful in debugging (e.g. KeyError('foo') has a
+      str() of 'foo' but a repr of 'KeyError('foo')' which is much more
+      useful. (Robert Collins)
+
   BUGFIXES:
 
     * Don't fail bundle selftest if email has 'two' embedded.  

=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2007-04-25 06:50:22 +0000
+++ b/bzrlib/errors.py	2007-04-26 01:48:29 +0000
@@ -102,11 +102,11 @@
                     return s.encode('utf8')
                 return s
         except (AttributeError, TypeError, NameError, ValueError, KeyError), e:
-            return 'Unprintable exception %s: dict=%r, fmt=%r, error=%s' \
+            return 'Unprintable exception %s: dict=%r, fmt=%r, error=%r' \
                 % (self.__class__.__name__,
                    self.__dict__,
                    getattr(self, '_fmt', None),
-                   str(e))
+                   e)
 
     def _get_format_string(self):
         """Return format string for this exception or None"""
@@ -154,9 +154,9 @@
                 return s.encode('utf8')
             return s
         except (TypeError, NameError, ValueError, KeyError), e:
-            return 'Unprintable exception %s(%r): %s' \
+            return 'Unprintable exception %s(%r): %r' \
                 % (self.__class__.__name__,
-                   self.__dict__, str(e))
+                   self.__dict__, e)
 
 
 class AlreadyBuilding(BzrError):



More information about the bazaar-commits mailing list