[Python-Dev] deleting setdefaultencoding iin site.py is evil

"Martin v. Löwis" martin at v.loewis.de
Thu Aug 27 10:02:47 CEST 2009


>> One specific problem is dictionaries will stop working correctly if you
>> set the default encoding to anything but ASCII. 
> 
> ...except they haven't.

In your application. Can you please agree that this a semantical problem
that is completely unacceptable for language design?

> Indeed, but this doesn't happen because the app never has a situation
> where strings and unicodes are put in the same dict. However, it does
> have plenty of situations where lists containing a mixture of utf-8
> encoded strings and unicodes exist, where changing the default encoding
> removes a *lot* of pain.

So you should convert all byte strings to UTF-8 before adding them
to the list. Assuming you have used proper encapsulation and
object-oriented design, it shouldn't be too difficult to find, for each
such list, where the places are that modify the list.

> Would anyone object if I added this snippet to the .rst that generates:
> http://docs.python.org/library/sys.html

The snippet explaining the problem? I don't mind, but Raymond is on
record for objecting to any addition of a warning box to the
documentation, because it gives the impression that Python is full of
problems, when many these warnings really refer to boundary cases only.

Regards,
Martin


More information about the Python-Dev mailing list