[issue43318] pdb can't output the prompt message when successfully clear a breakpoint by "filename:lineno"
Change by huzhaojie : -- components: Library (Lib) nosy: hjzin priority: normal severity: normal status: open title: pdb can't output the prompt message when successfully clear a breakpoint by "filename:lineno" type: behavior versions: Python 3.10, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue43318> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43318] pdb can't output the prompt message when successfully clear breakpoints by "filename:lineno"
Change by huzhaojie : -- keywords: +patch pull_requests: +23431 stage: -> patch review pull_request: https://github.com/python/cpython/pull/24646 ___ Python tracker <https://bugs.python.org/issue43318> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43318] pdb can't output the prompt message when successfully clear breakpoints by "filename:lineno"
New submission from huzhaojie : In Pdb, when successfully clear breakpoints, the Pdb should output a message:"Deleted XXX", but when breakpoints are cleared by filename:lineno, the message can't be output. I think it's related to the following code. ```python pdb.py: def do_clear(self, arg): ... if ':' in arg: # Make sure it works for "clear C:\foo\bar.py:12" i = arg.rfind(':') filename = arg[:i] arg = arg[i+1:] try: lineno = int(arg) except ValueError: err = "Invalid line number (%s)" % arg else: bplist = self.get_breaks(filename, lineno) err = self.clear_break(filename, lineno) if err: self.error(err) else: for bp in bplist: self.message('Deleted %s' % bp) return ``` self.get_breaks is called to get the breakpoints to be deleted, the result is in bplist. self.clear_break is called to delete the breakpoints in bplist. Each element in bplist is a reference to a Breakpoint object, so when all Breakpoint objects are removed, the bplist will become an empty list when self.clear_break is called, so pdb can't output the prompt message. It can be simply fixed by following code: ```python bplist = self.get_breaks(filename, lineno)[:] ``` -- title: pdb can't output the prompt message when successfully clear a breakpoint by "filename:lineno" -> pdb can't output the prompt message when successfully clear breakpoints by "filename:lineno" ___ Python tracker <https://bugs.python.org/issue43318> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43318] pdb can't output the prompt message when successfully clear breakpoints by "filename:lineno"
huzhaojie added the comment: Accroding to my test, it appears in python 3.8.0 and the latest 3.10 master branch, and I think other versions also have this bug. The steps to reproduce the bug: 1. start pdb: python -m pdb foo.py 2. set a breakpoint on any line of the file: (Pdb) b 2 Breakpoint 1 at foo.py:2 (Pdb) b Num Type Disp Enb Where 1 breakpoint keep yes at foo.py:2 3. when clear the breakpoint using breakpoint number, it will get a output("Deleted breakpoint 1 at ..."): (Pdb) cl 1 Deleted breakpoint 1 at foo.py:2 4. set another breakpoint: (Pdb) b 3 Breakpoint 2 at foo.py:3 5. if breakpoint is cleared using (filename:lineno), it gets nothing: (Pdb)cl foo.py:2 (Pdb) -- ___ Python tracker <https://bugs.python.org/issue43318> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com