encode Popen argv as UTF-8 on POSIX so we ignore locale

This commit is contained in:
Jean-Paul Calderone 2021-01-11 19:21:20 -05:00
parent ec6c036f87
commit de9bcc7ea8

@ -76,6 +76,11 @@ def run_bintahoe(extra_argv, python_options=None):
argv.extend(python_options)
argv.extend([u"-m", u"allmydata.scripts.runner"])
argv.extend(extra_argv)
if not platform.isWindows():
# On POSIX Popen (via execvp) will encode argv using the "filesystem"
# encoding. Depending on LANG this may make our unicode arguments
# unencodable. Do our own UTF-8 encoding here instead.
argv = list(arg.encode("utf-8") for arg in argv)
p = Popen(argv, stdout=PIPE, stderr=PIPE)
out = p.stdout.read().decode("utf-8")
err = p.stderr.read().decode("utf-8")