Re: formencode.api.Invalid class lack __unicode__ method
Ian Bicking <[email protected]> Wed, 29 Oct 2008 11:32:53 -0500
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
Added in r3638 (I think if you use e.unpack_errors() it shouldn't have this problem, though) Marcin Stępnicki wrote: > 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. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ FormEncode-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/formencode-discuss