From 561d3c129921128e12ffe90cd49df9f606af02db Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 15 Nov 2019 01:25:12 +0100 Subject: [PATCH 1/2] bpo-38806: bdb: stop_here: always stop at calling frame The following will not stop for debugging: python3.8 -c 'import pdb; pdb.Pdb(skip=["*"]).set_trace()' The example is contrived, the real case would be to have some "noisy" module being excluded in general, but when you add an explicit "set_trace()" in there it should still stop there, and not on some upper frame. This was changed a long time already in https://github.com/python/cpython/commit/313a7513b0c5771042d850d70782a2448d1cdcb7 (Python 2.3), but it is not really clear. This PR is meant to see how reverting that part goes. --- Lib/bdb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/bdb.py b/Lib/bdb.py index 75d6113576372e..59a3bdc5f9033b 100644 --- a/Lib/bdb.py +++ b/Lib/bdb.py @@ -201,8 +201,8 @@ def is_skipped_module(self, module_name): def stop_here(self, frame): "Return True if frame is below the starting frame in the stack." - # (CT) stopframe may now also be None, see dispatch_call. - # (CT) the former test for None is therefore removed from here. + if self.stopframe is None: + return True if self.skip and \ self.is_skipped_module(frame.f_globals.get('__name__')): return False From cc60f415bac8078b8026f8868fefee61fc03be25 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 15 Nov 2019 02:10:08 +0100 Subject: [PATCH 2/2] test --- Lib/bdb.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/bdb.py b/Lib/bdb.py index 59a3bdc5f9033b..78592600e1b0f6 100644 --- a/Lib/bdb.py +++ b/Lib/bdb.py @@ -201,7 +201,9 @@ def is_skipped_module(self, module_name): def stop_here(self, frame): "Return True if frame is below the starting frame in the stack." - if self.stopframe is None: + if (self.stopframe is None + and self.returnframe is None + and self.stoplineno == 0): # TEST: via set_step return True if self.skip and \ self.is_skipped_module(frame.f_globals.get('__name__')):