mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +04:00
Fix for cases where commands output UTF8 in Windows.
This commit is contained in:
parent
2bffc0ad85
commit
54b2d982f3
2 changed files with 19 additions and 0 deletions
|
|
@ -93,6 +93,15 @@ def cmd_output_b(
|
|||
) -> tuple[int, bytes, bytes | None]:
|
||||
_setdefault_kwargs(kwargs)
|
||||
|
||||
if sys.platform == 'win32':
|
||||
# In windows, pipes use CP1252 by default, and you'll get an
|
||||
# exception if the command being run outputs unicode. So we
|
||||
# set the pipe encoding to utf-8 instead.
|
||||
#
|
||||
# See https://stackoverflow.com/a/74607949/149506
|
||||
import os
|
||||
os.environ['PYTHONIOENCODING'] = 'utf-8'
|
||||
|
||||
try:
|
||||
cmd = parse_shebang.normalize_cmd(cmd, env=kwargs.get('env'))
|
||||
except parse_shebang.ExecutableNotFoundError as e:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue