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 to 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.
However, I'm worried about localisation issues that might arise. At present, in the caller I have:
subprocess.Popen(
[sys.executable, path_to_script, path.encode("utf-8"), str(recurse)],
stdin = None,
stdout = subprocess.PIPE)
In the script:
path = unicode(sys.argv[1], "utf-8")
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?