Simple unicode-safe version of str(exception)?
Russell E. Owen
rowen at cesmail.net
Mon Apr 28 15:28:38 EDT 2008
I have code like this:
except Exception, e:
self.setState(self.Failed, str(e))
which fails if the exception contains a unicode argument.
I did, of course, try unicode(e) but that fails.
The following works, but seems rather messy:
except Exception, e:
errStr = ",".join([unicode(s) for s in f.args])
self.setState(self.Failed, errStr)
Is there a simpler solution that works in Python 2.3-2.5?
-- Russell
More information about the Python-list
mailing list