diff --git a/pipenv/patched/pip/compat/__init__.py b/pipenv/patched/pip/compat/__init__.py index 099672cd..8fbdf439 100644 --- a/pipenv/patched/pip/compat/__init__.py +++ b/pipenv/patched/pip/compat/__init__.py @@ -4,6 +4,7 @@ from __future__ import absolute_import, division import os import sys +import locale from pip._vendor.six import text_type @@ -72,6 +73,10 @@ if sys.version_info >= (3,): try: return s.decode(sys.__stdout__.encoding) except UnicodeDecodeError: + if sys.__stdout__.encoding == 'utf-8': + encoding = locale.getdefaultlocale()[1] + if encoding is not None and encoding.lower() != 'utf-8': + return s.decode(encoding) return s.decode('utf_8') def native_str(s, replace=False): diff --git a/pipenv/vendor/delegator.py b/pipenv/vendor/delegator.py index e61413bc..70623c8b 100644 --- a/pipenv/vendor/delegator.py +++ b/pipenv/vendor/delegator.py @@ -2,6 +2,8 @@ import os import subprocess import shlex import signal +import sys +import locale from pexpect.popen_spawn import PopenSpawn @@ -46,9 +48,14 @@ class Command(object): @property def _default_pexpect_kwargs(self): + encoding = 'utf-8' + if sys.platform == 'win32': + default_encoding = locale.getdefaultlocale()[1] + if default_encoding is not None: + encoding = default_encoding return { 'env': os.environ.copy(), - 'encoding': 'utf-8', + 'encoding': encoding, 'timeout': self.timeout }