aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorKagami Sascha Rosylight <saschanaz@outlook.com>2020-06-20 17:36:01 +0200
committerKagami Sascha Rosylight <saschanaz@outlook.com>2020-06-20 17:36:01 +0200
commita202a1d5b6e4a6940fc36df62347d557ba82e05f (patch)
tree0dff8fba48928cce602937ca5ac5ed6e780adcba /python
parent0b61cfc3ae803ac0f9deef937f890f83b24c9a35 (diff)
downloadservo-a202a1d5b6e4a6940fc36df62347d557ba82e05f.tar.gz
servo-a202a1d5b6e4a6940fc36df62347d557ba82e05f.zip
Fix Py3 environment setting failures
Diffstat (limited to 'python')
-rw-r--r--python/servo/build_commands.py5
-rw-r--r--python/servo/command_base.py10
2 files changed, 9 insertions, 6 deletions
diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py
index 3b87e9aba7e..c3a0819ac00 100644
--- a/python/servo/build_commands.py
+++ b/python/servo/build_commands.py
@@ -320,7 +320,10 @@ class MachCommands(CommandBase):
exitcode = process.wait()
encoding = locale.getpreferredencoding() # See https://stackoverflow.com/a/9228117
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:
print("Failed to run vcvarsall. stderr:")
print(stderr.decode(encoding))
diff --git a/python/servo/command_base.py b/python/servo/command_base.py
index db9f550e61d..de2272dbb9d 100644
--- a/python/servo/command_base.py
+++ b/python/servo/command_base.py
@@ -131,17 +131,17 @@ def archive_deterministically(dir_to_archive, dest_archive, prepend_path=None):
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
- # binary. utf-8 is our globally assumed default. If the caller doesn't
- # want UTF-8, they shouldn't pass in a unicode instance.
+ # native string type. utf-8 is our globally assumed default. If the caller
+ # doesn't want UTF-8, they shouldn't pass in a unicode instance.
normalized_env = {}
for k, v in env.items():
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):
- v = v.encode('utf-8', 'strict')
+ v = six.ensure_str(v, 'utf-8', 'strict')
normalized_env[k] = v