[New-bugs-announce] [issue10561] The pdb command 'clear bpnumber' may delete more than one breakpoint
Xavier de Gaye
report at bugs.python.org
Sun Nov 28 12:38:56 CET 2010
New submission from Xavier de Gaye <xdegaye at gmail.com>:
Description:
------------
1. When deleting a single breakpoint, all the breakpoints located on
the line of this breakpoint are also deleted. See the test case
below.
2. The pdb 'clear' command documentation does not mention that all the
breakpoints on a line can be deleted with the command:
clear filename:lineno
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:
------
Index: Doc/library/pdb.rst
===================================================================
--- 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)
===================================================================
----------
components: Library (Lib)
messages: 122652
nosy: xdegaye
priority: normal
severity: normal
status: open
title: The pdb command 'clear bpnumber' may delete more than one breakpoint
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10561>
_______________________________________
More information about the New-bugs-announce
mailing list