From d9d089759de900875c14133f9b0b8cd2318e4118 Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Mon, 16 Feb 2015 21:53:26 +0000 Subject: [PATCH] Fix websocket/zmq serialization to expect memoryviews --- IPython/html/base/zmqhandlers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IPython/html/base/zmqhandlers.py b/IPython/html/base/zmqhandlers.py index f1159e830..eedf71e80 100644 --- a/IPython/html/base/zmqhandlers.py +++ b/IPython/html/base/zmqhandlers.py @@ -43,6 +43,8 @@ def serialize_binary_message(msg): # don't modify msg or buffer list in-place msg = msg.copy() buffers = list(msg.pop('buffers')) + # for python 2, copy the buffer memoryviews to byte strings + buffers = [x.tobytes() for x in buffers] bmsg = json.dumps(msg, default=date_default).encode('utf8') buffers.insert(0, bmsg) nbufs = len(buffers)