Commit 181027dd authored by Philipp Hörist's avatar Philipp Hörist
Browse files

IPython: Simplify stream code

parent 5d812cbe
......@@ -141,12 +141,6 @@ def __init__(self, argv=None, user_ns=None, user_global_ns=None, cin=None,
IPython.frontend.terminal.interactiveshell.raw_input_original = \
if cin:
io.stdin = io.IOStream(cin)
if cout:
io.stdout = io.IOStream(cout)
if cerr:
io.stderr = io.IOStream(cerr)
# This is to get rid of the blockage that accurs during
# IPython.Shell.InteractiveShell.user_setup()
......@@ -163,10 +157,10 @@ def __init__(self, argv=None, user_ns=None, user_global_ns=None, cin=None,
cfg = Config()
cfg.InteractiveShell.colors = "Linux"
# InteractiveShell's __init__ overwrites io.stdout,io.stderr with
# sys.stdout, sys.stderr, this makes sure they are right
# InteractiveShell's __init__ gets a reference of stdout and stderr
# so we save the standard here to revert it after init
old_stdout, old_stderr = sys.stdout, sys.stderr
sys.stdout, sys.stderr =,
sys.stdout, sys.stderr = cout, cerr
# InteractiveShell inherits from SingletonConfigurable so use instance()
if parse_version(IPython.release.version) >= parse_version("1.2.1"):
......@@ -177,6 +171,7 @@ def __init__(self, argv=None, user_ns=None, user_global_ns=None, cin=None,
config=cfg, user_ns=user_ns)
# Set back stdout and stderr to what it was before
sys.stdout, sys.stderr = old_stdout, old_stderr
self.IP.system = lambda cmd:,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment