Simple unicode-safe version of str(exception)?
Russell E. Owen
rowen at cesmail.net
Tue Apr 29 12:10:00 EDT 2008
In article <67on2nF2ol856U1 at mid.individual.net>,
Bjoern Schliessmann <usenet-mail-0306.20.chr0n0ss at spamgourmet.com>
wrote:
> "Martin v. Löwis" wrote:
>
> > e is an exception object, not a Unicode object.
>
> Er, sure, thanks for pointing that out. At first sight he should
> substitute "e" with "e.message" then since he tries to convert to
> string (for display?).
No. e.message is only set if the exeption object receives exactly one
argument.
That is why my replacement code reads:
errStr = ",".join([unicode(s) for s in f.args])
self.setState(self.Failed, errStr)
(where e is an Exception of some kind)
Notice that I'm iterating over the args. But again, this is far messier
than:
self.setState(self.Failed, str(e)
So...to repeat the original question, is there any simpler unicode-safe
replacement for str(exception)?
-- Russell
More information about the Python-list
mailing list