[issue4705] python3.0 -u: unbuffered stdout

STINNER Victor report at bugs.python.org
Sun Dec 28 17:04:52 CET 2008


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

>> Should we also change stdin?
> I don't know, but "python -h" only talks about stderr/stdout.

The manpage of Python2 is clear:

   -u     Force stdin, stdout and stderr to be totally unbuffered.

stdin is also unbuffered.

> It seems the "name" field of the TextIOWrapper object isn't 
> set in create_stdio()

It used only used for buffered output. Without the patch, 
sys.stdout.name == sys.stdout.buffer.name == '1' :-/

New patch:
 - use create_stdio() to create unbuffered sys.stdin
 - rename Py_UnbufferedStdoutFlag to Py_UnbufferedStdioFlag
 - replace "Py_UnbufferedStdioFlag++;" by "Py_UnbufferedStdioFlag = 
1;"
 - change create_stdio(): (...)

Note: there is no test for unbuffered input because I don't know how 
to test this (even by manual tests) :-p

Added file: http://bugs.python.org/file12478/unbufferedstdout-3.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4705>
_______________________________________


More information about the Python-bugs-list mailing list