[Python-Dev] Can't have unbuffered text I/O in Python 3.0?

Fabio Zadrozny fabiofz at gmail.com
Fri Dec 19 22:43:01 CET 2008


Hi,

I'm currently having problems to get the output of Python 3.0 into the
Eclipse console (integrating it into Pydev).

The problem appears to be that stdout and stderr are not running
unbuffered (even passing -u or trying to set PYTHONUNBUFFERED), and
the content only appears to me when a flush() is done or when the
process finishes.

So, in the search of a solution, I found a suggestion from
http://stackoverflow.com/questions/107705/python-output-buffering

to use the following construct:

sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)

But that gives the error below in Python 3.0:

    sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
  File "D:\bin\Python30\lib\os.py", line 659, in fdopen
    return io.open(fd, *args, **kwargs)
  File "D:\bin\Python30\lib\io.py", line 243, in open
    raise ValueError("can't have unbuffered text I/O")
ValueError: can't have unbuffered text I/O

So, I'd like to know if there's some way I can make it run unbuffered
(to get the output contents without having to flush() after each
write).

Thanks,

Fabio


More information about the Python-Dev mailing list