Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/4280.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a ``UnicodeDecodeError`` when try install some package on some non-english systems.
6 changes: 2 additions & 4 deletions pip/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import os
import sys
import locale

from pip._vendor.six import text_type

Expand Down Expand Up @@ -38,10 +39,7 @@

if sys.version_info >= (3,):
def console_to_str(s):
try:
return s.decode(sys.__stdout__.encoding)
except UnicodeDecodeError:
return s.decode('utf_8')
return s.decode(locale.getpreferredencoding() or "utf-8", 'replace')

def native_str(s, replace=False):
if isinstance(s, bytes):
Expand Down