Marcin Stępnicki
2008-10-29 11:12:48 UTC
I've noticed that error messages which are unicode objects give the
following error when used in htmlfill:
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0119' in
position 5: ordinal not in range(128)
In rewritingparser.html_quote there is a fragment which checks if
given object has __unicode__ attribute:
(...)
else:
if hasattr(v, '__unicode__'):
v = unicode(v)
but objects of 'formencode.api.Invalid' class don't have it, so the following:
(...)
else:
v = str(v)
fails with UnicodeDecodeError.
Adding:
def __unicode__(self):
val = self.msg
return val
to formencode.api.Invalid fixes the problem for me.
Regards,
Marcin
following error when used in htmlfill:
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0119' in
position 5: ordinal not in range(128)
In rewritingparser.html_quote there is a fragment which checks if
given object has __unicode__ attribute:
(...)
else:
if hasattr(v, '__unicode__'):
v = unicode(v)
but objects of 'formencode.api.Invalid' class don't have it, so the following:
(...)
else:
v = str(v)
fails with UnicodeDecodeError.
Adding:
def __unicode__(self):
val = self.msg
return val
to formencode.api.Invalid fixes the problem for me.
Regards,
Marcin