From 7cc97790ce8b1041fa5dc43b90ba9d74a4f7ffae Mon Sep 17 00:00:00 2001 From: y-p Date: Sun, 9 Dec 2012 15:27:40 +0200 Subject: [PATCH] ENH: try to detect encoding via sys.stdout first, then sys.stdin when redirected to a file stdout is None, in ipython zmq frontends stdin is None, and stdout (only recently in 0.14) is utf-8. https://github.com/ipython/ipython/issues/2500 --- pandas/core/format.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/format.py b/pandas/core/format.py index 97aa23191adaa..67de3d7fad354 100644 --- a/pandas/core/format.py +++ b/pandas/core/format.py @@ -1274,11 +1274,11 @@ def detect_console_encoding(): encoding = None try: - encoding=sys.stdin.encoding + encoding = sys.stdout.encoding or sys.stdin.encoding except AttributeError: pass - if not encoding or encoding =='ascii': # try again for something better + if not encoding or encoding == 'ascii': # try again for something better try: encoding = locale.getpreferredencoding() except Exception: