diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -293,6 +293,13 @@ sys.stderr = PyShell.PseudoOutputFile(self.console, "stderr", IOBinding.encoding) + # Follow sys.__stdxyz__ doc and prevent stream closure + # even if both sys references are rebound. See issue17838 + sys.__stdin__ = sys.stdin + sys.__stdout__ = sys.stdout + sys.__stderr__ = sys.stderr + self._keep_alive = (sys.stdin, sys.stdout, sys.stderr) + sys.displayhook = rpc.displayhook # page help() text to shell. import pydoc # import must be done here to capture i/o binding