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 gregory.p.smith
Recipients georg.brandl, gregory.p.smith, larry
Date 2013-03-20.01:29:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1363742986.45.0.357278360182.issue17488@psf.upfronthosting.co.za>
In-reply-to
Content
The subprocess module in Python 3 uses io.open(file_descriptor, mode, bufsize) to create its Popen stdout, stderr and stdin file objects.

In Python 2, it used the old os.fdopen which created an old-style python 2 file object that simply wraps libc's FILE* interface.

This results in a behavior difference between Python 2 and Python 3 subprocesses as the bufsize=0 on io.open()ed files results in a RawIOBase file object whos read() or write() methods map directly to a single underlying system call.  ie: In Python 3 if you Popen.read(30000) and there are only 12345 bytes in the pipe from the child, it will return 12345 bytes rather than blocking while it makes further read() syscalls until it gets enough data or EOF as it would with the libc backed file objects in Python 2.

This tripped up the imaplib module in Issue17443.  (since fixed by explicitly enabling buffered I/O).

This behavior difference will make porting code to work on both Python 2 and 3 a bit more painful as bufsize=non-zero must be specified by the user for consistent behavior.

I'd like to fix this by changing the default bufsize=0 to bufsize=io.DEFAULT_BUFFER_SIZE, but only if I can do that in 3.2 and 3.3 .  If I can't, it _does_ seem like an API change, I'll just make a documentation update to mention the issue and the best practice for 2.x and 3.x compatibility.

[note: this issue does not apply to my subprocess32 backport running on python 2.x because that uses python2's the old style file os.fdopen]

marking release blocker to ask for comments from the 3.2 and 3.3 release managers on if i can consider changing the default subprocess.Popen bufsize parameter value or not.
History
Date User Action Args
2013-03-20 01:29:46gregory.p.smithsetrecipients: + gregory.p.smith, georg.brandl, larry
2013-03-20 01:29:46gregory.p.smithsetmessageid: <1363742986.45.0.357278360182.issue17488@psf.upfronthosting.co.za>
2013-03-20 01:29:46gregory.p.smithlinkissue17488 messages
2013-03-20 01:29:44gregory.p.smithcreate