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

Jim Fulton jim at zope.com
Mon Oct 3 16:51:38 CEST 2005


M.-A. Lemburg wrote:
> Michael Hudson wrote:
> 
>>Martin Blais <blais at furius.ca> writes:
>>
>>
>>
>>>What if we could completely disable the implicit conversions between
>>>unicode and str?  In other words, if you would ALWAYS be forced to
>>>call either .encode() or .decode() to convert between one and the
>>>other... wouldn't that help a lot deal with that issue?
>>
>>
>>I don't know.  I've made one or two apps safe against this and it's
>>mostly just annoying.
>>
>>
>>>How hard would that be to implement?
>>
>>import sys
>>reload(sys)
>>sys.setdefaultencoding('undefined')
> 
> 
> You shouldn't post tricks like these :-)
> 
> The correct way to change the default encoding is by
> providing a sitecustomize.py module which then call the
> sys.setdefaultencoding("undefined").

This is a much more evil trick IMO, as it affects all Python code,
rather than a single program.

I would argue that it's evil to change the default encoding
in the first place, except in this case to disable implicit
encoding or decoding.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Python-Dev mailing list