mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 09:04:41 +04:00
avoid a UnicodeError on windows with non-charmap characters
This commit is contained in:
parent
42562a12ed
commit
0781dac78f
1 changed files with 3 additions and 2 deletions
|
|
@ -67,9 +67,10 @@ def _find_by_py_launcher(
|
||||||
) -> Optional[str]: # pragma: no cover (windows only)
|
) -> Optional[str]: # pragma: no cover (windows only)
|
||||||
if version.startswith('python'):
|
if version.startswith('python'):
|
||||||
num = version[len('python'):]
|
num = version[len('python'):]
|
||||||
|
cmd = ('py', f'-{num}', '-c', 'import sys; print(sys.executable)')
|
||||||
|
env = dict(os.environ, PYTHONIOENCODING='UTF-8')
|
||||||
try:
|
try:
|
||||||
cmd = ('py', f'-{num}', '-c', 'import sys; print(sys.executable)')
|
return cmd_output(*cmd, env=env)[1].strip()
|
||||||
return cmd_output(*cmd)[1].strip()
|
|
||||||
except CalledProcessError:
|
except CalledProcessError:
|
||||||
pass
|
pass
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue