[Zope3-dev] test errors due to ascii defaultencoding assumption

Dieter Maurer dieter at handshake.de
Thu Oct 20 16:05:20 EDT 2005


Tim Peters wrote at 2005-10-19 15:15 -0400:
> ...
>    When the Unicode type was added, people disagreed on what the
>    [default] encoding should be (ASCII, ISO-8859-1, or UTF-8), so the
>    setdefaultencoding hook was added so we could play with it.
>    Unfortunately, nobody got around to remove it before the release.
>
>    (to me, arguing that it's a good thing that you can use a global setting
>    to control what a+b does when a is an 8-bit string and b is a unicode
>    string is about as silly as arguing that it would be a good thing to have
>    a global setting for controlling what a+b does if a is an integer and b is
>    a string. if you want to convert between different logical types (encoded
>    data and text are different things), use an explicit conversion.)

That would be true had Python already different types
for "text" (unicode) and binary strings and would use these
consistently.

Nowadays, life is hell without a sensible "setdefaultencoding":

  Many isolated modules intersperse unicode in an otherwise
  "string" dominated world causing wide spread
  UnicodeDecodingErrors.

>I'm sure sys.setdefaultencoding will vanish in a future Python
>release, since it wasn't intended to persist beyond initial
>development to begin with.

Hopefully only after Python cleaned up the separation
between text and binary strings.

Otherwise, I would be forced to maintain my private Python
version (with "setdefaultencoding").


-- 
Dieter


More information about the Zope3-dev mailing list