[issue21332] subprocess bufsize=1 docs are misleading

akira report at bugs.python.org
Fri May 2 06:38:01 CEST 2014


akira added the comment:

yes, line_buffering=(bufsize == 1) is necessary to support the current 
Python io implementation or if C implementation is fixed to avoid 
buffer.flush() on every write with write_through=True -- otherwise
bufsize is not respected in text mode (it would always mean bufsize=0). 

Note: the current patch for issue #21396 (making C and Python io do the 
same thing) may break subprocess code with universal_newlines=True that 
expects (incorrectly) bufsize=0 by default -- as test_universal_newlines
had (enabling universal_newlines shouldn't switch from bufsize=-1 to 
bufsize=0). <-- XXX backward compatibility issue!

> Perhaps you can avoid the 10 s deadlock timeout and threading in your 
> test by closing the underlying input pipe file descriptor (or raw file 
> object), without flushing it.

It is a good idea. There could be portability issues with the test: it 
relies on the fact that os.close doesn't flush already buffered data -- I 
don't know whether os.close causes flush on Windows (it doesn't on POSIX 
[1]: the data shall be discarded).

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html

I've uploaded a new patch with the updated tests. Please, review.

----------
Added file: http://bugs.python.org/file35129/subprocess-line-buffering-issue21332-ps3.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21332>
_______________________________________


More information about the Python-bugs-list mailing list