| 212 | line_prefix = '\n-> ' # Probably a better default |
| 213 | |
| 214 | class Pdb(bdb.Bdb, cmd.Cmd): |
| 215 | |
| 216 | _previous_sigint_handler = None |
| 217 | |
| 218 | def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None, |
| 219 | nosigint=False, readrc=True): |
| 220 | bdb.Bdb.__init__(self, skip=skip) |
| 221 | cmd.Cmd.__init__(self, completekey, stdin, stdout) |
| 222 | sys.audit("pdb.Pdb") |
| 223 | if stdout: |
| 224 | self.use_rawinput = 0 |
| 225 | self.prompt = '(Pdb) ' |
| 226 | self.aliases = {} |
| 227 | self.displaying = {} |
| 228 | self.mainpyfile = '' |
| 229 | self._wait_for_mainpyfile = False |
| 230 | self.tb_lineno = {} |
| 231 | # Try to load readline if it exists |
| 232 | try: |
| 233 | import readline |
| 234 | # remove some common file name delimiters |
| 235 | readline.set_completer_delims(' \t\n`@#$%^&*()=+[{]}\\|;:\'",<>?') |
| 236 | except ImportError: |
| 237 | pass |
| 238 | self.allow_kbdint = False |
| 239 | self.nosigint = nosigint |
| 240 | |
| 241 | # Read ~/.pdbrc and ./.pdbrc |
| 242 | self.rcLines = [] |
| 243 | if readrc: |
| 244 | try: |
| 245 | with open(os.path.expanduser('~/.pdbrc'), encoding='utf-8') as rcFile: |
| 246 | self.rcLines.extend(rcFile) |
| 247 | except OSError: |
| 248 | pass |
| 249 | try: |
| 250 | with open(".pdbrc", encoding='utf-8') as rcFile: |
| 251 | self.rcLines.extend(rcFile) |
| 252 | except OSError: |
| 253 | pass |
| 254 | |
| 255 | self.commands = {} # associates a command list to breakpoint numbers |
| 256 | self.commands_doprompt = {} # for each bp num, tells if the prompt |
| 257 | # must be disp. after execing the cmd list |
| 258 | self.commands_silent = {} # for each bp num, tells if the stack trace |
| 259 | # must be disp. after execing the cmd list |
| 260 | self.commands_defining = False # True while in the process of defining |
| 261 | # a command list |
| 262 | self.commands_bnum = None # The breakpoint number for which we are |
| 263 | # defining a list |
| 264 | |
| 265 | def sigint_handler(self, signum, frame): |
| 266 | if self.allow_kbdint: |
| 267 | raise KeyboardInterrupt |
| 268 | self.message("\nProgram interrupted. (Use 'cont' to resume).") |
| 269 | self.set_step() |
| 270 | self.set_trace(frame) |
| 271 | |