Supply user_line and user_exception functions for Bdb.
| 27 | |
| 28 | |
| 29 | class Idb(bdb.Bdb): |
| 30 | "Supply user_line and user_exception functions for Bdb." |
| 31 | |
| 32 | def __init__(self, gui): |
| 33 | self.gui = gui # An instance of Debugger or proxy thereof. |
| 34 | super().__init__() |
| 35 | |
| 36 | def user_line(self, frame): |
| 37 | """Handle a user stopping or breaking at a line. |
| 38 | |
| 39 | Convert frame to a string and send it to gui. |
| 40 | """ |
| 41 | if _in_rpc_code(frame): |
| 42 | self.set_step() |
| 43 | return |
| 44 | message = _frame2message(frame) |
| 45 | try: |
| 46 | self.gui.interaction(message, frame) |
| 47 | except TclError: # When closing debugger window with [x] in 3.x |
| 48 | pass |
| 49 | |
| 50 | def user_exception(self, frame, exc_info): |
| 51 | """Handle an the occurrence of an exception.""" |
| 52 | if _in_rpc_code(frame): |
| 53 | self.set_step() |
| 54 | return |
| 55 | message = _frame2message(frame) |
| 56 | self.gui.interaction(message, frame, exc_info) |
| 57 | |
| 58 | def _in_rpc_code(frame): |
| 59 | "Determine if debugger is within RPC code." |