8000 bpo-43318: Fix a bug where pdb does not always echo cleared breakpoin… · python/cpython@9c0180a · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c0180a

Browse files
bpo-43318: Fix a bug where pdb does not always echo cleared breakpoints (GH-24646) (GH-26674)
(cherry picked from commit 4cb6ba1) Co-authored-by: huzhaojie <hu.zj@foxmail.com>
1 parent 0a186b1 commit 9c0180a

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

Lib/pdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ def do_clear(self, arg):
893893
except ValueError:
894894
err = "Invalid line number (%s)" % arg
895895
else:
896-
bplist = self.get_breaks(filename, lineno)
896+
bplist = self.get_breaks(filename, lineno)[:]
897897
err = self.clear_break(filename, lineno)
898898
if err:
899899
self.error(err)

Lib/test/test_pdb.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,35 @@ def test_pdb_issue_20766():
13221322
pdb 2: <built-in function default_int_handler>
13231323
"""
13241324

1325+
def test_pdb_issue_43318():
1326+
"""echo breakpoints cleared with filename:lineno
1327+
1328+
>>> def test_function():
1329+
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
1330+
... print(1)
1331+
... print(2)
1332+
... print(3)
1333+
... print(4)
1334+
>>> reset_Breakpoint()
1335+
>>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
1336+
... 'break 3',
1337+
... 'clear <doctest test.test_pdb.test_pdb_issue_43318[0]>:3',
1338+
... 'continue'
1339+
... ]):
1340+
... test_function()
1341+
> <doctest test.test_pdb.test_pdb_issue_43318[0]>(3)test_function()
1342+
-> print(1)
1343+
(Pdb) break 3
1344+
Breakpoint 1 at <doctest test.test_pdb.test_pdb_issue_43318[0]>:3
1345+
(Pdb) clear <doctest test.test_pdb.test_pdb_issue_43318[0]>:3
1346+
Deleted breakpoint 1 at <doctest test.test_pdb.test_pdb_issue_43318[0]>:3
1347+
(Pdb) continue
1348+
1
1349+
2
1350+
3
1351+
4
1352+
"""
1353+
13251354

13261355
class PdbTestCase(unittest.TestCase):
13271356
def tearDown(self):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug where :mod:`pdb` does not always echo cleared breakpoints.

0 commit comments

Comments
 (0)
0