mirror of
https://github.com/beetbox/beets.git
synced 2025-12-27 02:52:33 +01:00
handle non-Unicode exception strings correctly
This commit is contained in:
parent
4f5c5d4e4f
commit
22d17aaa30
1 changed files with 4 additions and 2 deletions
|
|
@ -59,12 +59,14 @@ class HumanReadableException(Exception):
|
|||
|
||||
def _reasonstr(self):
|
||||
"""Get the reason as a string."""
|
||||
if isinstance(self.reason, basestring):
|
||||
if isinstance(self.reason, unicode):
|
||||
return self.reason
|
||||
elif isinstance(self.reason, basestring): # Byte string.
|
||||
return self.reason.decode('utf8', 'ignore')
|
||||
elif hasattr(self.reason, 'strerror'): # i.e., EnvironmentError
|
||||
return self.reason.strerror
|
||||
else:
|
||||
return u'"{0}"'.format(self.reason)
|
||||
return u'"{0}"'.format(unicode(self.reason))
|
||||
|
||||
def get_message(self):
|
||||
"""Create the human-readable description of the error, sans
|
||||
|
|
|
|||
Loading…
Reference in a new issue