Re: Unbuffered stderr in Python 3

2015-11-06 Thread srinivas devaki
On Mon, Nov 2, 2015 at 1:22 PM, Steven D'Aprano wrote: > > So how come Python 3 has line buffered stderr? And more importantly, how can > I turn buffering off? > > I don't want to use the -u unbuffered command line switch, because that > effects stdout as

Re: Unbuffered stderr in Python 3

2015-11-04 Thread Terry Reedy
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 wrote: Nobody writes: It's probably related to the

Re: Unbuffered stderr in Python 3

2015-11-04 Thread Wolfgang Maier
On 04.11.2015 11:43, Wolfgang Maier wrote: On 04.11.2015 11:24, Steven D'Aprano wrote: On Wed, 4 Nov 2015 07:19 pm, Wolfgang Maier wrote: On 04.11.2015 04:18, Steven D'Aprano wrote: This is one of the offending line from our code base: print('<4>Suspicious answer "{}"!'.format(answer),

Re: Unbuffered stderr in Python 3

2015-11-04 Thread Random832
Wolfgang Maier writes: > Standard I/O streams are line-buffered only if interactive (i.e., > connected to a console), but block-buffered otherwise. That's not appropriate for stderr, nor is it justified by the argument that Terry Reedy cited earlier. I

Re: Unbuffered stderr in Python 3

2015-11-04 Thread Dave Farrance
Random832 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

Re: Unbuffered stderr in Python 3

2015-11-04 Thread Wolfgang Maier
On 04.11.2015 04:18, 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 wrote: Nobody writes: It's probably related to the

Re: Unbuffered stderr in Python 3

2015-11-04 Thread Steven D'Aprano
On Wed, 4 Nov 2015 07:19 pm, Wolfgang Maier wrote: > On 04.11.2015 04:18, 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 wrote: >

Re: Unbuffered stderr in Python 3

2015-11-04 Thread Wolfgang Maier
On 04.11.2015 11:24, Steven D'Aprano wrote: On Wed, 4 Nov 2015 07:19 pm, Wolfgang Maier wrote: On 04.11.2015 04:18, Steven D'Aprano wrote: 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

Re: Unbuffered stderr in Python 3

2015-11-03 Thread Random832
Nobody 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.

Re: Unbuffered stderr in Python 3

2015-11-03 Thread Chris Angelico
On Wed, Nov 4, 2015 at 2:00 AM, Random832 wrote: > Nobody 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

Re: Unbuffered stderr in Python 3

2015-11-03 Thread George Trojan
Forwarded Message Subject:Re: Unbuffered stderr in Python 3 Date: Tue, 03 Nov 2015 18:03:51 + From: George Trojan <george.tro...@noaa.gov> To: python-list@python.org On 11/03/2015 05:00 PM, python-list-requ...@python.org wrote: On Mon, 02 Nov 2

Re: Unbuffered stderr in Python 3

2015-11-03 Thread George Trojan
On 11/03/2015 05:00 PM, python-list-requ...@python.org wrote: On Mon, 02 Nov 2015 18:52:55 +1100, Steven D'Aprano wrote: In Python 2, stderr is unbuffered. In most other environments (the shell, C...) stderr is unbuffered. It is usually considered a bad, bad thing for stderr to be buffered.

Re: Unbuffered stderr in Python 3

2015-11-03 Thread Terry Reedy
On 11/3/2015 10:42 AM, Chris Angelico wrote: On Wed, Nov 4, 2015 at 2:00 AM, Random832 wrote: Nobody 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

Re: Unbuffered stderr in Python 3

2015-11-03 Thread Random832
George Trojan 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,

Re: Unbuffered stderr in Python 3

2015-11-03 Thread Steven D'Aprano
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 wrote: >>> Nobody writes: >>> It's probably related to the fact that std{in,out,err} are

Re: Unbuffered stderr in Python 3

2015-11-02 Thread Nobody
On Mon, 02 Nov 2015 18:52:55 +1100, Steven D'Aprano wrote: > In Python 2, stderr is unbuffered. > > In most other environments (the shell, C...) stderr is unbuffered. > > It is usually considered a bad, bad thing for stderr to be buffered. What > happens if your application is killed before the

Unbuffered stderr in Python 3

2015-11-02 Thread Steven D'Aprano
In Python 2, stderr is unbuffered. In most other environments (the shell, C...) stderr is unbuffered. It is usually considered a bad, bad thing for stderr to be buffered. What happens if your application is killed before the buffer fills up? The errors in the buffer will be lost. So how come

Re: Unbuffered stderr in Python 3

2015-11-02 Thread Wolfgang Maier
On 02.11.2015 11:48, Wolfgang Maier wrote: Since Python3.3, the print function has a flush keyword argument that accepts a boolean and lets you do just this. Rewrite your example as: import sys, time def test(): # Simulate a slow calculation that prints status and/or error # messages to

Re: Unbuffered stderr in Python 3

2015-11-02 Thread Wolfgang Maier
On 02.11.2015 08:52, Steven D'Aprano wrote: In Python 2, stderr is unbuffered. In most other environments (the shell, C...) stderr is unbuffered. It is usually considered a bad, bad thing for stderr to be buffered. What happens if your application is killed before the buffer fills up? The