| 571 | self.locals = {} |
| 572 | |
| 573 | def runcode(self, code): |
| 574 | global interruptable |
| 575 | try: |
| 576 | self.user_exc_info = None |
| 577 | interruptable = True |
| 578 | try: |
| 579 | exec(code, self.locals) |
| 580 | finally: |
| 581 | interruptable = False |
| 582 | except SystemExit as e: |
| 583 | if e.args: # SystemExit called with an argument. |
| 584 | ob = e.args[0] |
| 585 | if not isinstance(ob, (type(None), int)): |
| 586 | print('SystemExit: ' + str(ob), file=sys.stderr) |
| 587 | # Return to the interactive prompt. |
| 588 | except: |
| 589 | self.user_exc_info = sys.exc_info() # For testing, hook, viewer. |
| 590 | if quitting: |
| 591 | exit() |
| 592 | if sys.excepthook is sys.__excepthook__: |
| 593 | print_exception() |
| 594 | else: |
| 595 | try: |
| 596 | sys.excepthook(*self.user_exc_info) |
| 597 | except: |
| 598 | self.user_exc_info = sys.exc_info() # For testing. |
| 599 | print_exception() |
| 600 | jit = self.rpchandler.console.getvar("<<toggle-jit-stack-viewer>>") |
| 601 | if jit: |
| 602 | self.rpchandler.interp.open_remote_stack_viewer() |
| 603 | else: |
| 604 | flush_stdout() |
| 605 | |
| 606 | def interrupt_the_server(self): |
| 607 | if interruptable: |