summaryrefslogtreecommitdiff
path: root/Cython/Debugger/libpython.py
diff options
context:
space:
mode:
Diffstat (limited to 'Cython/Debugger/libpython.py')
-rw-r--r--Cython/Debugger/libpython.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Cython/Debugger/libpython.py b/Cython/Debugger/libpython.py
index 07a57a49c..b871756ee 100644
--- a/Cython/Debugger/libpython.py
+++ b/Cython/Debugger/libpython.py
@@ -59,9 +59,13 @@ import itertools
import gdb
-# I think this is the only way to fix this bug :'(
-# http://sourceware.org/bugzilla/show_bug.cgi?id=12285
-reload(sys).setdefaultencoding('UTF-8')
+if sys.version_info[0] < 3:
+ # I think this is the only way to fix this bug :'(
+ # http://sourceware.org/bugzilla/show_bug.cgi?id=12285
+ out, err = sys.stdout, sys.stderr
+ reload(sys).setdefaultencoding('UTF-8')
+ sys.stdout = out
+ sys.stderr = err
# Look up the gdb.Type for some standard types:
_type_char_ptr = gdb.lookup_type('char').pointer() # char*