Description
When an error occurs during display formatting, the traceback is displayed as error but execute_reply is marked as success.
Based on discussion in:
I suspect that this might have been lost in ipykernel unintentionally in or following #152. Since that PR did not include tests and removed exc_content[u'status'] = u'error' from _showtraceback replacing it with unified error handling, I think that either it or a subsequent regression in unified error handling made the traceback no longer mark execution as failed.
|
def _showtraceback(self, etype, evalue, stb): |
|
# try to preserve ordering of tracebacks and print statements |
|
sys.stdout.flush() |
|
sys.stderr.flush() |
|
|
|
exc_content = { |
|
"traceback": stb, |
|
"ename": str(etype.__name__), |
|
"evalue": str(evalue), |
|
} |
|
|
|
dh = self.displayhook |
|
# Send exception info over pub socket for other clients than the caller |
|
# to pick up |
|
topic = None |
|
if dh.topic: # type:ignore[attr-defined] |
|
topic = dh.topic.replace(b"execute_result", b"error") # type:ignore[attr-defined] |
|
|
|
dh.session.send( # type:ignore[attr-defined] |
|
dh.pub_socket, # type:ignore[attr-defined] |
|
"error", |
|
json_clean(exc_content), |
|
dh.parent_header, # type:ignore[attr-defined] |
|
ident=topic, |
|
) |
_showtraceback is relevant because in IPython formatters are decorated by @catch_format_error which displays any exception caught during the formatting routine using ip.showtraceback() delegated in subclasses - such as ipykernel's to _showtraceback().
Reproduce
Execute:
See status "error"
Then execute:
class Test:
def __repr__(self):
1 / 0
Test()
See status "ok":
Context
Noticed in:
Description
When an error occurs during display formatting, the traceback is displayed as error but
execute_replyis marked as success.Based on discussion in:
I suspect that this might have been lost in ipykernel unintentionally in or following #152. Since that PR did not include tests and removed
exc_content[u'status'] = u'error'from_showtracebackreplacing it with unified error handling, I think that either it or a subsequent regression in unified error handling made the traceback no longer mark execution as failed.ipykernel/ipykernel/zmqshell.py
Lines 666 to 690 in 2818b66
_showtracebackis relevant because in IPython formatters are decorated by@catch_format_errorwhich displays any exception caught during the formatting routine usingip.showtraceback()delegated in subclasses - such as ipykernel's to_showtraceback().Reproduce
Execute:
See status "error"
Then execute:
See status "ok":
Context
Noticed in:
__repr__method (and similar) deshaw/jupyterlab-notify#32