bpo-38078: IDLE: Don't run internal code in the user namespace

This commit is contained in:
Zackery Spytz 2020-05-11 16:34:26 -06:00
parent d5d9a71866
commit 6d8c5fd26c
3 changed files with 7 additions and 3 deletions

View File

@ -749,7 +749,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
self.display_executing_dialog()
return 0
if self.rpcclt:
self.rpcclt.remotequeue("exec", "runcode", (code,), {})
self.rpcclt.remotequeue("exec", "runcommand", (code,), {})
else:
exec(code, self.locals)
return 1

View File

@ -539,13 +539,13 @@ class Executive(object):
self.calltip = calltip.Calltip()
self.autocomplete = autocomplete.AutoComplete()
def runcode(self, code):
def runcode(self, code, user=True):
global interruptable
try:
self.usr_exc_info = None
interruptable = True
try:
exec(code, self.locals)
exec(code, self.locals if user else {})
finally:
interruptable = False
except SystemExit as e:
@ -565,6 +565,9 @@ class Executive(object):
else:
flush_stdout()
def runcommand(self, code):
return self.runcode(code, user=False)
def interrupt_the_server(self):
if interruptable:
thread.interrupt_main()

View File

@ -0,0 +1 @@
Stop running internal IDLE code in the user namespace.