redefining stdout in imported module breaks cmdprompt on windows · Issue #17 · ipython/ipython (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@ghost

Description

@ghost

Original Launchpad bug 383554: https://bugs.launchpad.net/ipython/+bug/383554
Reported by: techtonik (anatoly techtonik).

When import the module that redefines stdout, the colorful IPython prompt breaks (pyreadline is at 1.5), although other colors work in error messages.

Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.9.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: from yyy import xxx

☺←[0;32m☻In [☺←[1;32m☻2☺←[0;32m☻]: ☺←[0m☻

☺←[0;32m☻In [☺←[1;32m☻3☺←[0;32m☻]: ☺←[0m☻some strange command
------------------------------------------------------------
   File "<ipython console>", line 1
     some strange command
                ^
SyntaxError: invalid syntax


☺←[0;32m☻In [☺←[1;32m☻4☺←[0;32m☻]: ☺←[0m☻

-- cut xxx.py ---

import sys

class restdout: def init(self, fp): self.fp = fp

def write(self, s):
    self.fp.write(s)

sys.stdout = restdout(sys.stdout)