On Fri, Jan 13, 2012 at 7:34 AM, anatoly techtonik <techtonik@gmail.com> wrote:
">

(original) (raw)

I think this may be because in Python 2, there is a coupling between stdin and stderr (in the C stdlib code) that flushes stdout when you read stdin. This doesn't seem to be required by the C std, but most implementations seem to do it. http://stackoverflow.com/questions/2123528/does-reading-from-stdin-flush-stdout


I think it was a nice feature but I can see problems with it; apps that want this behavior ought to bite the bullet and flush stdout.

On Fri, Jan 13, 2012 at 7:34 AM, anatoly techtonik <techtonik@gmail.com> wrote:

Posting to python-dev as it is no more relates to the idea of improving print().


sys.stdout.write() in Python 3 causes backwards incompatible behavior that breaks recipe for�unbuffered character reading from stdin on Linux -�http://code.activestate.com/recipes/134892/� At first I though that the problem is in the new�print() function, but�it appeared that the culprit is sys.stdout.write()


Attached is a test script which is a stripped down version of the recipe above.


If executed with Python 2, you can see the prompt to press a key (even though output on Linux is buffered in Python 2).
With Python 3, there is not prompt until you press a key.


Is it a bug or intended behavior? What is the cause of this break?
--�
anatoly t.


\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org




--
--Guido van Rossum (python.org/\~guido)