Show More
@@ -225,10 +225,13 b' var IPython = (function (IPython) {' | |||||
225 | json.output_type = "pyout"; |
|
225 | json.output_type = "pyout"; | |
226 | json.metadata = content.metadata; |
|
226 | json.metadata = content.metadata; | |
227 | json.prompt_number = content.execution_count; |
|
227 | json.prompt_number = content.execution_count; | |
228 |
} else if (msg_type === " |
|
228 | } else if (msg_type === "error") { | |
229 | json.ename = content.ename; |
|
229 | // pyerr message has been renamed to error, | |
230 | json.evalue = content.evalue; |
|
230 | // but the nbformat has not been updated, | |
231 | json.traceback = content.traceback; |
|
231 | // so transform back to pyerr for json. | |
|
232 | json.output_type = "pyerr"; | |||
|
233 | json = this.convert_mime_types(json, content.data); | |||
|
234 | json.metadata = this.convert_mime_types({}, content.metadata); | |||
232 | } |
|
235 | } | |
233 | this.append_output(json); |
|
236 | this.append_output(json); | |
234 | }; |
|
237 | }; | |
@@ -285,7 +288,7 b' var IPython = (function (IPython) {' | |||||
285 | if (json.output_type === 'pyout') { |
|
288 | if (json.output_type === 'pyout') { | |
286 | this.append_execute_result(json); |
|
289 | this.append_execute_result(json); | |
287 | } else if (json.output_type === 'pyerr') { |
|
290 | } else if (json.output_type === 'pyerr') { | |
288 |
this.append_ |
|
291 | this.append_error(json); | |
289 | } else if (json.output_type === 'stream') { |
|
292 | } else if (json.output_type === 'stream') { | |
290 | this.append_stream(json); |
|
293 | this.append_stream(json); | |
291 | } |
|
294 | } | |
@@ -425,7 +428,7 b' var IPython = (function (IPython) {' | |||||
425 | }; |
|
428 | }; | |
426 |
|
429 | |||
427 |
|
430 | |||
428 |
OutputArea.prototype.append_ |
|
431 | OutputArea.prototype.append_error = function (json) { | |
429 | var tb = json.traceback; |
|
432 | var tb = json.traceback; | |
430 | if (tb !== undefined && tb.length > 0) { |
|
433 | if (tb !== undefined && tb.length > 0) { | |
431 | var s = ''; |
|
434 | var s = ''; |
@@ -76,13 +76,13 b' var IPython = (function (IPython) {' | |||||
76 | // Initialize the iopub handlers |
|
76 | // Initialize the iopub handlers | |
77 |
|
77 | |||
78 | Kernel.prototype.init_iopub_handlers = function () { |
|
78 | Kernel.prototype.init_iopub_handlers = function () { | |
79 |
var output_types = ['stream', 'display_data', 'execute_result', ' |
|
79 | var output_msg_types = ['stream', 'display_data', 'execute_result', 'error']; | |
80 | this._iopub_handlers = {}; |
|
80 | this._iopub_handlers = {}; | |
81 | this.register_iopub_handler('status', $.proxy(this._handle_status_message, this)); |
|
81 | this.register_iopub_handler('status', $.proxy(this._handle_status_message, this)); | |
82 | this.register_iopub_handler('clear_output', $.proxy(this._handle_clear_output, this)); |
|
82 | this.register_iopub_handler('clear_output', $.proxy(this._handle_clear_output, this)); | |
83 |
|
83 | |||
84 | for (var i=0; i < output_types.length; i++) { |
|
84 | for (var i=0; i < output_msg_types.length; i++) { | |
85 | this.register_iopub_handler(output_types[i], $.proxy(this._handle_output_message, this)); |
|
85 | this.register_iopub_handler(output_msg_types[i], $.proxy(this._handle_output_message, this)); | |
86 | } |
|
86 | } | |
87 | }; |
|
87 | }; | |
88 |
|
88 |
@@ -165,7 +165,7 b' class ExecuteInput(Reference):' | |||||
165 | execution_count = Integer() |
|
165 | execution_count = Integer() | |
166 |
|
166 | |||
167 |
|
167 | |||
168 |
|
|
168 | Error = ExecuteReplyError | |
169 |
|
169 | |||
170 |
|
170 | |||
171 | class Stream(Reference): |
|
171 | class Stream(Reference): | |
@@ -202,7 +202,7 b' references = {' | |||||
202 | 'kernel_info_reply': KernelInfoReply(), |
|
202 | 'kernel_info_reply': KernelInfoReply(), | |
203 | 'execute_input' : ExecuteInput(), |
|
203 | 'execute_input' : ExecuteInput(), | |
204 | 'execute_result' : ExecuteResult(), |
|
204 | 'execute_result' : ExecuteResult(), | |
205 |
' |
|
205 | 'error' : Error(), | |
206 | 'stream' : Stream(), |
|
206 | 'stream' : Stream(), | |
207 | 'display_data' : DisplayData(), |
|
207 | 'display_data' : DisplayData(), | |
208 | 'header' : RHeader(), |
|
208 | 'header' : RHeader(), | |
@@ -276,8 +276,8 b' def test_execute_error():' | |||||
276 | nt.assert_equal(reply['status'], 'error') |
|
276 | nt.assert_equal(reply['status'], 'error') | |
277 | nt.assert_equal(reply['ename'], 'ZeroDivisionError') |
|
277 | nt.assert_equal(reply['ename'], 'ZeroDivisionError') | |
278 |
|
278 | |||
279 |
|
|
279 | error = KC.iopub_channel.get_msg(timeout=TIMEOUT) | |
280 |
validate_message( |
|
280 | validate_message(error, 'error', msg_id) | |
281 |
|
281 | |||
282 |
|
282 | |||
283 | def test_execute_inc(): |
|
283 | def test_execute_inc(): |
@@ -628,8 +628,8 b' class Kernel(Configurable):' | |||||
628 | # reset after use |
|
628 | # reset after use | |
629 | shell._reply_content = None |
|
629 | shell._reply_content = None | |
630 |
|
630 | |||
631 |
self.session.send(self.iopub_socket, u' |
|
631 | self.session.send(self.iopub_socket, u'error', reply_content, parent=parent, | |
632 |
ident=self._topic(' |
|
632 | ident=self._topic('error')) | |
633 | self.log.info("Exception in apply request:\n%s", '\n'.join(reply_content['traceback'])) |
|
633 | self.log.info("Exception in apply request:\n%s", '\n'.join(reply_content['traceback'])) | |
634 | result_buf = [] |
|
634 | result_buf = [] | |
635 |
|
635 |
@@ -1,26 +1,19 b'' | |||||
1 | """An Application for launching a kernel |
|
1 | """An Application for launching a kernel""" | |
2 | """ |
|
2 | ||
3 | # Copyright (c) IPython Development Team. |
|
3 | # Copyright (c) IPython Development Team. | |
4 | # Distributed under the terms of the Modified BSD License. |
|
4 | # Distributed under the terms of the Modified BSD License. | |
5 |
|
5 | |||
6 | #----------------------------------------------------------------------------- |
|
|||
7 | # Imports |
|
|||
8 | #----------------------------------------------------------------------------- |
|
|||
9 |
|
||||
10 | from __future__ import print_function |
|
6 | from __future__ import print_function | |
11 |
|
7 | |||
12 | # Standard library imports |
|
|||
13 | import atexit |
|
8 | import atexit | |
14 | import os |
|
9 | import os | |
15 | import sys |
|
10 | import sys | |
16 | import signal |
|
11 | import signal | |
17 |
|
12 | |||
18 | # System library imports |
|
|||
19 | import zmq |
|
13 | import zmq | |
20 | from zmq.eventloop import ioloop |
|
14 | from zmq.eventloop import ioloop | |
21 | from zmq.eventloop.zmqstream import ZMQStream |
|
15 | from zmq.eventloop.zmqstream import ZMQStream | |
22 |
|
16 | |||
23 | # IPython imports |
|
|||
24 | from IPython.core.ultratb import FormattedTB |
|
17 | from IPython.core.ultratb import FormattedTB | |
25 | from IPython.core.application import ( |
|
18 | from IPython.core.application import ( | |
26 | BaseIPythonApplication, base_flags, base_aliases, catch_config_error |
|
19 | BaseIPythonApplication, base_flags, base_aliases, catch_config_error | |
@@ -353,7 +346,7 b' class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,' | |||||
353 | shell = self.shell |
|
346 | shell = self.shell | |
354 | _showtraceback = shell._showtraceback |
|
347 | _showtraceback = shell._showtraceback | |
355 | try: |
|
348 | try: | |
356 |
# replace |
|
349 | # replace error-sending traceback with stderr | |
357 | def print_tb(etype, evalue, stb): |
|
350 | def print_tb(etype, evalue, stb): | |
358 | print ("GUI event loop or pylab initialization failed", |
|
351 | print ("GUI event loop or pylab initialization failed", | |
359 | file=io.stderr) |
|
352 | file=io.stderr) |
@@ -510,9 +510,9 b' class ZMQInteractiveShell(InteractiveShell):' | |||||
510 | # to pick up |
|
510 | # to pick up | |
511 | topic = None |
|
511 | topic = None | |
512 | if dh.topic: |
|
512 | if dh.topic: | |
513 |
topic = dh.topic.replace(b'execute_result', b' |
|
513 | topic = dh.topic.replace(b'execute_result', b'error') | |
514 |
|
514 | |||
515 |
exc_msg = dh.session.send(dh.pub_socket, u' |
|
515 | exc_msg = dh.session.send(dh.pub_socket, u'error', json_clean(exc_content), dh.parent_header, ident=topic) | |
516 |
|
516 | |||
517 | # FIXME - Hack: store exception info in shell object. Right now, the |
|
517 | # FIXME - Hack: store exception info in shell object. Right now, the | |
518 | # caller is reading this info after the fact, we need to fix this logic |
|
518 | # caller is reading this info after the fact, we need to fix this logic |
@@ -171,7 +171,7 b' class Metadata(dict):' | |||||
171 |
|
171 | |||
172 | 'execute_input' : None, |
|
172 | 'execute_input' : None, | |
173 | 'execute_result' : None, |
|
173 | 'execute_result' : None, | |
174 |
' |
|
174 | 'error' : None, | |
175 | 'stdout' : '', |
|
175 | 'stdout' : '', | |
176 | 'stderr' : '', |
|
176 | 'stderr' : '', | |
177 | 'outputs' : [], |
|
177 | 'outputs' : [], | |
@@ -869,8 +869,8 b' class Client(HasTraits):' | |||||
869 | name = content['name'] |
|
869 | name = content['name'] | |
870 | s = md[name] or '' |
|
870 | s = md[name] or '' | |
871 | md[name] = s + content['data'] |
|
871 | md[name] = s + content['data'] | |
872 |
elif msg_type == ' |
|
872 | elif msg_type == 'error': | |
873 |
md.update({' |
|
873 | md.update({'error' : self._unwrap_exception(content)}) | |
874 | elif msg_type == 'execute_input': |
|
874 | elif msg_type == 'execute_input': | |
875 | md.update({'execute_input' : content['code']}) |
|
875 | md.update({'execute_input' : content['code']}) | |
876 | elif msg_type == 'display_data': |
|
876 | elif msg_type == 'display_data': |
@@ -68,7 +68,7 b' def empty_record():' | |||||
68 | 'queue' : None, |
|
68 | 'queue' : None, | |
69 | 'execute_input' : None, |
|
69 | 'execute_input' : None, | |
70 | 'execute_result': None, |
|
70 | 'execute_result': None, | |
71 |
' |
|
71 | 'error': None, | |
72 | 'stdout': '', |
|
72 | 'stdout': '', | |
73 | 'stderr': '', |
|
73 | 'stderr': '', | |
74 | } |
|
74 | } | |
@@ -96,7 +96,7 b' def init_record(msg):' | |||||
96 | 'queue' : None, |
|
96 | 'queue' : None, | |
97 | 'execute_input' : None, |
|
97 | 'execute_input' : None, | |
98 | 'execute_result': None, |
|
98 | 'execute_result': None, | |
99 |
' |
|
99 | 'error': None, | |
100 | 'stdout': '', |
|
100 | 'stdout': '', | |
101 | 'stderr': '', |
|
101 | 'stderr': '', | |
102 | } |
|
102 | } | |
@@ -865,8 +865,8 b' class Hub(SessionFactory):' | |||||
865 | s = rec[name] or '' |
|
865 | s = rec[name] or '' | |
866 | d[name] = s + content['data'] |
|
866 | d[name] = s + content['data'] | |
867 |
|
867 | |||
868 |
elif msg_type == ' |
|
868 | elif msg_type == 'error': | |
869 |
d[' |
|
869 | d['error'] = content | |
870 | elif msg_type == 'execute_input': |
|
870 | elif msg_type == 'execute_input': | |
871 | d['execute_input'] = content['code'] |
|
871 | d['execute_input'] = content['code'] | |
872 | elif msg_type in ('display_data', 'execute_result'): |
|
872 | elif msg_type in ('display_data', 'execute_result'): | |
@@ -1316,7 +1316,7 b' class Hub(SessionFactory):' | |||||
1316 | def _extract_record(self, rec): |
|
1316 | def _extract_record(self, rec): | |
1317 | """decompose a TaskRecord dict into subsection of reply for get_result""" |
|
1317 | """decompose a TaskRecord dict into subsection of reply for get_result""" | |
1318 | io_dict = {} |
|
1318 | io_dict = {} | |
1319 |
for key in ('execute_input', 'execute_result', ' |
|
1319 | for key in ('execute_input', 'execute_result', 'error', 'stdout', 'stderr'): | |
1320 | io_dict[key] = rec[key] |
|
1320 | io_dict[key] = rec[key] | |
1321 | content = { |
|
1321 | content = { | |
1322 | 'header': rec['header'], |
|
1322 | 'header': rec['header'], |
@@ -122,7 +122,7 b' class SQLiteDB(BaseDB):' | |||||
122 | 'queue' , |
|
122 | 'queue' , | |
123 | 'execute_input' , |
|
123 | 'execute_input' , | |
124 | 'execute_result', |
|
124 | 'execute_result', | |
125 |
' |
|
125 | 'error', | |
126 | 'stdout', |
|
126 | 'stdout', | |
127 | 'stderr', |
|
127 | 'stderr', | |
128 | ]) |
|
128 | ]) | |
@@ -146,7 +146,7 b' class SQLiteDB(BaseDB):' | |||||
146 | 'queue' : 'text', |
|
146 | 'queue' : 'text', | |
147 | 'execute_input' : 'text', |
|
147 | 'execute_input' : 'text', | |
148 | 'execute_result' : 'text', |
|
148 | 'execute_result' : 'text', | |
149 |
' |
|
149 | 'error' : 'text', | |
150 | 'stdout' : 'text', |
|
150 | 'stdout' : 'text', | |
151 | 'stderr' : 'text', |
|
151 | 'stderr' : 'text', | |
152 | }) |
|
152 | }) | |
@@ -257,7 +257,7 b' class SQLiteDB(BaseDB):' | |||||
257 | queue text, |
|
257 | queue text, | |
258 | execute_input text, |
|
258 | execute_input text, | |
259 | execute_result text, |
|
259 | execute_result text, | |
260 |
|
|
260 | error text, | |
261 | stdout text, |
|
261 | stdout text, | |
262 | stderr text) |
|
262 | stderr text) | |
263 | """%self.table) |
|
263 | """%self.table) |
@@ -91,8 +91,8 b' class QtIOPubChannelMixin(ChannelQObject):' | |||||
91 | # Emitted when a message of type 'execute_result' is received. |
|
91 | # Emitted when a message of type 'execute_result' is received. | |
92 | execute_result_received = QtCore.Signal(object) |
|
92 | execute_result_received = QtCore.Signal(object) | |
93 |
|
93 | |||
94 |
# Emitted when a message of type ' |
|
94 | # Emitted when a message of type 'error' is received. | |
95 |
|
|
95 | error_received = QtCore.Signal(object) | |
96 |
|
96 | |||
97 | # Emitted when a message of type 'display_data' is received |
|
97 | # Emitted when a message of type 'display_data' is received | |
98 | display_data_received = QtCore.Signal(object) |
|
98 | display_data_received = QtCore.Signal(object) |
General Comments 0
You need to be logged in to leave comments.
Login now