Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98186 > unrolled thread

Re: Unbuffered stderr in Python 3

Started byRandom832 <random832@fastmail.com>
First post2015-11-03 14:45 -0500
Last post2015-11-04 15:55 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Unbuffered stderr in Python 3 Random832 <random832@fastmail.com> - 2015-11-03 14:45 -0500
    Re: Unbuffered stderr in Python 3 Dave Farrance <df@see.replyto.invalid> - 2015-11-04 15:55 +0000

#98186 — Re: Unbuffered stderr in Python 3

FromRandom832 <random832@fastmail.com>
Date2015-11-03 14:45 -0500
SubjectRe: Unbuffered stderr in Python 3
Message-ID<mailman.47.1446579961.8789.python-list@python.org>
George Trojan <george.trojan@noaa.gov> writes:
> This does set line buffering, but does not change the behaviour:

The opposite of line buffering is not no buffering, but full
(i.e. block) buffering, that doesn't get flushed until it runs
out of space. TextIOWrapper has its own internal buffer, and its
design apparently doesn't contemplate the possibility of using
it with a raw FileIO object (which may mean that the posted code
isn't guaranteed to work) or disabling buffering.

[toc] | [next] | [standalone]


#98235

FromDave Farrance <df@see.replyto.invalid>
Date2015-11-04 15:55 +0000
Message-ID<h2ak3bh20v5kft7u87q6139ehircqp43vp@4ax.com>
In reply to#98186
Random832 <random832@fastmail.com> wrote:

>The opposite of line buffering is not no buffering, but full
>(i.e. block) buffering, that doesn't get flushed until it runs
>out of space. TextIOWrapper has its own internal buffer, and its
>design apparently doesn't contemplate the possibility of using
>it with a raw FileIO object (which may mean that the posted code
>isn't guaranteed to work) or disabling buffering.

Hmmm. That even seems to cause trouble for sys.stderr.write
(in Python3 with a non-tty e.g. a piped output):

$ python2 -c 'import sys;sys.stderr.write("1\n");print("2")' 2>&1 | tee
1
2
$ python3 -c 'import sys;sys.stderr.write("1\n");print("2")' 2>&1 | tee
2
1

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web