Skip to content

Commit

Permalink
Merge pull request pypa#8718 from uranusjr/pyvenv-cfg-encoding
Browse files Browse the repository at this point in the history
Always use UTF-8 to read pyvenv.cfg
  • Loading branch information
pradyunsg committed Aug 11, 2020
1 parent e04cd89 commit 516c743
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/8717.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Always use UTF-8 to read ``pyvenv.cfg`` to match the built-in ``venv``.
5 changes: 4 additions & 1 deletion src/pip/_internal/utils/virtualenv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import absolute_import

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

0 comments on commit 516c743

Please sign in to comment.