MCPcopy Index your code
hub / github.com/python/cpython / do_clear

Method do_clear

Lib/pdb.py:1686–1731  ·  view source on GitHub ↗

cl(ear) [filename:lineno | bpnumber ...] With a space separated list of breakpoint numbers, clear those breakpoints. Without argument, clear all breaks (but first ask confirmation). With a filename:lineno argument, clear all breaks at that line in that file.

(self, arg)

Source from the content-addressed store, hash-verified

1684 return reply.strip().lower()
1685
1686 def do_clear(self, arg):
1687 """cl(ear) [filename:lineno | bpnumber ...]
1688
1689 With a space separated list of breakpoint numbers, clear
1690 those breakpoints. Without argument, clear all breaks (but
1691 first ask confirmation). With a filename:lineno argument,
1692 clear all breaks at that line in that file.
1693 """
1694 if not arg:
1695 reply = self._prompt_for_confirmation(
1696 'Clear all breaks? ',
1697 default='no',
1698 )
1699 if reply in ('y', 'yes'):
1700 bplist = [bp for bp in bdb.Breakpoint.bpbynumber if bp]
1701 self.clear_all_breaks()
1702 for bp in bplist:
1703 self.message('Deleted %s' % bp)
1704 return
1705 if ':' in arg:
1706 # Make sure it works for "clear C:\foo\bar.py:12"
1707 i = arg.rfind(':')
1708 filename = arg[:i]
1709 arg = arg[i+1:]
1710 try:
1711 lineno = int(arg)
1712 except ValueError:
1713 err = "Invalid line number (%s)" % arg
1714 else:
1715 bplist = self.get_breaks(filename, lineno)[:]
1716 err = self.clear_break(filename, lineno)
1717 if err:
1718 self.error(err)
1719 else:
1720 for bp in bplist:
1721 self.message('Deleted %s' % bp)
1722 return
1723 numberlist = arg.split()
1724 for i in numberlist:
1725 try:
1726 bp = self.get_bpbynumber(i)
1727 except ValueError as err:
1728 self.error(err)
1729 else:
1730 self.clear_bpbynumber(i)
1731 self.message('Deleted %s' % bp)
1732 do_cl = do_clear # 'c' is already an abbreviation for 'continue'
1733
1734 complete_clear = _complete_location

Callers

nothing calls this directly

Calls 10

messageMethod · 0.95
errorMethod · 0.95
clear_all_breaksMethod · 0.80
get_breaksMethod · 0.80
get_bpbynumberMethod · 0.80
clear_bpbynumberMethod · 0.80
rfindMethod · 0.45
clear_breakMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected