Repository: pre-commit/pre-commit

Issue:
BUG - hooks not working on windows 10, when user account name contains non-ascii characters
When user account name contains non-ascii characters such as 'š', such that python executable ends up for example in C:\Users\john.š\\.cache\pre-commit\repo\py_env-python3.8\Scripts\python.exe, when committing to the git repository following message appears:

An unexpected error has occurred: AssertionError: BUG: expected environment for python to be healthy() immediately after install, please open an issue describing your environment.

PS: fucntion os.path.isfile() in parse_shebang.normexe() returns False, even though the executable exists there and is a file.


Discussion:
please share your configuration and version information as well as the log file
### version information

```
pre-commit version: 2.9.0
sys.version:
    3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)]
sys.executable: c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\scripts\python.exe
os.name: nt
sys.platform: win32
```

### error information

```
An unexpected error has occurred: AssertionError: BUG: expected environment for python to be healthy() immediately after install, please open an issue describing your environment
```

```
Traceback (most recent call last):
  File "c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\lib\site-packages\pre_commit\error_handler.py", line 65, in error_handler
    yield
  File "c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\lib\site-packages\pre_commit\main.py", line 347, in main
    return hook_impl(
  File "c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\lib\site-packages\pre_commit\commands\hook_impl.py", line 217, in hook_impl
    return retv | run(config, store, ns)
  File "c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\lib\site-packages\pre_commit\commands\run.py", line 401, in run
    install_hook_envs(hooks, store)
  File "c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\lib\site-packages\pre_commit\repository.py", line 213, in install_hook_envs
    _hook_install(hook)
  File "c:\users\juraj.š\projects\aiscr-amcr-webclient\venv\lib\site-packages\pre_commit\repository.py", line 88, in _hook_install
    raise AssertionError(
AssertionError: BUG: expected environment for python to be healthy() immediately after install, please open an issue describing your environment
```

### Yaml

```
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.2.0
    hooks:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
    -   id: check-yaml
    -   id: check-added-large-files
```
could you also share the output of `pip freeze`?
appdirs==1.4.4
asgiref==3.3.0
cfgv==3.2.0
distlib==0.3.1
dj-database-url==0.5.0
Django==3.1.3
filelock==3.0.12
identify==1.5.10
nodeenv==1.5.0
pre-commit==2.9.0
psycopg2==2.8.6
pytz==2020.4
PyYAML==5.3.1
six==1.15.0
sqlparse==0.4.1
toml==0.10.2
virtualenv==20.2.1
hmmm I can't reproduce :(

could you set a breakpoint inside the `healthy()` method and show me a few things?

![image](https://user-images.githubusercontent.com/1810591/100143258-e8505080-2e49-11eb-973a-ab55ae638309.png)


here's (for example) some debug information that would be helpful:

![image](https://user-images.githubusercontent.com/1810591/100143523-4f6e0500-2e4a-11eb-82e3-ad06fc3bd19f.png)

I think you cannot reproduce to issue, because you have python installed in C:\Python39. Try installing it into subdirectory of the C:\Users\john.š. I have tried to install python directly to C:\Python39 (like you did) and the error went away. (I believe you will have to convert encoding of the pre-commit file to UTF-8 too)

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
@@ -36,7 +36,7 @@ def _version_info(exe: str) -> str:
 
 def _read_pyvenv_cfg(filename: str) -> Dict[str, str]:
     ret = {}
-    with open(filename) as f:
+    with open(filename, encoding='UTF-8') as f:
         for line in f:
             try:
                 k, v = line.split('=')


Test patch:
diff --git a/tests/languages/python_test.py b/tests/languages/python_test.py
--- a/tests/languages/python_test.py
+++ b/tests/languages/python_test.py
@@ -23,6 +23,13 @@ def test_read_pyvenv_cfg(tmpdir):
     assert python._read_pyvenv_cfg(pyvenv_cfg) == expected
 
 
+def test_read_pyvenv_cfg_non_utf8(tmpdir):
+    pyvenv_cfg = tmpdir.join('pyvenv_cfg')
+    pyvenv_cfg.write_binary('hello = hello john.š\n'.encode())
+    expected = {'hello': 'hello john.š'}
+    assert python._read_pyvenv_cfg(pyvenv_cfg) == expected
+
+
 def test_norm_version_expanduser():
     home = os.path.expanduser('~')
     if os.name == 'nt':  # pragma: nt cover