diff -r 4e1e68069480 Lib/idlelib/OutputWindow.py --- a/Lib/idlelib/OutputWindow.py Sat Oct 18 17:10:32 2014 -0400 +++ b/Lib/idlelib/OutputWindow.py Sun Oct 19 13:46:04 2014 +0300 @@ -39,7 +39,7 @@ class OutputWindow(EditorWindow): s = s.decode(IOBinding.encoding, "replace") self.text.insert(mark, s, tags) self.text.see(mark) - self.text.update() + self.text.update_idletasks() return len(s) def writelines(self, lines): diff -r 4e1e68069480 Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py Sat Oct 18 17:10:32 2014 -0400 +++ b/Lib/idlelib/PyShell.py Sun Oct 19 13:46:04 2014 +0300 @@ -1,5 +1,7 @@ #! /usr/bin/env python3 +import codecs +import functools import getopt import os import os.path @@ -383,6 +385,15 @@ class MyRPCClient(rpc.RPCClient): raise EOFError +def outputhandler(output, decoder, inputfd, mask): + data = os.read(inputfd, 512) + s = decoder.decode(data) + try: + output.write(s) + except UnicodeEncodeError: + s = re.sub('[^\x00-\uffff]', lambda m: r'\U%08x' % ord(m.group()), s) + output.write(s) + class ModifiedInterpreter(InteractiveInterpreter): def __init__(self, tkconsole): @@ -402,7 +413,23 @@ class ModifiedInterpreter(InteractiveInt def spawn_subprocess(self): if self.subprocess_arglist is None: self.subprocess_arglist = self.build_subprocess_arglist() - self.rpcsubproc = subprocess.Popen(self.subprocess_arglist) + self.rpcsubproc = subprocess.Popen(self.subprocess_arglist, + stdin=subprocess.DEVNULL, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + decoder = codecs.getincrementaldecoder(sys.getfilesystemencoding()) + self.tkconsole.root.createfilehandler( + self.rpcsubproc.stdout.fileno(), + READABLE, + functools.partial(outputhandler, + self.tkconsole.stdout, + decoder('surrogateescape'))) + self.tkconsole.root.createfilehandler( + self.rpcsubproc.stderr.fileno(), + READABLE, + functools.partial(outputhandler, + self.tkconsole.stderr, + decoder('surrogateescape'))) def build_subprocess_arglist(self): assert (self.port!=0), ( @@ -535,12 +562,14 @@ class ModifiedInterpreter(InteractiveInt self.rpcsubproc.kill() except OSError: # process already terminated - return + pass else: try: self.rpcsubproc.wait() except OSError: - return + pass + self.rpcsubproc.stdout.close() + self.rpcsubproc.stderr.close() def transfer_path(self, with_cwd=False): if with_cwd: # Issue 13506