diff options
author | bors-servo <infra@servo.org> | 2023-05-29 18:15:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-29 18:15:28 +0200 |
commit | fc07c2127669ecd6c2419552553212a0cd333ea3 (patch) | |
tree | 213f3f5358c130d0435f92acfd8104fd24874743 /python/servo/command_base.py | |
parent | cab7694b086807f12efd0b396bbb1bc609a015a0 (diff) | |
parent | faa8c0e967cd9e3526c05e4eac34c679cb14ed5f (diff) | |
download | servo-fc07c2127669ecd6c2419552553212a0cd333ea3.tar.gz servo-fc07c2127669ecd6c2419552553212a0cd333ea3.zip |
Auto merge of #29811 - mrobinson:remove-more-python-2, r=jdm
Remove more Python 2 compatibility code
- os.environ is always `str` in Python 3.
- The only string type is `str` so we can stop using `six.str_types`.
- `iteritems()` isn't necessary because dicts have the `items()` method.
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because they do not change behavior.
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'python/servo/command_base.py')
-rw-r--r-- | python/servo/command_base.py | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/python/servo/command_base.py b/python/servo/command_base.py index c7f3c326c4a..9ab6c3935f6 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -131,31 +131,11 @@ def archive_deterministically(dir_to_archive, dest_archive, prepend_path=None): os.rename(temp_file, dest_archive) -def normalize_env(env): - # There is a bug in Py2 subprocess where it doesn't like unicode types in - # environment variables. Here, ensure all unicode are converted to - # 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 = six.ensure_str(k, 'utf-8', 'strict') - - if isinstance(v, six.text_type): - v = six.ensure_str(v, 'utf-8', 'strict') - - normalized_env[k] = v - - return normalized_env - - def call(*args, **kwargs): """Wrap `subprocess.call`, printing the command if verbose=True.""" verbose = kwargs.pop('verbose', False) if verbose: print(' '.join(args[0])) - if 'env' in kwargs: - kwargs['env'] = normalize_env(kwargs['env']) # we have to use shell=True in order to get PATH handling # when looking for the binary on Windows return subprocess.call(*args, shell=sys.platform == 'win32', **kwargs) @@ -166,8 +146,6 @@ def check_output(*args, **kwargs): verbose = kwargs.pop('verbose', False) if verbose: print(' '.join(args[0])) - if 'env' in kwargs: - kwargs['env'] = normalize_env(kwargs['env']) # we have to use shell=True in order to get PATH handling # when looking for the binary on Windows return subprocess.check_output(*args, shell=sys.platform == 'win32', **kwargs) @@ -179,9 +157,6 @@ def check_call(*args, **kwargs): Also fix any unicode-containing `env`, for subprocess """ verbose = kwargs.pop('verbose', False) - if 'env' in kwargs: - kwargs['env'] = normalize_env(kwargs['env']) - if verbose: print(' '.join(args[0])) # we have to use shell=True in order to get PATH handling |