mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
fix unicode decode error on windows
This commit is contained in:
@@ -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):
|
||||
|
||||
Vendored
+8
-1
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user