Skip to content

Commit 0ffbf25

Browse files
authored
Merge pull request #702 from JohanMabille/inspect_variable
stringify variables that are not json serializable in inspectVariable…
2 parents b4352b8 + 4c45db4 commit 0ffbf25

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ipykernel/debugger.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from IPython.core.getipython import get_ipython
1414
import debugpy
1515

16+
from .jsonutil import json_clean
17+
1618
# Required for backwards compatiblity
1719
ROUTING_ID = getattr(zmq, 'ROUTING_ID', None) or zmq.IDENTITY
1820

@@ -417,9 +419,14 @@ async def inspectVariables(self, message):
417419
var_list = []
418420
for k, v in get_ipython().user_ns.items():
419421
if self.accept_variable(k):
422+
try:
423+
val = json_clean(v)
424+
425+
except ValueError:
426+
val = str(v)
420427
var_list.append({
421428
'name': k,
422-
'value': v,
429+
'value': val,
423430
'type': str(type(v))[8:-2],
424431
'variablesReference': 0
425432
})

0 commit comments

Comments
 (0)