Skip to content

Commit

Permalink
fix: enforce UTF-8 encoding for linter subprocess on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
akaihola committed Nov 16, 2024
1 parent d84d790 commit 0d5ea2b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/graylint/linting.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,15 @@ def _check_linter_output(
existing_path_strs = sorted(str(path) for path in paths if (root / path).exists())
cmdline_and_paths = cmdline_parts + existing_path_strs
logger.debug("[%s]$ %s", root, shlex.join(cmdline_and_paths))
effective_env = env.copy()
if WINDOWS:
effective_env["PYTHONIOENCODING"] = "utf-8"
with Popen( # nosec
cmdline_and_paths,
stdout=PIPE,
encoding="utf-8",
cwd=root,
env=env,
env=effective_env,
) as linter_process:
# condition needed for MyPy (see https://stackoverflow.com/q/57350490/15770)
if linter_process.stdout is None:
Expand Down

0 comments on commit 0d5ea2b

Please sign in to comment.