https://github.com/python/cpython/commit/7e03ae8789611c53bcb854fb313741803c0f87b9 commit: 7e03ae8789611c53bcb854fb313741803c0f87b9 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: gaogaotiantian <[email protected]> date: 2026-10-19T23:46:42Z summary:
[3.14] gh-149015: Fix clear_all_file_breaks for breakpoints sharing a line in bdb (GH-159748) (#159802) gh-149015: Fix clear_all_file_breaks for breakpoints sharing a line in bdb (GH-159748) (cherry picked from commit 630920e45e2ee9fe9bef44bf4a70c95868c58afb) Co-authored-by: Tian Gao <[email protected]> files: A Misc/NEWS.d/next/Library/2026-10-19-00-00-00.gh-issue-149015.bdb.rst M Lib/bdb.py M Lib/test/test_bdb.py diff --git a/Lib/bdb.py b/Lib/bdb.py index 79da4bab9c9034..7af9481a84a0e3 100644 --- a/Lib/bdb.py +++ b/Lib/bdb.py @@ -756,7 +756,7 @@ def clear_all_file_breaks(self, filename): return 'There are no breakpoints in %s' % filename for line in self.breaks[filename]: blist = Breakpoint.bplist[filename, line] - for bp in blist: + for bp in blist[:]: bp.deleteMe() del self.breaks[filename] return None diff --git a/Lib/test/test_bdb.py b/Lib/test/test_bdb.py index f15dae13eb384e..6a1df6e083e9e9 100644 --- a/Lib/test/test_bdb.py +++ b/Lib/test/test_bdb.py @@ -965,6 +965,17 @@ def main(): with TracerRun(self) as tracer: tracer.runcall(tfunc_import) + def test_clear_all_file_breaks_same_line(self): + reset_Breakpoint() + self.addCleanup(reset_Breakpoint) + debugger = Bdb() + for _ in range(3): + self.assertIsNone(debugger.set_break(__file__, 1)) + self.assertIsNone(debugger.clear_all_file_breaks(__file__)) + self.assertEqual(debugger.get_all_breaks(), {}) + self.assertEqual(_bdb.Breakpoint.bplist, {}) + self.assertTrue(all(bp is None for bp in _bdb.Breakpoint.bpbynumber)) + def test_clear_at_no_bp(self): self.expect_set = [ ('line', 2, 'tfunc_import'), ('clear', (__file__, 1)) diff --git a/Misc/NEWS.d/next/Library/2026-10-19-00-00-00.gh-issue-149015.bdb.rst b/Misc/NEWS.d/next/Library/2026-10-19-00-00-00.gh-issue-149015.bdb.rst new file mode 100644 index 00000000000000..a7bcbc4b1aa322 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-19-00-00-00.gh-issue-149015.bdb.rst @@ -0,0 +1,2 @@ +Fix :meth:`bdb.Bdb.clear_all_file_breaks` leaving breakpoints behind when +multiple breakpoints are set on the same line. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
