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

Method runcode

Lib/idlelib/pyshell.py:762–806  ·  view source on GitHub ↗

Override base class method

(self, code)

Source from the content-addressed store, hash-verified

760 return 1
761
762 def runcode(self, code):
763 "Override base class method"
764 if self.tkconsole.executing:
765 self.restart_subprocess()
766 self.checklinecache()
767 debugger = self.debugger
768 try:
769 self.tkconsole.beginexecuting()
770 if not debugger and self.rpcclt is not None:
771 self.active_seq = self.rpcclt.asyncqueue("exec", "runcode",
772 (code,), {})
773 elif debugger:
774 debugger.run(code, self.locals)
775 else:
776 exec(code, self.locals)
777 except SystemExit:
778 if not self.tkconsole.closing:
779 if messagebox.askyesno(
780 "Exit?",
781 "Do you want to exit altogether?",
782 default="yes",
783 parent=self.tkconsole.text):
784 raise
785 else:
786 self.showtraceback()
787 else:
788 raise
789 except:
790 if use_subprocess:
791 print("IDLE internal error in runcode()",
792 file=self.tkconsole.stderr)
793 self.showtraceback()
794 self.tkconsole.endexecuting()
795 else:
796 if self.tkconsole.canceled:
797 self.tkconsole.canceled = False
798 print("KeyboardInterrupt", file=self.tkconsole.stderr)
799 else:
800 self.showtraceback()
801 finally:
802 if not use_subprocess:
803 try:
804 self.tkconsole.endexecuting()
805 except AttributeError: # shell may have closed
806 pass
807
808 def write(self, s):
809 "Override base class method"

Callers 1

execfileMethod · 0.95

Calls 8

restart_subprocessMethod · 0.95
checklinecacheMethod · 0.95
showtracebackMethod · 0.95
beginexecutingMethod · 0.80
asyncqueueMethod · 0.80
endexecutingMethod · 0.80
runMethod · 0.45
askyesnoMethod · 0.45

Tested by

no test coverage detected