Skip to content

Commit

Permalink
Fix richInspectVariables
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed May 30, 2022
1 parent 3f9ed67 commit a2ac60e
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions ipykernel/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,29 +577,10 @@ async def richInspectVariables(self, message):

repr_data = {}
repr_metadata = {}
if not self.stopped_threads:
# The code did not hit a breakpoint, we use the intepreter
# to get the rich representation of the variable
result = get_ipython().user_expressions({var_name: var_name})[var_name]
if result.get("status", "error") == "ok":
repr_data = result.get("data", {})
repr_metadata = result.get("metadata", {})
else:
# The code has stopped on a breakpoint, we use the setExpression
# request to get the rich representation of the variable
code = f"get_ipython().display_formatter.format({var_name})"
frame_id = message["arguments"]["frameId"]
seq = message["seq"]
reply = await self._forward_message(
{
"type": "request",
"command": "evaluate",
"seq": seq + 1,
"arguments": {"expression": code, "frameId": frame_id},
}
)
if reply["success"]:
repr_data, repr_metadata = eval(reply["body"]["result"], {}, {})
result = get_ipython().user_expressions({var_name: var_name})[var_name]
if result.get("status", "error") == "ok":
repr_data = result.get("data", {})
repr_metadata = result.get("metadata", {})

body = {
"data": repr_data,
Expand Down

0 comments on commit a2ac60e

Please sign in to comment.