##// END OF EJS Templates
Encode to byte before base64.decodestring
Takafumi Arakaki -
Show More
@@ -265,12 +265,12 class ZMQTerminalInteractiveShell(TerminalInteractiveShell):
265 265 if mime not in ('image/png', 'image/jpeg'):
266 266 return
267 267 import PIL
268 raw = base64.decodestring(data[mime])
268 raw = base64.decodestring(data[mime].encode('ascii'))
269 269 img = PIL.Image.open(BytesIO(raw))
270 270 img.show()
271 271
272 272 def handle_image_stream(self, data, mime):
273 raw = base64.decodestring(data[mime])
273 raw = base64.decodestring(data[mime].encode('ascii'))
274 274 imageformat = self._imagemime[mime]
275 275 fmt = dict(format=imageformat)
276 276 args = [s.format(**fmt) for s in self.stream_image_handler]
@@ -281,7 +281,7 class ZMQTerminalInteractiveShell(TerminalInteractiveShell):
281 281 proc.communicate(raw)
282 282
283 283 def handle_image_tempfile(self, data, mime):
284 raw = base64.decodestring(data[mime])
284 raw = base64.decodestring(data[mime].encode('ascii'))
285 285 imageformat = self._imagemime[mime]
286 286 filename = 'tmp.{0}'.format(imageformat)
287 287 with nested(NamedFileInTemporaryDirectory(filename),
@@ -30,7 +30,7 class ZMQTerminalInteractiveShellTestCase(unittest.TestCase):
30 30 self.shell = ZMQTerminalInteractiveShell(kernel_manager=km)
31 31 self.raw = b'dummy data'
32 32 self.mime = 'image/png'
33 self.data = {self.mime: base64.encodestring(self.raw)}
33 self.data = {self.mime: base64.encodestring(self.raw).decode('ascii')}
34 34
35 35 def test_no_call_by_default(self):
36 36 def raise_if_called(*args, **kwds):
General Comments 0
You need to be logged in to leave comments. Login now