Call up the pdb debugger if desired, always clean up the tb reference. Keywords: - force(False): by default, this routine checks the instance call_pdb flag and does not actually invoke the debugger if the flag is false. The 'force' option forces th
(self, force=False)
| 1226 | return structured_traceback_parts |
| 1227 | |
| 1228 | def debugger(self, force=False): |
| 1229 | """Call up the pdb debugger if desired, always clean up the tb |
| 1230 | reference. |
| 1231 | |
| 1232 | Keywords: |
| 1233 | |
| 1234 | - force(False): by default, this routine checks the instance call_pdb |
| 1235 | flag and does not actually invoke the debugger if the flag is false. |
| 1236 | The 'force' option forces the debugger to activate even if the flag |
| 1237 | is false. |
| 1238 | |
| 1239 | If the call_pdb flag is set, the pdb interactive debugger is |
| 1240 | invoked. In all cases, the self.tb reference to the current traceback |
| 1241 | is deleted to prevent lingering references which hamper memory |
| 1242 | management. |
| 1243 | |
| 1244 | Note that each call to pdb() does an 'import readline', so if your app |
| 1245 | requires a special setup for the readline completers, you'll have to |
| 1246 | fix that by hand after invoking the exception handler.""" |
| 1247 | |
| 1248 | if force or self.call_pdb: |
| 1249 | if self.pdb is None: |
| 1250 | self.pdb = self.debugger_cls() |
| 1251 | # the system displayhook may have changed, restore the original |
| 1252 | # for pdb |
| 1253 | display_trap = DisplayTrap(hook=sys.__displayhook__) |
| 1254 | with display_trap: |
| 1255 | self.pdb.reset() |
| 1256 | # Find the right frame so we don't pop up inside ipython itself |
| 1257 | if hasattr(self, 'tb') and self.tb is not None: |
| 1258 | etb = self.tb |
| 1259 | else: |
| 1260 | etb = self.tb = sys.last_traceback |
| 1261 | while self.tb is not None and self.tb.tb_next is not None: |
| 1262 | self.tb = self.tb.tb_next |
| 1263 | if etb and etb.tb_next: |
| 1264 | etb = etb.tb_next |
| 1265 | self.pdb.botframe = etb.tb_frame |
| 1266 | self.pdb.interaction(None, etb) |
| 1267 | |
| 1268 | if hasattr(self, 'tb'): |
| 1269 | del self.tb |
| 1270 | |
| 1271 | def handler(self, info=None): |
| 1272 | (etype, evalue, etb) = info or sys.exc_info() |
no test coverage detected