New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pdb does not output the prompt message when successfully clear breakpoints by "filename:lineno" #87484
Comments
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. 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: bplist = self.get_breaks(filename, lineno)[:] |
Please provide instructions how to reproduce the bug. The patch would need a unit test as well. |
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:
(Pdb) b 2
(Pdb) cl 1
(Pdb) b 3
(Pdb)cl foo.py:2 |
I found a typo in the reproduce step. I'm going to fix it here. The unit test is updated in PR. Now it has some conflicts with the master branch, and I will resolve them soon. The steps to reproduce the bug: Assume the file to be debugged is foo.py(You can use any file you want).
(Pdb) b 2
(Pdb) cl 1
(Pdb) b 3
(Pdb)cl foo.py:3 |
Your fix looks correct - the problem is that the list of breakpoints gets emptied by the clear_break call, and you copy the list so that it can be echoed later if clear_break does not err. I made some polishing comments on the PR, and it also need to be rebased because there is not a merge conflict on test_pdb. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: