[Python-Dev] open(): set the default encoding to 'utf-8' in Python 3.3?
victor.stinner at haypocalc.com
Tue Jun 28 22:51:38 CEST 2011
Le mardi 28 juin 2011 à 16:02 +0200, M.-A. Lemburg a écrit :
> How about a more radical change: have open() in Py3 default to
> opening the file in binary mode, if no encoding is given (even
> if the mode doesn't include 'b') ?
I tried your suggested change: Python doesn't start.
sysconfig uses the implicit locale encoding to read sysconfig.cfg, the
Makefile and pyconfig.h. I think that it is correct to use the locale
encoding for Makefile and pyconfig.h, but maybe not for sysconfig.cfg.
Python require more changes just to run "make". I was able to run "make"
by using encoding='utf-8' in various functions (of distutils and
setup.py). I didn't try the test suite, I expect too many failures.
Then I tried my suggestion (use "utf-8" by default): Python starts
correctly, I can build it (run "make") and... the full test suite pass
without any change. (I'm testing on Linux, my locale encoding is UTF-8.)
More information about the Python-Dev