File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -302,8 +302,17 @@ async def source(self, message):
302302
303303 async def stackTrace (self , message ):
304304 reply = await self ._forward_message (message )
305- reply ['body' ]['stackFrames' ] = \
306- [frame for frame in reply ['body' ]['stackFrames' ] if frame ['source' ]['path' ] != '<string>' ]
305+ # We stackFrames array has the following content:
306+ # { frames from the notebook}
307+ # ...
308+ # { 'id': xxx, 'name': '<module>', ... } <= this is the first frame of the code from the notebook
309+ # { frame from ipykernel }
310+ # ...
311+ # {'id': yyy, 'name': '<module>', ... } <= this is the first frame of ipykernel code
312+ # We want to remove all the frames from ipykernel
313+ sf_list = reply ['body' ]['stackFrames' ]
314+ module_idx = len (sf_list ) - next (i for i , v in enumerate (reversed (sf_list ), 1 ) if v ['name' ] == '<module>' and i != 1 )
315+ reply ['body' ]['stackFrames' ] = reply ['body' ]['stackFrames' ][:module_idx + 1 ]
307316 return reply
308317
309318 def accept_variable (self , variable ):
You can’t perform that action at this time.
0 commit comments