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


Groups > comp.lang.python > #98191

Re: Unbuffered stderr in Python 3

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Terry Reedy <tjreedy@udel.edu>
Newsgroups comp.lang.python
Subject Re: Unbuffered stderr in Python 3
Date Tue, 3 Nov 2015 17:25:55 -0500
Lines 28
Message-ID <mailman.1.1446589565.20590.python-list@python.org> (permalink)
References <5637165b$0$1505$c3e8da3$5496439d@news.astraweb.com> <pan.2015.11.03.07.10.58.482000@nowhere.invalid> <874mh39lgu.fsf@fastmail.com> <CAPTjJmqDMkq3Q9ztaSLFUbJ=CK2dL=Od+JL=kxXavytEXVWYVQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de wX8j0vFZh8p+lrX9w1GKeQpxVfFSSAejt0vvtCNXe3iA==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'terminated': 0.07; 'byte,': 0.09; 'considered,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'streams.': 0.09; 'sys.stderr': 0.09; 'jan': 0.11; 'output': 0.13; 'wed,': 0.15; 'newline."': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'wrote:': 0.16; 'bytes': 0.18; 'case.': 0.18; '>>>': 0.20; '2015': 0.20; 'not,': 0.22; 'am,': 0.23; 'errors': 0.23; 'header:In-Reply-To:1': 0.24; 'url:bugs': 0.24; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'chris': 0.26; 'oversight': 0.29; 'character': 0.29; 'probably': 0.31; 'related': 0.32; 'url:python': 0.33; 'stream': 0.33; 'nov': 0.35; 'unicode': 0.35; 'but': 0.36; 'should': 0.36; 'url:org': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'enough': 0.39; 'to:addr:python.org': 0.40; 'behavior': 0.61; 'making': 0.62; 'course': 0.62; 'fundamental': 0.66; 'unusual': 0.72; 'significance': 0.84; 'streams': 0.84; 'different.': 0.91; 'received:fios.verizon.net': 0.91
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host pool-173-59-124-74.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
In-Reply-To <CAPTjJmqDMkq3Q9ztaSLFUbJ=CK2dL=Od+JL=kxXavytEXVWYVQ@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:98191

Show key headers only | View raw


On 11/3/2015 10:42 AM, Chris Angelico wrote:
> On Wed, Nov 4, 2015 at 2:00 AM, Random832 <random832@fastmail.com> wrote:
>> Nobody <nobody@nowhere.invalid> writes:
>>
>>> It's probably related to the fact that std{in,out,err} are Unicode
>>> streams.
>>
>> There's no fundamental reason a Unicode stream should have to be line
>> buffered. If it's "related", it's only in that an oversight was made in
>> the course of making that change.

The current behavior is not an 'oversight'.  I was considered, decided, 
and revisited in https://bugs.python.org/issue13601.  Guido: 
"Line-buffering should be good enough since in practice errors messages 
are always terminated by a newline."  If not, print(part_line, 
file=sys.stderr, flush=True) works for the unusual case.

> Yep. Unicode *input* streams need to be buffered, but *output* can
> always be insta-flushed. The only significance of Unicode to output is
> that a single character may cause multiple bytes to be output; and
> since output can block for even a single byte, it should be no
> different.
>
> +1 for making sys.stderr unbuffered.

-
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Unbuffered stderr in Python 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-11-02 18:52 +1100
  Re: Unbuffered stderr in Python 3 Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-11-02 11:48 +0100
  Re: Unbuffered stderr in Python 3 Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-11-02 11:54 +0100
  Re: Unbuffered stderr in Python 3 Nobody <nobody@nowhere.invalid> - 2015-11-03 07:10 +0000
    Re: Unbuffered stderr in Python 3 Random832 <random832@fastmail.com> - 2015-11-03 10:00 -0500
    Re: Unbuffered stderr in Python 3 Chris Angelico <rosuav@gmail.com> - 2015-11-04 02:42 +1100
    Re: Unbuffered stderr in Python 3 Terry Reedy <tjreedy@udel.edu> - 2015-11-03 17:25 -0500
      Re: Unbuffered stderr in Python 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-11-04 14:18 +1100
        Re: Unbuffered stderr in Python 3 Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-11-04 09:19 +0100
          Re: Unbuffered stderr in Python 3 Steven D'Aprano <steve@pearwood.info> - 2015-11-04 21:24 +1100
            Re: Unbuffered stderr in Python 3 Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-11-04 11:43 +0100
            Re: Unbuffered stderr in Python 3 Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-11-04 12:49 +0100
            Re: Unbuffered stderr in Python 3 Random832 <random832@fastmail.com> - 2015-11-04 08:43 -0500
        Re: Unbuffered stderr in Python 3 Terry Reedy <tjreedy@udel.edu> - 2015-11-04 18:00 -0500
  Re: Unbuffered stderr in Python 3 srinivas devaki <mr.eightnoteight@gmail.com> - 2015-11-06 19:10 +0530

csiph-web