[Zope] Unicode Error
Toby Dickenson
tdickenson@geminidataloggers.com
Sat, 2 Nov 2002 20:15:32 +0000
On Saturday 02 November 2002 1:48 am, Tino Wildenhain wrote:
> if encoding !=3D "ascii":
> sys.setdefaultencoding(encoding)
>
> This implies modification of the installed code to change
> default behavior. I would consider this as bad.
> Why isnt a locales sensitive version the default?
That would make it difficult to write reliable portable Python code. It i=
s a=20
good thing that Python has predictable behaviour for things like=20
(string+integer), a local-sensitive or user-sensitive default encoding wo=
uld=20
make (plain string+unicode string) unpredictable.
Note that nothing else in Python depends on locales by default. Not even =
date=20
formatting, for example.
> However, there is lukyly another way to do it:
>
> let us provide a sitecustomize.py module for zope.
> If its in the path, it has access to sys.setdefaultencoding
That still breaks Python libraries that assume this has not been changed.=
=20
This is a legitimate assumption made by these libraries; the same as assu=
ming=20
the behaviour of (string+integer).=20
> I use it that way (I set utf-8) and Zope unicodes and strings
> quite good.
Feel free to do that in your own zope, but this will never be a supported=
way=20
of using Python. I think it is irresponsible to recommend this approach a=
s if=20
it was standard practice.