From 704527aacd3a7ec29b57a8bdc86ecb83e5e3f1bf 2015-04-06 17:35:21 From: Min RK Date: 2015-04-06 17:35:21 Subject: [PATCH] use stdout.encoding for decoding pretty bytes ensures correct decoding for objects that have queried sys.stdout.encoding for computing repr bytes. --- diff --git a/IPython/lib/pretty.py b/IPython/lib/pretty.py index 541d36c..c0553ea 100644 --- a/IPython/lib/pretty.py +++ b/IPython/lib/pretty.py @@ -112,6 +112,7 @@ import datetime from collections import deque from IPython.utils.py3compat import PY3, cast_unicode +from IPython.utils.encoding import get_stream_enc from io import StringIO @@ -140,7 +141,8 @@ else: class CUnicodeIO(StringIO): """StringIO that casts str to unicode on Python 2""" def write(self, text): - return super(CUnicodeIO, self).write(cast_unicode(text)) + return super(CUnicodeIO, self).write( + cast_unicode(text, encoding=get_stream_enc(sys.stdout))) def pretty(obj, verbose=False, max_width=79, newline='\n', max_seq_length=MAX_SEQ_LENGTH):