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 akira
Recipients akira, pitrou
Date 2014-05-01.10:27:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1398940053.27.0.559866112173.issue21396@psf.upfronthosting.co.za>
In-reply-to
Content
I've uploaded the patch that makes C implementation behave according
to the docs like Python implementation with the corresponding tests.

Issue #21332 is a dependency for this issue: subprocess' test_universal_newlines needs to be updated to work with Python version.


For Reference
-------------

issue #12591 introduces `write_through` to support subprocess' stdin
pipe in text mode with bufsize=0 i.e., TextIOWrapper.buffer is
unbuffered (raw) and Python and C implementation behave the same in
this particular case.

C implementation (pseudo-code)::

  if self.write_through:
      flush_text_buffer()
      buffer.flush() # <-- undocumented

Python implementation::

   if self.write_through:
       pass # _pyio.TextIOWrapper.write() calls buffer.write() directly

behaves according to the current documentation [1]:

   If *write_through* is ``True``, calls to :meth:`write` are guaranteed
   not to be buffered: any data written on the :class:`TextIOWrapper`
   object is immediately handled to its underlying binary *buffer*
      
[1]: hg.python.org/cpython/file/2a56d3896d50/Doc/library/io.rst

For reference, here's how subprocess.py uses write_through [2]::

  self.stdin = io.open(pipe, 'wb', bufsize)
  if universal_newlines=True:
      self.stdin = io.TextIOWrapper(self.stdin,
          write_through=True,
          line_buffering=(bufsize == 1)) # <-- issue #21332

http://hg.python.org/cpython/rev/9ce8fa0a0899/ - introduce io.TextIOWrapper in subprocess
http://hg.python.org/cpython/rev/5cc536fbd7c1  - introduce write_through

[2]: http://hg.python.org/cpython/file/2a56d3896d50/Lib/subprocess.py#l849
History
Date User Action Args
2014-05-01 10:27:33akirasetrecipients: + akira, pitrou
2014-05-01 10:27:33akirasetmessageid: <1398940053.27.0.559866112173.issue21396@psf.upfronthosting.co.za>
2014-05-01 10:27:33akiralinkissue21396 messages
2014-05-01 10:27:32akiracreate