Skip to content

Commit 85eb54a

Browse files
bzinbergstevengj
authored andcommitted
Fix Issue #815 (#816)
* Fix bug (I think): evaluate each of the user_expressions, rather than returning them untouched * Should have evaluated `ex`, not `code`. And ignoring SOFTSCOPE setting, as suggested in #816 (review) * Catch and report errors in evaluating user expressions, as suggested in #816 (comment) * whoops, didn't mean to use tab characters * Update implemantation of `user_expressions` to match the IPython reference implementation * whoops wrong status
1 parent 68748c2 commit 85eb54a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/execute_request.jl

+16-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,22 @@ function execute_request(socket, msg)
7979

8080
user_expressions = Dict()
8181
for (v,ex) in msg.content["user_expressions"]
82-
user_expressions[v] = invokelatest(parse, ex)
82+
try
83+
value = include_string(current_module[], ex)
84+
# Like the IPython reference implementation, we return
85+
# something that looks like a `display_data` but also has a
86+
# `status` field:
87+
# https://github.com/ipython/ipython/blob/master/IPython/core/interactiveshell.py#L2609-L2614
88+
user_expressions[v] = Dict("status" => "ok",
89+
"data" => display_dict(value),
90+
"metadata" => metadata(value))
91+
catch e
92+
# The format of user_expressions[v] is like `error` except that
93+
# it also has a `status` field:
94+
# https://jupyter-client.readthedocs.io/en/stable/messaging.html#execution-errors
95+
user_expressions[v] = Dict("status" => "error",
96+
error_content(e, catch_backtrace())...)
97+
end
8398
end
8499

85100
for hook in postexecute_hooks

0 commit comments

Comments
 (0)