bpo-38078: IDLE: Don't run internal code in the user namespace
This commit is contained in:
parent
d5d9a71866
commit
6d8c5fd26c
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Stop running internal IDLE code in the user namespace.
|
Loading…
Reference in New Issue