| 206 | # Run an interactive shell or pdb when an uncaught exception |
| 207 | # raised. if INLINE_DEBUGGER defined. |
| 208 | if not exc_info[0] == SyntaxError: |
| 209 | if settings.INLINE_DEBUGGER: |
| 210 | if settings.INLINE_DEBUGGER == "interactive": |
| 211 | tbtmp = exc_info[-1] |
| 212 | tb = None |
| 213 | while tbtmp: |
| 214 | tbtmp = tbtmp.tb_next |
| 215 | if tbtmp is not None: |
| 216 | tb = tbtmp |
| 217 | import traceback |
| 218 | print |
| 219 | traceback.print_exception(*exc_info) |
| 220 | |
| 221 | try: |
| 222 | from IPython import Shell |
| 223 | ipshell = Shell.start() |
| 224 | ipshell.IP.api.to_user_ns(tb.tb_frame.f_locals) |
| 225 | ipshell.IP.api.to_user_ns(tb.tb_frame.f_globals) |
| 226 | ipshell.mainloop() |
| 227 | |
| 228 | except ImportError: |
| 229 | import code |
| 230 | shell = code.InteractiveConsole(tb.tb_frame.f_locals) |
| 231 | shell.interact() |
| 232 | |
| 233 | elif settings.INLINE_DEBUGGER == "pdb": |
| 234 | import pdb |
| 235 | import traceback |
| 236 | print |
| 237 | traceback.print_exception(*exc_info) |
| 238 | pdb.post_mortem(exc_info[-1]) |
| 239 | else: |
| 240 | exception = WrongValue("'%s'is invalid value for'setting.INLINE_DEBUGGER'. Use 'pdb' or 'interactive' instead." % \ |
| 241 | settings.INLINE_DEBUGGER) |
| 242 | exc_info = (type(exception), exception, None) |
| 243 | |
| 244 | |