diff --git a/Lib/bdb.py b/Lib/bdb.py index c6a10359ac..3590875333 100644 --- a/Lib/bdb.py +++ b/Lib/bdb.py @@ -4,6 +4,7 @@ import fnmatch import sys import os from inspect import CO_GENERATOR, CO_COROUTINE, CO_ASYNC_GENERATOR +import linecache, reprlib __all__ = ["BdbQuit", "Bdb", "Breakpoint"] @@ -89,7 +90,10 @@ class Bdb: if event == 'call': return self.dispatch_call(frame, arg) if event == 'return': - return self.dispatch_return(frame, arg) + res = self.dispatch_return(frame, arg) + if frame == self.botframe: + self.botframe = None + return res if event == 'exception': return self.dispatch_exception(frame, arg) if event == 'c_call': @@ -538,7 +542,6 @@ class Bdb: line of code (if it exists). """ - import linecache, reprlib frame, lineno = frame_lineno filename = self.canonic(frame.f_code.co_filename) s = '%s(%r)' % (filename, lineno)