mirror of
https://github.com/servo/servo.git
synced 2025-06-28 11:03:39 +01:00
Fix Py3 environment setting failures
This commit is contained in:
parent
0b61cfc3ae
commit
a202a1d5b6
2 changed files with 9 additions and 6 deletions
|
@ -320,7 +320,10 @@ class MachCommands(CommandBase):
|
||||||
exitcode = process.wait()
|
exitcode = process.wait()
|
||||||
encoding = locale.getpreferredencoding() # See https://stackoverflow.com/a/9228117
|
encoding = locale.getpreferredencoding() # See https://stackoverflow.com/a/9228117
|
||||||
if exitcode == 0:
|
if exitcode == 0:
|
||||||
os.environ.update(eval(stdout.decode(encoding)))
|
decoded = stdout.decode(encoding)
|
||||||
|
if decoded.startswith("environ("):
|
||||||
|
decoded = decoded.strip()[8:-1]
|
||||||
|
os.environ.update(eval(decoded))
|
||||||
else:
|
else:
|
||||||
print("Failed to run vcvarsall. stderr:")
|
print("Failed to run vcvarsall. stderr:")
|
||||||
print(stderr.decode(encoding))
|
print(stderr.decode(encoding))
|
||||||
|
|
|
@ -131,17 +131,17 @@ def archive_deterministically(dir_to_archive, dest_archive, prepend_path=None):
|
||||||
|
|
||||||
|
|
||||||
def normalize_env(env):
|
def normalize_env(env):
|
||||||
# There is a bug in subprocess where it doesn't like unicode types in
|
# There is a bug in Py2 subprocess where it doesn't like unicode types in
|
||||||
# environment variables. Here, ensure all unicode are converted to
|
# environment variables. Here, ensure all unicode are converted to
|
||||||
# binary. utf-8 is our globally assumed default. If the caller doesn't
|
# native string type. utf-8 is our globally assumed default. If the caller
|
||||||
# want UTF-8, they shouldn't pass in a unicode instance.
|
# doesn't want UTF-8, they shouldn't pass in a unicode instance.
|
||||||
normalized_env = {}
|
normalized_env = {}
|
||||||
for k, v in env.items():
|
for k, v in env.items():
|
||||||
if isinstance(k, six.text_type):
|
if isinstance(k, six.text_type):
|
||||||
k = k.encode('utf-8', 'strict')
|
k = six.ensure_str(k, 'utf-8', 'strict')
|
||||||
|
|
||||||
if isinstance(v, six.text_type):
|
if isinstance(v, six.text_type):
|
||||||
v = v.encode('utf-8', 'strict')
|
v = six.ensure_str(v, 'utf-8', 'strict')
|
||||||
|
|
||||||
normalized_env[k] = v
|
normalized_env[k] = v
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue