diff options
author | 2010-11-29 11:54:17 +0000 | |
---|---|---|
committer | 2010-11-29 11:54:17 +0000 | |
commit | 6f1070485f54469d7bf48df8306e398609340a07 (patch) | |
tree | 08eda3c912bb78c17b0655e140161da0213126d7 /Lib | |
parent | Issue #10565: Iterator ABC should require both __next__ and __iter__. (diff) | |
download | cpython-6f1070485f54469d7bf48df8306e398609340a07.tar.gz cpython-6f1070485f54469d7bf48df8306e398609340a07.tar.bz2 cpython-6f1070485f54469d7bf48df8306e398609340a07.zip |
Fix #10561 - Fix pdb behavior. Delete the breakpoints by breakpoint number.
Handle multiple breakpoints at same line. Update docs/test.
Patch by Xavier de Gaye.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/bdb.py | 14 | ||||
-rwxr-xr-x | Lib/pdb.py | 3 | ||||
-rw-r--r-- | Lib/test/test_pdb.py | 18 |
3 files changed, 27 insertions, 8 deletions
diff --git a/Lib/bdb.py b/Lib/bdb.py index e599847ce52..0cb2e922cab 100644 --- a/Lib/bdb.py +++ b/Lib/bdb.py @@ -252,6 +252,12 @@ class Bdb: 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: @@ -263,17 +269,15 @@ class Bdb: # 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: bp = self.get_bpbynumber(arg) except ValueError as err: return str(err) - 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) diff --git a/Lib/pdb.py b/Lib/pdb.py index a159d4ccd75..f5d8c2a08a5 100755 --- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -774,7 +774,8 @@ class Pdb(bdb.Bdb, cmd.Cmd): except ValueError as err: self.error(err) else: - self.clear_break(bp.file, bp.line) + self.clear_bpbynumber(i) + #self.clear_break(bp.file, bp.line) self.message('Deleted %s' % bp) do_cl = do_clear # 'c' is already an abbreviation for 'continue' diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 0d93b43e84b..a778c6c6a61 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -192,6 +192,9 @@ def test_pdb_breakpoint_commands(): ... 'ignore 1 10', ... 'condition 1 1 < 2', ... 'break 4', + ... 'break 4', + ... 'break', + ... 'clear 3', ... 'break', ... 'condition 1', ... 'enable 1', @@ -220,6 +223,17 @@ def test_pdb_breakpoint_commands(): New condition set for breakpoint 1. (Pdb) break 4 Breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4 + (Pdb) break 4 + Breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4 + (Pdb) break + Num Type Disp Enb Where + 1 breakpoint keep no at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3 + stop only if 1 < 2 + ignore next 10 hits + 2 breakpoint keep yes at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4 + 3 breakpoint keep yes at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4 + (Pdb) clear 3 + Deleted breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4 (Pdb) break Num Type Disp Enb Where 1 breakpoint keep no at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3 @@ -244,10 +258,10 @@ def test_pdb_breakpoint_commands(): Clear all breaks? y Deleted breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4 (Pdb) tbreak 5 - Breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:5 + Breakpoint 4 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:5 (Pdb) continue 2 - Deleted breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:5 + Deleted breakpoint 4 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:5 > <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>(5)test_function() -> print(3) (Pdb) break |