##// END OF EJS Templates
Improve robustness, as suggested by Min.
Thomas Kluyver -
Show More
@@ -88,12 +88,12 b' def _find_cmd(cmd):'
88
88
89 def _system_body(p):
89 def _system_body(p):
90 """Callback for _system."""
90 """Callback for _system."""
91 enc = sys.stdin.encoding
91 enc = sys.stdin.encoding or sys.getdefaultencoding()
92 for line in read_no_interrupt(p.stdout).splitlines():
92 for line in read_no_interrupt(p.stdout).splitlines():
93 line = line.decode(enc)
93 line = line.decode(enc, 'replace')
94 print(line, file=sys.stdout)
94 print(line, file=sys.stdout)
95 for line in read_no_interrupt(p.stderr).splitlines():
95 for line in read_no_interrupt(p.stderr).splitlines():
96 line = line.decode(enc)
96 line = line.decode(enc, 'replace')
97 print(line, file=sys.stderr)
97 print(line, file=sys.stderr)
98
98
99
99
@@ -44,6 +44,10 b' class OutStream(object):'
44 else:
44 else:
45 data = self._buffer.getvalue()
45 data = self._buffer.getvalue()
46 if data:
46 if data:
47 # Make sure that we're handling unicode
48 if not isinstance(data, unicode):
49 enc = sys.stdin.encoding or sys.getdefaultencoding()
50 data = data.decode(enc, 'replace')
47 content = {u'name':self.name, u'data':data}
51 content = {u'name':self.name, u'data':data}
48 msg = self.session.send(self.pub_socket, u'stream',
52 msg = self.session.send(self.pub_socket, u'stream',
49 content=content,
53 content=content,
General Comments 0
You need to be logged in to leave comments. Login now