Do not allow the evaluation of the exit code strings (i.e., "Quit", "Exit", "quit", and "exit")

This commit is contained in:
cc-wr 2019-12-05 08:22:12 -05:00
parent e006c4f7e1
commit 1607ff07cd

View File

@ -123,11 +123,16 @@ If[
If[
loopState["isCompleteRequestSent"],
loopState["redirectMessages"] = True;
loopState["askExit"] =
If[
StringMatchQ[
loopState["frameAssoc"]["content"]["code"],
"Quit" | "Exit" | "quit" | "exit"
];
],
loopState["replyMsgType"] = "execute_reply";
(* NOTE: uses payloads *)
loopState["replyContent"] = ExportString[Association["status" -> "ok", "execution_count" -> loopState["executionCount"], "user_expressions" -> {}, "payload" -> {Association["source" -> "ask_exit", "keepkernel" -> False]}], "JSON", "Compact" -> True];
Return[];
];
];
(* redirect Print so that it prints in the Jupyter notebook *)
@ -171,6 +176,7 @@ If[
"user_expressions" -> {},
(* see https://jupyter-client.readthedocs.io/en/stable/messaging.html#payloads-deprecated *)
(* if the "askExit" flag is True, add an "ask_exit" payload *)
(* NOTE: uses payloads *)
"payload" -> If[loopState["askExit"], {Association["source" -> "ask_exit", "keepkernel" -> False]}, {}]
],
"JSON",