[Zope3-dev] Re: [Zope3-checkins] CVS: Zope3/src/zope/app/content -
folder.py:1.3
Florent Guillaume
fg@nuxeo.com
17 Jan 2003 21:06:33 +0100
On Fri, 2003-01-17 at 20:18, R. David Murray wrote:
> >> + try: unicode(name)
> >> + except UnicodeDecodeError:
> >> + raise TypeError("Name may not contain non-7-bit-ascii codes")
>
> >Why is that? Is this only temporary until we have Unicode encoding in URLs?
> >From my understanding of the discussions we had sometime ago, it is
> >imperative to allow any Unicode character (except '/') in a name.
>
> The error message is broken, not the code.
>
> unicode(name) will not raise an error if name is valid unicode. If
> name is ASCII, it will raise a TypeError if name contains non-7-bit
> ascii. We need to prevent non-7-bit ascii precisely to support
> unicode.
>
> I've checked in an imporovement (I hope it's an improvement <grin>) to
> the error message.
Ah ok, sorry I jumped the gun.
Corner case though: if the user has managed to set his default encoding
to something like latin-1, you'll still store a non-unicode string with
non-7-bit characters.
How about a simple
try:
name = unicode(name)
except UnicodeError:
...
?
Florent
--
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com