Subprocess module and unicode input

Matthew Lausch mclausch at gmail.com
Fri Sep 7 23:46:26 CEST 2007


I'd like to use the subprocess module with upper level characters in
the process name or in the arguments to the process. Something like
this:

cmd = [ u'test_\u65e5\u672c\u8a9e_exec.bat', u'arg1', u'arg2' ]
subprocess.call(cmd)

But this gives the error:

UnicodeEncodeError: 'ascii' codec can't encode characters in position
5-7: ordinal not in range(128)

Is there a way around this problem? I don't want to assume any
particular set of characters. The example above uses Japanese
characters, but I would like to support anything.

Thanks.




More information about the Python-list mailing list