summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-03-19 13:56:01 -0400
committerR David Murray <rdmurray@bitdance.com>2013-03-19 13:56:01 -0400
commit7889944b83cf04cefb45cd658644298218eac5db (patch)
treefc1f6d1ff2f4ddc45d5726b3d3212b33a46510c0
parente185341bfa177932b00a03a1d8b1d0e0e7795919 (diff)
parentfcb6d6a3b3bfba67927ced18dd648ba889e14f4c (diff)
downloadcpython-git-7889944b83cf04cefb45cd658644298218eac5db.tar.gz
Merge: #17443: Fix buffering in IMAP4_stream.
In Python2 Popen uses *FILE objects, which wind up buffering even though subprocess defaults to no buffering. In Python3, subprocess streams really are unbuffered by default, but the imaplib code assumes read is buffered. This patch uses the default buffer size from the io module to get buffered streams from Popen. Much debugging work and patch by Diane Trout. The imap protocol is too complicated to write a test for this simple change with our current level of test infrastructure.
-rw-r--r--Lib/imaplib.py3
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS4
3 files changed, 8 insertions, 0 deletions
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index f8c7ffdb92..724f9d13a0 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -24,6 +24,8 @@ __version__ = "2.58"
import binascii, errno, random, re, socket, subprocess, sys, time, calendar
from datetime import datetime, timezone, timedelta
+from io import DEFAULT_BUFFER_SIZE
+
try:
import ssl
HAVE_SSL = True
@@ -1244,6 +1246,7 @@ class IMAP4_stream(IMAP4):
self.sock = None
self.file = None
self.process = subprocess.Popen(self.command,
+ bufsize=DEFAULT_BUFFER_SIZE,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
shell=True, close_fds=True)
self.writefile = self.process.stdin
diff --git a/Misc/ACKS b/Misc/ACKS
index e2455ae812..2d29e9942f 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1216,6 +1216,7 @@ Alberto Trevino
Matthias Troffaes
Tom Tromey
John Tromp
+Diane Trout
Jason Trowbridge
Brent Tubbs
Anthony Tuininga
diff --git a/Misc/NEWS b/Misc/NEWS
index 95994ffb30..7e126c44ac 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -193,6 +193,10 @@ Core and Builtins
Library
-------
+- Issue #17443: impalib.IMAP4_stream was using the default unbuffered IO
+ in subprocess, but the imap code assumes buffered IO. In Python2 this
+ worked by accident. IMAP4_stream now explicitly uses buffered IO.
+
- Issue #17476: Fixed regression relative to Python2 in undocumented pydoc
'allmethods'; it was missing unbound methods on the class.