Title: -u (unbuffered I/O) command line option documentation mismatch for sys.stdin
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.3, Python 3.4
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: docs@python, ezio.melotti, mjpieters, pitrou, python-dev
Priority: normal Keywords: patch

Created on 2013-01-11 18:22 by mjpieters, last changed 2013-07-25 03:06 by ezio.melotti. This issue is now closed.

File name Uploaded Description Edit
issue16937.diff Elena.Oat, 2013-07-06 11:49 review
Messages (4)
msg179718 - (view) Author: Martijn Pieters (mjpieters) * Date: 2013-01-11 18:22
Run `python3.3 -h` and the `-u` option is documented as:

>     -u     : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x
>              see man page for details on internal buffering relating to '-u'

Note that only `stdout` and `stderr` are mentioned.

The online documentation at doesn't agree:

> ... the binary layer of the stdin, stdout and stderr streams ...

nor does `man python3.3`, which claims:

>    -u     Force the binary I/O layers of stdin, stdout and stderr to be unbuffered.  The text I/O layer will still
>           be line-buffered.

So, is `stdin` going to be unbuffered, or not, when using `-u`?

Running a simple test shows that `stdin` is firmly being buffered regardless of the `-u` switch:

    $ python3.3 -c 'import sys; print(sys.stdin.buffer, sys.stdout.buffer)'
    <_io.BufferedReader name='<stdin>'> <_io.BufferedWriter name='<stdout>'>
    $ python3.3 -u -c 'import sys; print(sys.stdin.buffer, sys.stdout.buffer)'
    <_io.BufferedReader name='<stdin>'> <_io.FileIO name='<stdout>' mode='wb'>

I'll presume here that `stdin` is deliberately buffered, regardless, and that the documentation and man page are out of date here (in python 2, `-u` does include `stdin`).
msg179741 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-01-11 22:47
Indeed, stdin is always buffered, simply because it doesn't make a difference (except if you're trying to read raw data from fd 0).
msg193681 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-07-25 03:05
New changeset 4b33f74ab0f1 by Ezio Melotti in branch '3.3':
#16937: document that stdin is always buffered, even when -u is used.  Patch by Elena Oat.

New changeset 52f0aa0d552a by Ezio Melotti in branch 'default':
#16937: merge with 3.3.
msg193682 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-07-25 03:06
Fixed, thanks for the patch!
Date User Action Args
2013-07-25 03:06:29ezio.melottisetstatus: open -> closed

type: enhancement
assignee: docs@python -> ezio.melotti

nosy: + ezio.melotti
messages: + msg193682
resolution: fixed
stage: resolved
2013-07-25 03:05:15python-devsetnosy: + python-dev
messages: + msg193681
2013-07-06 11:49:56Elena.Oatsetfiles: + issue16937.diff
keywords: + patch
2013-01-11 22:47:46pitrousetmessages: + msg179741
2013-01-11 18:36:05georg.brandlsetnosy: + pitrou
2013-01-11 18:22:02mjpieterscreate