Message80539
> 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. |
|
Date |
User |
Action |
Args |
2009-01-25 21:25:20 | mark.dickinson | set | recipients:
+ mark.dickinson, pitrou, vstinner, fabioz, benjamin.peterson |
2009-01-25 21:25:20 | mark.dickinson | set | messageid: <1232918720.11.0.510188828628.issue4705@psf.upfronthosting.co.za> |
2009-01-25 21:25:19 | mark.dickinson | link | issue4705 messages |
2009-01-25 21:25:16 | mark.dickinson | create | |
|