diff options
author | Georg Brandl <georg@python.org> | 2010-07-30 12:01:20 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-07-30 12:01:20 (GMT) |
commit | 7410dd11ef4d6f6953f690d304158cd53b357cb2 (patch) | |
tree | 6ba217d2809026291ad3f6e0e7e5da71fd70f609 /Lib/bdb.py | |
parent | a074523f3a8aaf3210165f236c64992d73538a32 (diff) | |
download | cpython-7410dd11ef4d6f6953f690d304158cd53b357cb2.zip cpython-7410dd11ef4d6f6953f690d304158cd53b357cb2.tar.gz cpython-7410dd11ef4d6f6953f690d304158cd53b357cb2.tar.bz2 |
#809887: improve pdb feedback for breakpoint-related actions. Also add a functional test for these commands.
Diffstat (limited to 'Lib/bdb.py')
-rw-r--r-- | Lib/bdb.py | 30 |
1 files changed, 21 insertions, 9 deletions
@@ -270,15 +270,9 @@ class Bdb: def clear_bpbynumber(self, arg): try: - number = int(arg) - except: - return 'Non-numeric breakpoint number (%s)' % arg - try: - bp = Breakpoint.bpbynumber[number] - except IndexError: - return 'Breakpoint number (%d) out of range' % number - if not bp: - return 'Breakpoint (%d) already deleted' % number + bp = self.get_bpbynumber(arg) + except ValueError as err: + return str(err) self.clear_break(bp.file, bp.line) def clear_all_file_breaks(self, filename): @@ -299,6 +293,21 @@ class Bdb: bp.deleteMe() self.breaks = {} + def get_bpbynumber(self, arg): + if not arg: + raise ValueError('Breakpoint number expected') + try: + number = int(arg) + except ValueError: + raise ValueError('Non-numeric breakpoint number %s' % arg) + try: + bp = Breakpoint.bpbynumber[number] + except IndexError: + raise ValueError('Breakpoint number %d out of range' % number) + if bp is None: + raise ValueError('Breakpoint %d already deleted' % number) + return bp + def get_break(self, filename, lineno): filename = self.canonic(filename) return filename in self.breaks and \ @@ -510,6 +519,9 @@ class Breakpoint: print(('\tbreakpoint already hit %d time%s' % (self.hits, ss)), file=out) + def __str__(self): + return 'breakpoint %s at %s:%s' % (self.number, self.file, self.line) + # -----------end of Breakpoint class---------- def checkfuncname(b, frame): |