[issue19264] subprocess.Popen doesn't support unicode on Windows

STINNER Victor report at bugs.python.org
Tue Mar 25 14:46:08 CET 2014


STINNER Victor added the comment:

>  The original issue was reported against 2.7

Oh... Ok :-)

It's tricky to fix this issue in Python 2.7 because you have to choose which function is used: CreateProcessA() (bytes) or CreateProcessW() (Unicode). To use CreateProcessW(), you have to decode bytes parameter. Python 3 has os.fsencode()/os.fsdecode() functions, similar functions in C. The "mbcs" Python codec is strict by default, but it now supports any Python error handler. This change changed was improved in each Python 3 release.

Python 2 has PyUnicode_DecodeMBCSStateful() and PyUnicode_EncodeMBCS() which use the default Windows behaviour. I'm not sure that using PyUnicode_DecodeMBCSStateful() (or directly MultiByteToWideChar) + CreateProcessW() is exactly the same than calling CreateProcessA().

Should we support CreateProcessA() and CreateProcessW(), and use one or the other depending on the type of the pararameters?

IMO such change requires too much work and it is not enough to have a full Unicode support for filenames. You have to fix much more code. I already did all this work in Python 3 (in 3.1, 3.2 and then 3.3). I suggest you to upgrade to port your application to Python 3 if you want a full Unicode support. Using Unicode in Python 3 is natural and just works fine.

So I still suggest to close this issue as wontfix.

--

Similar discussions on Python 3:
http://bugs.python.org/issue8393#msg103565
http://bugs.python.org/issue8514#msg104224

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19264>
_______________________________________


More information about the Python-bugs-list mailing list