| 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.Shell import IPShellEmbed |
| 223 | ipshell = IPShellEmbed(user_ns=tb.tb_frame.f_locals) |
| 224 | ipshell() |
| 225 | |
| 226 | except ImportError: |
| 227 | import code |
| 228 | shell = code.InteractiveConsole(tb.tb_frame.f_locals) |
| 229 | shell.interact() |
| 230 | |
| 231 | elif settings.INLINE_DEBUGGER == "pdb": |
| 232 | import pdb |
| 233 | import traceback |
| 234 | print |
| 235 | traceback.print_exception(*exc_info) |
| 236 | pdb.post_mortem(exc_info[-1]) |
| 237 | else: |
| 238 | exception = WrongValue("'%s'is invalid value for'setting.INLINE_DEBUGGER'. Use 'pdb' or 'interactive' instead." % \ |
| 239 | settings.INLINE_DEBUGGER) |
| 240 | exc_info = (type(exception), exception, None) |
| 241 | |
| 242 | |