For python 2.6, don't try to use Exception.message

bzr revid: p_christ@hol.gr-20090216183933-4w10k79yzal4fcfl
This commit is contained in:
P. Christeas 2009-02-16 20:39:33 +02:00
parent 086e4a29c6
commit f9f9fc5dde
1 changed files with 2 additions and 2 deletions

View File

@ -692,14 +692,14 @@ def ustr(value):
return unicode(value, getlocale()[1])
def exception_to_unicode(e):
if hasattr(e, 'message'):
if (sys.version_info[:2] < (2,6)) and hasattr(e, 'message'):
return ustr(e.message)
if hasattr(e, 'args'):
return "\n".join((ustr(a) for a in e.args))
try:
return ustr(e)
except:
return u"Unknow message"
return u"Unknown message"
# to be compatible with python 2.4