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
The pdb command 'clear bpnumber' may delete more than one breakpoint #54770
Comments
Description:
See the proposed bdb patch and documentation patch below. Test case: ##### File foobar.py #####
def main():
pass
if __name__ == '__main__':
main()
##### Test case #####
xavier$ /usr/local/bin/python2.7
Python 2.7 (r27:82500, Jul 13 2010, 21:30:27)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pdb, foobar
>>> pdb.run('foobar.main()')
> <string>(1)<module>()
(Pdb) break foobar.main
Breakpoint 1 at /home/xavier/tmp/foobar.py:1
(Pdb) break foobar.main
Breakpoint 2 at /home/xavier/tmp/foobar.py:1
(Pdb) break
Num Type Disp Enb Where
1 breakpoint keep yes at /home/xavier/tmp/foobar.py:1
2 breakpoint keep yes at /home/xavier/tmp/foobar.py:1
(Pdb) clear 1
Deleted breakpoint 1
(Pdb) break
(Pdb)
######################### Patch: --- Doc/library/pdb.rst (revision 86836)
+++ Doc/library/pdb.rst (working copy)
@@ -239,7 +239,8 @@
Temporary breakpoint, which is removed automatically when it is first hit. The
arguments are the same as break.
-cl(ear) [*bpnumber* [*bpnumber ...*]]
+cl(ear) [*filename:lineno* | *bpnumber* [*bpnumber ...*]]
+ With a *filename:lineno* argument, clear all the breakpoints at this line.
With a space separated list of breakpoint numbers, clear those breakpoints.
Without argument, clear all breaks (but first ask confirmation).
Index: Lib/bdb.py
===================================================================
--- Lib/bdb.py (revision 86836)
+++ Lib/bdb.py (working copy)
@@ -250,6 +250,12 @@
list.append(lineno)
bp = Breakpoint(filename, lineno, temporary, cond, funcname)
+ def prune_breaks(self, filename, lineno):
+ if (filename, lineno) not in Breakpoint.bplist:
+ self.breaks[filename].remove(lineno)
+ if not self.breaks[filename]:
+ del self.breaks[filename]
+
def clear_break(self, filename, lineno):
filename = self.canonic(filename)
if not filename in self.breaks:
@@ -261,10 +267,7 @@
# pair, then remove the breaks entry
for bp in Breakpoint.bplist[filename, lineno][:]:
bp.deleteMe()
- if (filename, lineno) not in Breakpoint.bplist:
- self.breaks[filename].remove(lineno)
- if not self.breaks[filename]:
- del self.breaks[filename]
+ self.prune_breaks(filename, lineno)
def clear_bpbynumber(self, arg):
try:
@@ -277,7 +280,8 @@
return 'Breakpoint number (%d) out of range' % number
if not bp:
return 'Breakpoint (%d) already deleted' % number
- self.clear_break(bp.file, bp.line)
+ bp.deleteMe()
+ self.prune_breaks(bp.file, bp.line)
def clear_all_file_breaks(self, filename):
filename = self.canonic(filename) =================================================================== |
Fixed in r86861. Xavier, I noticed that pdb.py itself was not calling the proper method. Added the tests to the patch. Thanks. BTW, please provide patches against py3k as that is development version. |
r86862 - release31-maint and r86863 - release27-maint. |
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: