Skip to content

Commit

Permalink
hgext/*-format: pass PYTHONIOENCODING=UTF-8 to the mach subproces…
Browse files Browse the repository at this point in the history
…s (Bug 1752583) r=mhentges

`cp1252` is the default encoding for `hg.exe`, and is making it's way
into `mach` as the preferred encoding via the inherited environment from `hg`.
This commit forces utf-8 in the call to mach, by passing `PYTHONIOENCODING`
in the environment for `mach`.

Differential Revision: https://phabricator.services.mozilla.com/D137478

--HG--
extra : moz-landing-system : lando
  • Loading branch information
cgsheeh committed Jan 31, 2022
1 parent 4f2d769 commit eedf013
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion hgext/clang-format/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ def call_clang_format(repo, changed_files):
clang_format_cmd = [b'python3', b'mach'] + arguments
else:
clang_format_cmd = [mach_path] + arguments
subprocess.call(clang_format_cmd)

# Set `PYTHONIOENCODING` since `hg.exe` will detect `cp1252` as the encoding
# and pass it as the encoding to `mach` via the environment.
env = dict(os.environ)
env["PYTHONIOENCODING"] = "utf-8"

subprocess.call(clang_format_cmd, env=env)


def wrappedcommit(orig, repo, *args, **kwargs):
Expand Down
8 changes: 7 additions & 1 deletion hgext/js-format/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ def call_js_format(repo, changed_files):
js_format_cmd = [b'python3', b'mach'] + arguments
else:
js_format_cmd = [mach_path] + arguments
subprocess.call(js_format_cmd)

# Set `PYTHONIOENCODING` since `hg.exe` will detect `cp1252` as the encoding
# and pass it as the encoding to `mach` via the environment.
env = dict(os.environ)
env["PYTHONIOENCODING"] = "utf-8"

subprocess.call(js_format_cmd, env=env)


def wrappedcommit(orig, repo, *args, **kwargs):
Expand Down

0 comments on commit eedf013

Please sign in to comment.