Skip to content

Commit

Permalink
Fix case of spurious line events with IPython. Fixes microsoft#854
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Feb 26, 2022
1 parent 796f63e commit 5429cde
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,14 +898,17 @@ def trace_dispatch(self, frame, event, arg):
elif breakpoint.is_logpoint:
stop = False

if is_call and frame.f_code.co_name in ('<module>', '<lambda>'):
if is_call and (frame.f_code.co_name == '<lambda>' or (line == 1 and frame.f_code.co_name.startswith(('<module>', '<cell')))):
# If we find a call for a module, it means that the module is being imported/executed for the
# first time. In this case we have to ignore this hit as it may later duplicated by a
# line event at the same place (so, if there's a module with a print() in the first line
# the user will hit that line twice, which is not what we want).
#
# As for lambda, as it only has a single statement, it's not interesting to trace
# For lambda, as it only has a single statement, it's not interesting to trace
# its call and later its line event as they're usually in the same line.
#
# For ipython, <cell xxx> may be executed having each line compiled as a new
# module, so it's the same case as <module>.

return self.trace_dispatch

Expand Down

0 comments on commit 5429cde

Please sign in to comment.