Repository: pre-commit/pre-commit

Issue:
Good old 'utf-8' codec error on Windows
Howdy,

I'm unable to run `tox -re linting` on pytest anymore. I'm getting this error:

```
λ tox -re linting
linting recreate: c:\pytest\.tox\linting
linting installdeps: pre-commit>=1.11.0
linting installed: aspy.yaml==1.2.0,cfgv==1.6.0,identify==1.4.2,importlib-metadata==0.9,nodeenv==1.3.3,pre-commit==1.16.0,pytest==3.6.0,PyYAML==5.1,six==1.12.0,toml==0.10.0,virtualenv==16.5.0,zipp==0.4.0
linting run-test-pre: PYTHONHASHSEED='335'
linting run-test: commands[0] | pre-commit run --all-files --show-diff-on-failure
An unexpected error has occurred: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 282: invalid continuation byte
Check the log at C:\Users\Bruno/.cache\pre-commit\pre-commit.log
ERROR: InvocationError for command 'c:\pytest\.tox\linting\Scripts\pre-commit.EXE' run --all-files --show-diff-on-failure (exited with code 1)
```

Here's the contents of the log file:

```
An unexpected error has occurred: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 282: invalid continuation byte
Traceback (most recent call last):
  File "c:\pytest\.tox\linting\lib\site-packages\pre_commit\error_handler.py", line 46, in error_handler
    yield
  File "c:\pytest\.tox\linting\lib\site-packages\pre_commit\main.py", line 294, in main
    return run(args.config, store, args)
  File "c:\pytest\.tox\linting\lib\site-packages\pre_commit\commands\run.py", line 285, in run
    install_hook_envs(hooks, store)
  File "c:\pytest\.tox\linting\lib\site-packages\pre_commit\repository.py", line 210, in install_hook_envs
    if not _need_installed():
  File "c:\pytest\.tox\linting\lib\site-packages\pre_commit\repository.py", line 205, in _need_installed
    if hook.install_key not in seen and not hook.installed():
  File "c:\pytest\.tox\linting\lib\site-packages\pre_commit\repository.py", line 75, in installed
    lang.healthy(self.prefix, self.language_version)
  File "c:\pytest\.tox\linting\lib\site-packages\pre_commit\languages\python.py", line 139, in healthy
    retcode, _, _ = cmd_output(
  File "c:\pytest\.tox\linting\lib\site-packages\pre_commit\util.py", line 149, in cmd_output
    stderr = stderr.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 282: invalid continuation byte
```

I've seen #835, #330 and #245, so I've tried to cleanup the pre-commit cache and updating `pip` and `virtualenv`, both on my system and in the virtualenv I have for pytest:

```
(.env37) λ pip install -U virtualenv
Requirement already up-to-date: virtualenv in .\.env37\lib\site-packages (16.5.0)

(.env37) λ py -3.7 -m pip install -U virtualenv
Requirement already up-to-date: virtualenv in c:\users\bruno\appdata\local\programs\python\python37\lib\site-packages (16.5.0)

(.env37) λ .tox\linting\Scripts\pip install virtualenv -U
Requirement already up-to-date: virtualenv in .\.tox\linting\lib\site-packages (16.5.0)
```

Same for `pre-commit`:

```
(.env37) λ .tox\linting\Scripts\pip list
Package            Version
------------------ -------
aspy.yaml          1.2.0
cfgv               1.6.0
identify           1.4.2
importlib-metadata 0.9
nodeenv            1.3.3
pip                19.1.1
pre-commit         1.16.0
PyYAML             5.1
setuptools         41.0.1
six                1.12.0
toml               0.10.0
virtualenv         16.5.0
wheel              0.33.1
zipp               0.4.0

(.env37) λ pip list
Package            Version                Location
------------------ ---------------------- -------------
aspy.yaml          1.2.0
atomicwrites       1.3.0
attrs              19.1.0
cfgv               1.6.0
colorama           0.4.1
filelock           3.0.10
identify           1.4.2
importlib-metadata 0.9
more-itertools     7.0.0
nodeenv            1.3.3
pip                19.1.1
pluggy             0.9.0
pre-commit         1.16.0
py                 1.8.0
pytest             4.4.2.dev43+g8605ed2a1 c:\pytest\src
PyYAML             5.1
setuptools         39.0.1
six                1.12.0
toml               0.10.0
tox                3.9.0
virtualenv         16.5.0
zipp               0.4.0
```

Any hints @asottile? 🤔 


Discussion:
Somehow this command is causing non UTF8 bytes to be printed : https://github.com/pre-commit/pre-commit/blob/v1.16.0/pre_commit/languages/python.py#L141

The fix is easy, add `encoding=None` to the call, however I have no idea how you're in this state! I'd be curious to see what that's printing O_o
@nicoddemus any chance you could see what it's spitting out? (that command _should_ produce no output I would think :laughing:)

something like `python -c "import ctypes, datetime, io, os, ssl, weakref"`

Resolving patch:
diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py
--- a/pre_commit/languages/python.py
+++ b/pre_commit/languages/python.py
@@ -140,6 +140,7 @@ def healthy(prefix, language_version):
                 'python', '-c',
                 'import ctypes, datetime, io, os, ssl, weakref',
                 retcode=None,
+                encoding=None,
             )
         return retcode == 0
 


Test patch: