Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b05010

Browse files
committed
Fix debugger tests: hide internal bdb frame if present
1 parent c2826a5 commit 0b05010

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

IPython/core/debugger.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,26 @@ def set_trace(self, frame=None):
353353
self.initial_frame = frame
354354
return super().set_trace(frame)
355355

356+
def get_stack(self, *args, **kwargs):
357+
stack, pos = super().get_stack(*args, **kwargs)
358+
if len(stack) >= 0 and self._is_internal_frame(stack[0][0]):
359+
stack.pop(0)
360+
pos -= 1
361+
return stack, pos
362+
363+
def _is_internal_frame(self, frame):
364+
"""Determine if this frame should be skipped as internal"""
365+
filename = frame.f_code.co_filename
366+
367+
# Skip bdb.py runcall and internal operations
368+
if filename.endswith("bdb.py"):
369+
func_name = frame.f_code.co_name
370+
# Skip internal bdb operations but allow breakpoint hits
371+
if func_name in ("runcall", "run", "runeval"):
372+
return True
373+
374+
return False
375+
356376
def _hidden_predicate(self, frame):
357377
"""
358378
Given a frame return whether it it should be hidden or not by IPython.
@@ -754,7 +774,7 @@ def print_list_lines(self, filename: str, first: int, last: int) -> None:
754774
bp,
755775
(Token.LinenoEm, num),
756776
(Token, " "),
757-
# TODO: invsetigate Toke.Line here
777+
# TODO: investigate Token.Line here
758778
(Token, colored_line),
759779
]
760780
)

0 commit comments

Comments
 (0)