[Python-Dev] Import and unicode: part two

Victor Stinner victor.stinner at haypocalc.com
Thu Jan 20 01:26:01 CET 2011

Le mercredi 19 janvier 2011 à 15:44 -0800, Toshio Kuratomi a écrit : 
> Additionally, many unix filesystem don't specify a filesystem encoding for
> filenames; they deal in legal and illegal bytes which could lead to
> troubles.  This problem of which encoding to use is a problem that can be
> seen on UNIX systems even now.

If the system is not correctly configured, it is not a bug in Python,
but a bug in the system config. Python relies on the locale to choose
the filesystem encoding (sys.getfilesystemencoding()). Python uses this
encoding to decode and encode all filenames.

> * Specify an encoding per platform and stick to that.

It doesn't work: on UNIX/BSD, the user chooses its own encoding and all
programs will use it.

Anyway, I don't see why it is a problem to have different encodings on
different systems. Each system can use its own encoding. The bug that
I'm trying to solve is a Python bug, not an OS bug.

> * Change import semantics to allow specifying the encoding of the module on
>   the filesystem (seems really icky).

This is a very bad idea. I introduced PYTHONFSENCODING environment
variable in Python 3.2, but then quickly removed it, because it
introduced a lot of inconsistencies.


More information about the Python-Dev mailing list