Skip to content

Commit

Permalink
Backport a bdb patch from https://bugs.python.org/issue16482
Browse files Browse the repository at this point in the history
This fixes an issue, noted in #90, where f_lineno would be reported
incorrectly, causing lines to be spuriously reported as breakpoints.

See also https://bugs.python.org/issue17697#msg186637 for a description of the
problem.
  • Loading branch information
asmeurer committed May 8, 2015
1 parent b979fc5 commit 6065d5a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pudb/debugger.py
Expand Up @@ -163,6 +163,34 @@ def __init__(self, steal_output=False):
for bpoint_descr in load_breakpoints():
self.set_break(*bpoint_descr)

# These (dispatch_line and set_continue) are copied from bdb with the
# patch from https://bugs.python.org/issue16482 applied. See
# https://github.com/inducer/pudb/pull/90.
def dispatch_line(self, frame):
if self.stop_here(frame) or self.break_here(frame):
self.user_line(frame)
if self.quitting: raise bdb.BdbQuit
# Do not re-install the local trace when we are finished debugging,
# see issues 16482 and 7238.
if not sys.gettrace():
return None
return self.trace_dispatch


def set_continue(self):
# Don't stop except at breakpoints or when finished
self._set_stopinfo(self.botframe, None, -1)
if not self.breaks:
# no breakpoints; run without debugger overhead
sys.settrace(None)
frame = sys._getframe().f_back
while frame:
del frame.f_trace
if frame is self.botframe:
break
frame = frame.f_back


def set_trace(self, frame=None, as_breakpoint=True):
"""Start debugging from `frame`.
Expand Down

0 comments on commit 6065d5a

Please sign in to comment.