shlex, unicode, and subprocess.Popen on Windows

python at bdurham.com python at bdurham.com
Mon Aug 30 15:54:04 CEST 2010


Python 2.6/Windows: shlex.split() does not support unicode
strings. Is this simply a limitation of the current shlex
implementation or is this an intentional design decision that
reflects the behavior of how the Windows shell supports unicode
values?

Specifically, it doesn't appear that subprocess.Popen() has any
restrictions on unicode args, but perhaps I'm missing some edge
cases where this may be true?

If this is simply a limitation of the current shlex
implementation, does anyone see any risks to encoding a command
string using 'xmlreplace' ( command.encode( 'utf8', 'xmlreplace'
) ) in order to hide unicode chars, splitting the now ASCII
string using shlex.split, and then walking the list of strings
returned by shlex.split, decoding them back to Unicode ( .decode(
'utf8' ) ) before passing this list to subprocess.Popen() for
execution?

Thanks,
Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100830/46a5532a/attachment.html>


More information about the Python-list mailing list