diff --git a/IPython/utils/_process_win32.py b/IPython/utils/_process_win32.py index a1c7ccc..1d8bd94 100644 --- a/IPython/utils/_process_win32.py +++ b/IPython/utils/_process_win32.py @@ -88,9 +88,12 @@ def _find_cmd(cmd): def _system_body(p): """Callback for _system.""" + enc = sys.stdin.encoding or sys.getdefaultencoding() for line in read_no_interrupt(p.stdout).splitlines(): + line = line.decode(enc, 'replace') print(line, file=sys.stdout) for line in read_no_interrupt(p.stderr).splitlines(): + line = line.decode(enc, 'replace') print(line, file=sys.stderr) diff --git a/IPython/zmq/iostream.py b/IPython/zmq/iostream.py index 72756ba..55f0eeb 100644 --- a/IPython/zmq/iostream.py +++ b/IPython/zmq/iostream.py @@ -44,6 +44,10 @@ class OutStream(object): else: data = self._buffer.getvalue() if data: + # Make sure that we're handling unicode + if not isinstance(data, unicode): + enc = sys.stdin.encoding or sys.getdefaultencoding() + data = data.decode(enc, 'replace') content = {u'name':self.name, u'data':data} msg = self.session.send(self.pub_socket, u'stream', content=content,