diff --git a/gajim/dev/ipython_view.py b/gajim/dev/ipython_view.py index 86348cc2bea1324403e0d6dd798fc2ea8e22a6a0..fad1c873aa40eb209afaf0b0956c84c9adeccf36 100644 --- a/gajim/dev/ipython_view.py +++ b/gajim/dev/ipython_view.py @@ -141,12 +141,6 @@ def __init__(self, argv=None, user_ns=None, user_global_ns=None, cin=None, else: IPython.frontend.terminal.interactiveshell.raw_input_original = \ input_func - 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 = io.stdout.stream, io.stderr.stream + 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, IPython.frontend.terminal.embed.InteractiveShellEmbed.instance( 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: self.shell(self.IP.var_expand(cmd),