Skip to content

Commit e8f5219

Browse files
authored
Merge pull request #8718 from uranusjr/pyvenv-cfg-encoding
Always use UTF-8 to read pyvenv.cfg
2 parents d6d84e7 + 810385b commit e8f5219

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

news/8717.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Always use UTF-8 to read ``pyvenv.cfg`` to match the built-in ``venv``.

src/pip/_internal/utils/virtualenv.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import absolute_import
22

3+
import io
34
import logging
45
import os
56
import re
@@ -51,7 +52,9 @@ def _get_pyvenv_cfg_lines():
5152
"""
5253
pyvenv_cfg_file = os.path.join(sys.prefix, 'pyvenv.cfg')
5354
try:
54-
with open(pyvenv_cfg_file) as f:
55+
# Although PEP 405 does not specify, the built-in venv module always
56+
# writes with UTF-8. (pypa/pip#8717)
57+
with io.open(pyvenv_cfg_file, encoding='utf-8') as f:
5558
return f.read().splitlines() # avoids trailing newlines
5659
except IOError:
5760
return None

0 commit comments

Comments
 (0)