Skip to content
Browse files

Use 'UTF-8' as the `encoding` attribute in `OutStream` class.

This means that `sys.stdout.encoding` returns something useful instead
of raising an AttributeError. 'UTF-8' was chosen because our version of
write actually wants a unicode string (i.e., not `bytes`) and we want
something universal which an encode the entire range of unicode characters.
  • Loading branch information...
1 parent d66b481 commit f1c11554dead345a3300aad1b3a12e3e9d72310c @bfroehle committed
Showing with 4 additions and 4 deletions.
  1. +4 −4 IPython/zmq/iostream.py
View
8 IPython/zmq/iostream.py
@@ -4,7 +4,7 @@
from session import extract_header, Message
-from IPython.utils import io, text, encoding
+from IPython.utils import io, text
from IPython.utils import py3compat
#-----------------------------------------------------------------------------
@@ -23,6 +23,7 @@ class OutStream(object):
topic=None
def __init__(self, session, pub_socket, name):
+ self.encoding = 'UTF-8'
self.session = session
self.pub_socket = pub_socket
self.name = name
@@ -73,9 +74,8 @@ def write(self, string):
else:
# Make sure that we're handling unicode
if not isinstance(string, unicode):
- enc = encoding.DEFAULT_ENCODING
- string = string.decode(enc, 'replace')
-
+ string = string.decode(self.encoding, 'replace')
+
self._buffer.write(string)
current_time = time.time()
if self._start <= 0:

0 comments on commit f1c1155

Please sign in to comment.
Something went wrong with that request. Please try again.