From 8858f7eecc31f363ec8b391ac0d9698f99d556a5 2014-01-21 19:31:24 From: Thomas Kluyver Date: 2014-01-21 19:31:24 Subject: [PATCH] Merge pull request #4840 from dsblank/master Error in Session.send_raw() --- diff --git a/IPython/kernel/zmq/session.py b/IPython/kernel/zmq/session.py index eddf968..a9e1ec4 100644 --- a/IPython/kernel/zmq/session.py +++ b/IPython/kernel/zmq/session.py @@ -679,7 +679,7 @@ class Session(Configurable): to_send.append(DELIM) to_send.append(self.sign(msg_list)) to_send.extend(msg_list) - stream.send_multipart(msg_list, flags, copy=copy) + stream.send_multipart(to_send, flags, copy=copy) def recv(self, socket, mode=zmq.NOBLOCK, content=True, copy=True): """Receive and unpack a message. diff --git a/IPython/kernel/zmq/tests/test_session.py b/IPython/kernel/zmq/tests/test_session.py index 36c8d40..519b7d6 100644 --- a/IPython/kernel/zmq/tests/test_session.py +++ b/IPython/kernel/zmq/tests/test_session.py @@ -287,3 +287,27 @@ class TestSession(SessionTestCase): session = ss.Session(packer='msgpack.packb', unpacker='msgpack.unpackb') self._datetime_test(session) + def test_send_raw(self): + ctx = zmq.Context.instance() + A = ctx.socket(zmq.PAIR) + B = ctx.socket(zmq.PAIR) + A.bind("inproc://test") + B.connect("inproc://test") + + msg = self.session.msg('execute', content=dict(a=10)) + msg_list = [self.session.pack(msg[part]) for part in + ['header', 'parent_header', 'metadata', 'content']] + self.session.send_raw(A, msg_list, ident=b'foo') + + ident, new_msg_list = self.session.feed_identities(B.recv_multipart()) + new_msg = self.session.unserialize(new_msg_list) + self.assertEqual(ident[0], b'foo') + self.assertEqual(new_msg['msg_type'],msg['msg_type']) + self.assertEqual(new_msg['header'],msg['header']) + self.assertEqual(new_msg['parent_header'],msg['parent_header']) + self.assertEqual(new_msg['content'],msg['content']) + self.assertEqual(new_msg['metadata'],msg['metadata']) + + A.close() + B.close() + ctx.term()