##// END OF EJS Templates
msgspec 5: stream.data -> stream.text
MinRK -
Show More
@@ -210,7 +210,7 b' define(['
210 210 var msg_type = json.output_type = msg.header.msg_type;
211 211 var content = msg.content;
212 212 if (msg_type === "stream") {
213 json.text = content.data;
213 json.text = content.text;
214 214 json.stream = content.name;
215 215 } else if (msg_type === "display_data") {
216 216 json = content.data;
@@ -163,6 +163,11 b' class V5toV4(Adapter):'
163 163
164 164 # iopub channel
165 165
166 def stream(self, msg):
167 content = msg['content']
168 content['data'] = content.pop('text')
169 return msg
170
166 171 def display_data(self, msg):
167 172 content = msg['content']
168 173 content.setdefault("source", "display")
@@ -287,6 +292,11 b' class V4toV5(Adapter):'
287 292
288 293 # iopub channel
289 294
295 def stream(self, msg):
296 content = msg['content']
297 content['text'] = content.pop('data')
298 return msg
299
290 300 def display_data(self, msg):
291 301 content = msg['content']
292 302 content.pop("source", None)
@@ -1,20 +1,11 b''
1 #-------------------------------------------------------------------------------
2 # Copyright (C) 2012 The IPython Development Team
3 #
4 # Distributed under the terms of the BSD License. The full license is in
5 # the file COPYING, distributed as part of this software.
6 #-------------------------------------------------------------------------------
1 # Copyright (c) IPython Development Team.
2 # Distributed under the terms of the Modified BSD License.
7 3
8 #-----------------------------------------------------------------------------
9 # Imports
10 #-----------------------------------------------------------------------------
11 4 from __future__ import print_function
12 5
13 # Standard library imports
14 6 import sys
15 7 import unittest
16 8
17 # Local imports
18 9 from IPython.kernel.inprocess.blocking import BlockingInProcessKernelClient
19 10 from IPython.kernel.inprocess.manager import InProcessKernelManager
20 11 from IPython.kernel.inprocess.ipkernel import InProcessKernel
@@ -27,9 +18,6 b' if py3compat.PY3:'
27 18 else:
28 19 from StringIO import StringIO
29 20
30 #-----------------------------------------------------------------------------
31 # Test case
32 #-----------------------------------------------------------------------------
33 21
34 22 class InProcessKernelTestCase(unittest.TestCase):
35 23
@@ -41,12 +29,11 b' class InProcessKernelTestCase(unittest.TestCase):'
41 29
42 30 @skipif_not_matplotlib
43 31 def test_pylab(self):
44 """ Does pylab work in the in-process kernel?
45 """
32 """Does %pylab work in the in-process kernel?"""
46 33 kc = self.kc
47 34 kc.execute('%pylab')
48 35 msg = get_stream_message(kc)
49 self.assertIn('matplotlib', msg['content']['data'])
36 self.assertIn('matplotlib', msg['content']['text'])
50 37
51 38 def test_raw_input(self):
52 39 """ Does the in-process kernel handle raw_input correctly?
@@ -76,7 +63,7 b' class InProcessKernelTestCase(unittest.TestCase):'
76 63 kernel.frontends.append(kc)
77 64 kc.shell_channel.execute('print("bar")')
78 65 msg = get_stream_message(kc)
79 self.assertEqual(msg['content']['data'], 'bar\n')
66 self.assertEqual(msg['content']['text'], 'bar\n')
80 67
81 68 #-----------------------------------------------------------------------------
82 69 # Utility functions
@@ -172,7 +172,7 b' Error = ExecuteReplyError'
172 172
173 173 class Stream(Reference):
174 174 name = Enum((u'stdout', u'stderr'))
175 data = Unicode()
175 text = Unicode()
176 176
177 177
178 178 class DisplayData(MimeBundle):
@@ -394,7 +394,7 b' def test_stream():'
394 394 stdout = KC.iopub_channel.get_msg(timeout=TIMEOUT)
395 395 validate_message(stdout, 'stream', msg_id)
396 396 content = stdout['content']
397 nt.assert_equal(content['data'], u'hi\n')
397 nt.assert_equal(content['text'], u'hi\n')
398 398
399 399
400 400 def test_display_data():
@@ -140,9 +140,9 b' def assemble_output(iopub):'
140 140 break
141 141 elif msg['msg_type'] == 'stream':
142 142 if content['name'] == 'stdout':
143 stdout += content['data']
143 stdout += content['text']
144 144 elif content['name'] == 'stderr':
145 stderr += content['data']
145 stderr += content['text']
146 146 else:
147 147 raise KeyError("bad stream: %r" % content['name'])
148 148 else:
@@ -163,7 +163,7 b' class OutStream(object):'
163 163 data = self._flush_buffer()
164 164
165 165 if data:
166 content = {u'name':self.name, u'data':data}
166 content = {u'name':self.name, u'text':data}
167 167 msg = self.session.send(self.pub_socket, u'stream', content=content,
168 168 parent=self.parent_header, ident=self.topic)
169 169
@@ -123,7 +123,7 b' class ExecutePreprocessor(Preprocessor):'
123 123
124 124 if msg_type == 'stream':
125 125 out.stream = content['name']
126 out.text = content['data']
126 out.text = content['text']
127 127 elif msg_type in ('display_data', 'execute_result'):
128 128 out['metadata'] = content['metadata']
129 129 for mime, data in content['data'].items():
@@ -874,7 +874,7 b' class Client(HasTraits):'
874 874 if msg_type == 'stream':
875 875 name = content['name']
876 876 s = md[name] or ''
877 md[name] = s + content['data']
877 md[name] = s + content['text']
878 878 elif msg_type == 'error':
879 879 md.update({'error' : self._unwrap_exception(content)})
880 880 elif msg_type == 'execute_input':
@@ -862,7 +862,7 b' class Hub(SessionFactory):'
862 862 if msg_type == 'stream':
863 863 name = content['name']
864 864 s = '' if rec is None else rec[name]
865 d[name] = s + content['data']
865 d[name] = s + content['text']
866 866
867 867 elif msg_type == 'error':
868 868 d['error'] = content
@@ -531,7 +531,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
531 531 self.log.debug("stream: %s", msg.get('content', ''))
532 532 if not self._hidden and self._is_from_this_session(msg):
533 533 self.flush_clearoutput()
534 self.append_stream(msg['content']['data'])
534 self.append_stream(msg['content']['text'])
535 535
536 536 def _handle_shutdown_reply(self, msg):
537 537 """ Handle shutdown signal, only if from other console.
@@ -235,13 +235,13 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
235 235 if self._pending_clearoutput:
236 236 print("\r", file=io.stdout, end="")
237 237 self._pending_clearoutput = False
238 print(sub_msg["content"]["data"], file=io.stdout, end="")
238 print(sub_msg["content"]["text"], file=io.stdout, end="")
239 239 io.stdout.flush()
240 elif sub_msg["content"]["name"] == "stderr" :
240 elif sub_msg["content"]["name"] == "stderr":
241 241 if self._pending_clearoutput:
242 242 print("\r", file=io.stderr, end="")
243 243 self._pending_clearoutput = False
244 print(sub_msg["content"]["data"], file=io.stderr, end="")
244 print(sub_msg["content"]["text"], file=io.stderr, end="")
245 245 io.stderr.flush()
246 246
247 247 elif msg_type == 'execute_result':
@@ -711,10 +711,14 b' Message type: ``stream``::'
711 711 # The name of the stream is one of 'stdout', 'stderr'
712 712 'name' : str,
713 713
714 # The data is an arbitrary string to be written to that stream
715 'data' : str,
714 # The text is an arbitrary string to be written to that stream
715 'text' : str,
716 716 }
717 717
718 .. versionchanged:: 5.0
719
720 'data' key renamed to 'text' for conistency with the notebook format.
721
718 722 Display Data
719 723 ------------
720 724
General Comments 0
You need to be logged in to leave comments. Login now