python unicode in subprocess does not work same in console and in mod_wsgi
Question: On a python console I can run (echo of e acute):

    
    
    import subprocess
    cmd = u'echo "é"'
    subprocess.call(cmd,shell=True)
    

But if I run that code in a Django view (mod_wsgi), It crashes :

    
    
    subprocess.call(cmd,shell=True)
       File "/usr/lib64/python2.6/subprocess.py", line 444, in call
         return Popen(*popenargs, **kwargs).wait()
       File "/usr/lib64/python2.6/subprocess.py", line 595, in __init__
         errread, errwrite)
       File "/usr/lib64/python2.6/subprocess.py", line 1106, in _execute_child
         raise child_exception
     TypeError: execv() arg 2 must contain only strings
    

I can solve this problem by doing a `.encode('ascii','replace')` but it strips
the accentuated chars.

I cannot see any way to specify a locale or an encoding while calling the
subshell. I tried to configure mod_wsgi with lang and locale to utf-8 but it
did not help.

How can I run a subprocess call with accentuated chars on mod_wsgi ?


Answer: I finally found a way :

    
    
    subprocess.call(cmd.encode('utf-8'),shell=True)
    

