Skip to content

Commit 3a9e4b7

Browse files
committed
Removed filtering of stack frames for testing
1 parent 280fdfd commit 3a9e4b7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

ipykernel/debugger.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,17 +315,21 @@ async def source(self, message):
315315

316316
async def stackTrace(self, message):
317317
reply = await self._forward_message(message)
318-
# The stackFrames array has the following content:
318+
# The stackFrames array can have the following content:
319319
# { frames from the notebook}
320320
# ...
321321
# { 'id': xxx, 'name': '<module>', ... } <= this is the first frame of the code from the notebook
322322
# { frames from ipykernel }
323323
# ...
324324
# {'id': yyy, 'name': '<module>', ... } <= this is the first frame of ipykernel code
325-
# We want to remove all the frames from ipykernel
326-
sf_list = reply['body']['stackFrames']
327-
module_idx = len(sf_list) - next(i for i, v in enumerate(reversed(sf_list), 1) if v['name'] == '<module>' and i != 1)
328-
reply['body']['stackFrames'] = reply['body']['stackFrames'][:module_idx+1]
325+
# or only the frames from the notebook.
326+
# We want to remove all the frames from ipykernel when they are present.
327+
try:
328+
sf_list = reply['body']['stackFrames']
329+
module_idx = len(sf_list) - next(i for i, v in enumerate(reversed(sf_list), 1) if v['name'] == '<module>' and i != 1)
330+
reply['body']['stackFrames'] = reply['body']['stackFrames'][:module_idx+1]
331+
except StopIteration:
332+
pass
329333
return reply
330334

331335
def accept_variable(self, variable_name):

0 commit comments

Comments
 (0)