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


Groups > comp.lang.python > #98250

Re: Unbuffered stderr in Python 3

From Terry Reedy <tjreedy@udel.edu>
Newsgroups comp.lang.python
Subject Re: Unbuffered stderr in Python 3
Date 2015-11-04 18:00 -0500
Message-ID <mailman.33.1446678031.16136.python-list@python.org> (permalink)
References (1 earlier) <pan.2015.11.03.07.10.58.482000@nowhere.invalid> <874mh39lgu.fsf@fastmail.com> <CAPTjJmqDMkq3Q9ztaSLFUbJ=CK2dL=Od+JL=kxXavytEXVWYVQ@mail.gmail.com> <mailman.1.1446589565.20590.python-list@python.org> <56397921$0$11094$c3e8da3@news.astraweb.com>

Show all headers | View raw


On 11/3/2015 10:18 PM, Steven D'Aprano wrote:
> On Wednesday 04 November 2015 09:25, Terry Reedy wrote:
>
>> 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.
>
> This is one of the offending line from our code base:
>
> print('<4>Suspicious answer "{}"!'.format(answer), file=sys.stderr)
>
> So that ought to be terminated by a newline.

Or include 'flush=True' if you really want that to be a partial line.

-- 
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