[Python-Dev] Divorcing str and unicode (no more implicit conversions).

"Martin v. Löwis" martin at v.loewis.de
Mon Oct 17 08:36:17 CEST 2005


Martin Blais wrote:
>>Yes. setdefaultencoding() is removed from sys by site.py. To get it
>>again you must reload sys.
> 
> 
> Thanks.

Actually, I should take the opportunity to advise people that
setdefaultencoding doesn't really work. With the default default
encoding, strings and Unicode objects hash equal when they are
equal. If you change the default encoding, this property
goes away (perhaps unless you change it to Latin-1). As a result,
dictionaries where you mix string and Unicode keys won't work:
you might not find a value for a string key when looking up
with a Unicode object, and vice versa.

Regards,
Martin


More information about the Python-Dev mailing list