diff options
author | Tzu-ping Chung <uranusjr@gmail.com> | 2020-08-06 11:45:29 +0800 |
---|---|---|
committer | Tzu-ping Chung <uranusjr@gmail.com> | 2020-08-06 11:46:46 +0800 |
commit | 810385b971bc101182ded21e83457d83790e413a (patch) | |
tree | e798fd90d22f4403a701c31bd4efbc77348fb802 | |
parent | 70768de0a8f8cd8148bbfadac7fdc179e7f8a10a (diff) | |
download | pip-810385b971bc101182ded21e83457d83790e413a.tar.gz |
Always use UTF-8 to read pyvenv.cfg
-rw-r--r-- | news/8717.bugfix | 1 | ||||
-rw-r--r-- | src/pip/_internal/utils/virtualenv.py | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/news/8717.bugfix b/news/8717.bugfix new file mode 100644 index 000000000..e8c8533c4 --- /dev/null +++ b/news/8717.bugfix @@ -0,0 +1 @@ +Always use UTF-8 to read ``pyvenv.cfg`` to match the built-in ``venv``. diff --git a/src/pip/_internal/utils/virtualenv.py b/src/pip/_internal/utils/virtualenv.py index 596a69a7d..4a7812873 100644 --- a/src/pip/_internal/utils/virtualenv.py +++ b/src/pip/_internal/utils/virtualenv.py @@ -1,5 +1,6 @@ from __future__ import absolute_import +import io import logging import os import re @@ -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 |