MCPcopy Index your code
hub / github.com/python/cpython / runcode

Method runcode

Lib/idlelib/run.py:584–615  ·  view source on GitHub ↗
(self, code)

Source from the content-addressed store, hash-verified

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

Callers 2

run_module_eventMethod · 0.45
test_exceptionsMethod · 0.45

Calls 7

strFunction · 0.85
flush_stdoutFunction · 0.85
excepthookMethod · 0.80
exitFunction · 0.70
print_exceptionFunction · 0.70
getvarMethod · 0.45

Tested by 1

test_exceptionsMethod · 0.36