~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-21 19:05:37 UTC
  • mto: This revision was merged to the branch mainline in revision 1953.
  • Revision ID: john@arbash-meinel.com-20060821190537-92913a2a33a84176
Make BzrNewError always return a str object

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
 
127
127
    def __str__(self):
128
128
        try:
129
 
            return self.__doc__ % self.__dict__
 
129
            # __str__() should always return a 'str' object
 
130
            # never a 'unicode' object.
 
131
            s = self.__doc__ % self.__dict__
 
132
            if isinstance(s, unicode):
 
133
                return s.encode('utf8')
 
134
            return s
130
135
        except (NameError, ValueError, KeyError), e:
131
136
            return 'Unprintable exception %s: %s' \
132
137
                % (self.__class__.__name__, str(e))