[Python-Dev] Fix IO Encoding issue for embedded Python under Windows - Issue16129
Bastien Montagne
montagne29 at wanadoo.fr
Thu Oct 10 11:54:06 CEST 2013
Hi Py Devs,
As this is my first mail here, first a short presentation: my name is
Bastien Montagne (aka mont29), I live in France, and I’ve been using
Python for a fair amount of years now in various projects, amongst which
Blender 3D software. I’m also a Blender dev (C & Py) since a few years.
Now to the topic, to summarize http://bugs.python.org/issue16129 , an
application dynamically linking against Python under MS-Windows has no
way to control Python's environment, and hence cannot set
PYTHONIOENCODING to get another encoding than default Windows' console
(which is usually 8bit, like cp437). This is really annoying under
Blender, as we use utf-8 strings, users having e.g. "special" chars in
their file paths keep getting python errors instead of nice prints…
Following Nick Coghlan’s suggestions, I made a patch which solves that
issue by adding Py_SetStandardStreamEncoding() to the API, which allows
embedding code to directly specify standard IO encodings. So now I’m
waiting for reviews & comments from py devs, in the hope that this can
make it into python code before 3.4 feature freeze (patch:
http://bugs.python.org/file31985/setstdio.diff ).
Best regards,
Bastien
More information about the Python-Dev
mailing list