subprocess.call with non-ASCII arguments?

Ulli Horlacher framstag at rus.uni-stuttgart.de
Tue Dec 15 07:51:24 EST 2015


I want to create a zip file within a Python 2.7 program on windows.

My code:

  cmd = ['7za.exe','a','-tzip',archive] + files
  status = subprocess.call(cmd)

leads to:

  File "fexit.py", line 971, in sendfile_retry
    status = subprocess.call(cmd)
  File "C:\Python27\lib\subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "C:\Python27\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 87:
 ordinal not in range(128)


This is because the array "files" contains filenames with non-ASCII
characters.

So, the problem is in subprocess.py, which I cannot modify.

What can I do?


-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum IZUS/TIK         E-Mail: horlacher at tik.uni-stuttgart.de
Universitaet Stuttgart         Tel:    ++49-711-68565868
Allmandring 30a                Fax:    ++49-711-682357
70550 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/



More information about the Python-list mailing list