Bugs item #1759845, was opened at 2007-07-24 14:24 Message generated for change (Comment added) made by mclausch You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1759845&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.5 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Matt (mclausch) Assigned to: Nobody/Anonymous (nobody) Summary: subprocess.call fails with unicode strings in command line Initial Comment: On Windows, subprocess.call() fails with an exception if either the executable or any of the arguments contain upper level characters. See below: >>> cmd = [ u'test_\xc5_exec.bat', u'arg1', u'arg2' ] >>> subprocess.call(cmd) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python25\lib\subprocess.py", line 443, in call return Popen(*popenargs, **kwargs).wait() File "C:\Python25\lib\subprocess.py", line 593, in __init__ errread, errwrite) File "C:\Python25\lib\subprocess.py", line 815, in _execute_child startupinfo) UnicodeEncodeError: 'ascii' codec can't encode character u'\xc5' in position 5: ordinal not in range(128) ---------------------------------------------------------------------- >Comment By: Matt (mclausch) Date: 2007-08-20 17:12 Message: Logged In: YES user_id=1852547 Originator: YES Sorry, I should have been more specific. I'm looking for a general solution, not just one for characters in iso-8859-1. For instance, I need to execute a subprocess where the executable or the arguments may contain Japanese characters. So another example would be: cmd = [ u'test_\u65e5\u672c\u8a9e_exec.bat', u'arg1', u'arg2' ] subprocess.call(cmd) ---------------------------------------------------------------------- Comment By: brotchie (brotch) Date: 2007-08-05 04:36 Message: Logged In: YES user_id=1860608 Originator: NO Python's default character coding is 'ascii' which can't convert unicode > 127 into chars. Forcing the unicode string to encode as 'iso-8859-1' eg. subprocess.call(cmd.encode('iso-8859-1')) resolves the problem and runs the correct command. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1759845&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com