This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients benjamin.peterson, fabioz, mark.dickinson, pitrou, vstinner
Date 2009-01-25.21:25:15
SpamBayes Score 4.0234482e-13
Marked as misclassified No
Message-id <1232918720.11.0.510188828628.issue4705@psf.upfronthosting.co.za>
In-reply-to
Content
> since I don't see how the behaviour can differ for a read-only
> non-seekable stream.

Unless I'm misunderstanding you (quite likely), I think one *can* get 
different results with buffered and unbuffered stdin.
For example, on my machine, if I create the following script:

#!/usr/bin/python -u
import sys
print sys.stdin.readline()

and name it test.py, I get the following result in an OS X Terminal 
running bash:

dickinsm$ ls python_source/trunk/Objects/ | (./test.py; ./test.py)
abstract.c

boolobject.c

Whereas if I remove the '-u' from the shebang line I just get:

dickinsm$ ls python_source/trunk/Objects/ | (./test.py; ./test.py)
abstract.c


I'm not 100% sure that I understand exactly what's going on here, but it's 
something like the following:  in the first (unbuffered) case, the 
stdin.readline call of the first ./test.py only reads one line from stdin, 
leaving the rest intact;  so the second ./test.py also gets to output a 
line.  In the second case some larger amount of stdin (1024 bytes?) is 
immediately slurped into the stdin buffer for the first Python process, so 
the second ./test.py doesn't get anything.
History
Date User Action Args
2009-01-25 21:25:20mark.dickinsonsetrecipients: + mark.dickinson, pitrou, vstinner, fabioz, benjamin.peterson
2009-01-25 21:25:20mark.dickinsonsetmessageid: <1232918720.11.0.510188828628.issue4705@psf.upfronthosting.co.za>
2009-01-25 21:25:19mark.dickinsonlinkissue4705 messages
2009-01-25 21:25:16mark.dickinsoncreate