unicode decoding issue
Clemens Robbenhaar <robbenhaar-WaVJUzJ3u31Wk0Htik3J/[email protected]>
| Newsgroups | gmane.comp.web.zope.silva.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Andy,
> I can't recall whether Silva and related packages are python2.3 supported yet,
> but here's and issue I've had to deal with somewhere (can't recall exactly)
> in the Silva code, and well as in Formulator.Valitade.StringValidtor.validate
>
> This function checks to see if the value is supposed to be unicode, and
> blindlly converts it to unicode. Apparrently in python2.3 doing this:
> >>> unicode(u'','utf-8')
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: decoding Unicode is not supported
> >>>
Actually this behaviour is also in python2.1.3 ...
>
> The easy way to fix (for this formulator problem) is this:
> if field.get_value('unicode') and not isinstance(value,UnicodeType):
> # use acquisition to get encoding of form
> value = unicode(value, field.get_form_encoding())
>
> Would you like me to create submit an incident to the bugtracker for this?
Well, if You can puzzle together the details about how to produce the
issue. Actually Formulator already tries not to get unicode into the
"unicode" function, and Silva does the same, I guess ... thus most of
the time it should be a bug if that happens.
For the StringValidation this "cannot happen" at the point where You
try to work aroung it. Actually the validator should only be called with
unvalidated values from the request, and these are never unicode. This
if unicode falls in there, there must have been a bug somewhere earlier
in the code.
Catching unicode late in the Validator may work around that problem,
but its smells like defensive codeing which may swallow and obscure
bugs and as far as I know Martijn does not like to have such stuff in
the code.
Thus it would be nice to hear details about how to produce that issue.
Cheers,
Clemens
P.S. if there is a formulator issue, where should Andy file the bug
report? The SF issue tracker is dead, and there is not explicit issue
tracker for Formulator at issues.infrae.com ... setting up a new roundup
instance is not that involved, but of course it may need some
maintenance effort i.e. when upgrading ...