title: Encoding of arguments to subprocess.Popen
body: <p>I have a Python extension to the Nautilus file browser (AFAIK this runs exclusively on GNU/Linux/Unix/etc environments). I decided to split out an expensive computation and run it as a subprocess, pickle the result and send it back over a pipe. My question concerns the arguments <em>to</em> the script. Since the computation requires a path argument and a boolean argument I figured I could do this in two ways: send the args in a pickled tuple over a pipe, or give them on the command line. I found that the pickled tuple approach is noticeably slower than just giving arguments, so I went with the subprocess argument approach.</p>
  
  <p>However, I'm worried about localisation issues that might arise. At present, in the caller I have:</p>
  
  <pre><code>subprocess.Popen(
      [sys.executable, path_to_script, path.encode("utf-8"), str(recurse)],
      stdin = None,
      stdout = subprocess.PIPE)
  </code></pre>
  
  <p>In the script:</p>
  
  <pre><code>path = unicode(sys.argv[1], "utf-8")
  </code></pre>
  
  <p>My concern is that encoding the path argument as UTF-8 is a mistake, but I don't know for sure. I want to avoid a "it works on my machine" syndrome. Will this fail if a user has, say, latin1 as their default character encoding? Or does it not matter?</p>