Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for base executable with non-ascii characters on windows #1713

Merged
merged 1 commit into from Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pre_commit/languages/python.py
Expand Up @@ -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('=')
Expand Down
7 changes: 7 additions & 0 deletions tests/languages/python_test.py
Expand Up @@ -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
Expand Down