Author hjzin
Recipients hjzin
Date 2021-02-25.08:11:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1614240670.83.0.613464478845.issue43318@roundup.psfhosted.org>
In-reply-to
Content
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)[:]
```
History
Date User Action Args
2021-02-25 08:11:10hjzinsetrecipients: + hjzin
2021-02-25 08:11:10hjzinsetmessageid: <1614240670.83.0.613464478845.issue43318@roundup.psfhosted.org>
2021-02-25 08:11:10hjzinlinkissue43318 messages
2021-02-25 08:11:10hjzincreate