mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 17:14:43 +04:00
Merge pull request #1713 from pre-commit/pyvenv_utf8_windows
fix for base executable with non-ascii characters on windows
This commit is contained in:
commit
a9ed1de5f7
2 changed files with 8 additions and 1 deletions
|
|
@ -36,7 +36,7 @@ def _version_info(exe: str) -> str:
|
||||||
|
|
||||||
def _read_pyvenv_cfg(filename: str) -> Dict[str, str]:
|
def _read_pyvenv_cfg(filename: str) -> Dict[str, str]:
|
||||||
ret = {}
|
ret = {}
|
||||||
with open(filename) as f:
|
with open(filename, encoding='UTF-8') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
try:
|
try:
|
||||||
k, v = line.split('=')
|
k, v = line.split('=')
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,13 @@ def test_read_pyvenv_cfg(tmpdir):
|
||||||
assert python._read_pyvenv_cfg(pyvenv_cfg) == expected
|
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():
|
def test_norm_version_expanduser():
|
||||||
home = os.path.expanduser('~')
|
home = os.path.expanduser('~')
|
||||||
if os.name == 'nt': # pragma: nt cover
|
if os.name == 'nt': # pragma: nt cover
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue