This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients amaury.forgeotdarc, brian.curtin, pitrou, v+python
Date 2011-01-06.07:51:31
SpamBayes Score 5.013881e-06
Marked as misclassified No
Message-id <1294300288.3716.9.camel@localhost.localdomain>
In-reply-to <1294299025.84.0.898729521572.issue10841@psf.upfronthosting.co.za>
Content
> Is there an easy way for me to find the code for -u?

"-u" just passes 0 for the "buffering" argument to open() when creating
stdout and stderr. Otherwise "buffering" equals -1.
You can find equivalent code for open() in Lib/_pyio.py (the actual code
in is in C).

The practical difference is that "-u" removes the binary buffering layer
between the unicode layer and the raw file object:

$ ./python -c "import sys; print(sys.stdout, sys.stdout.buffer)"
<_io.TextIOWrapper name='<stdout>' encoding='UTF-8'> <_io.BufferedWriter name='<stdout>'>
$ ./python -u -c "import sys; print(sys.stdout, sys.stdout.buffer)"
<_io.TextIOWrapper name='<stdout>' encoding='UTF-8'> <_io.FileIO name='<stdout>' mode='wb'>

This should make absolutely no difference as to newline handling, since
that is handled exclusively in TextIOWrapper (binary layers are
transparent by construction).
History
Date User Action Args
2011-01-06 07:51:33pitrousetrecipients: + pitrou, amaury.forgeotdarc, v+python, brian.curtin
2011-01-06 07:51:31pitroulinkissue10841 messages
2011-01-06 07:51:31pitroucreate