From d4b39a336f91ccef496eccd86b14a774a6110231 2015-02-16 19:53:30 From: Jason Grout Date: 2015-02-16 19:53:30 Subject: [PATCH] Extract session buffers as memoryviews A bug in pyzmq forces us to have a workaround, which can be deleted when the pyzmq dependency is upgraded to fix pyzmq issue #646. Thanks to @minrk for helping work on the code and also for the bugfix in pyzmq. --- diff --git a/IPython/kernel/zmq/session.py b/IPython/kernel/zmq/session.py index 16582bb..389fdf5 100644 --- a/IPython/kernel/zmq/session.py +++ b/IPython/kernel/zmq/session.py @@ -842,8 +842,11 @@ class Session(Configurable): message['content'] = self.unpack(msg_list[4]) else: message['content'] = msg_list[4] - - message['buffers'] = msg_list[5:] + buffers = [memoryview(b) for b in msg_list[5:]] + if buffers and buffers[0].shape is None: + # force copy to workaround pyzmq #646 + buffers = [memoryview(b.bytes) for b in msg_list[5:]] + message['buffers'] = buffers # adapt to the current version return adapt(message)