summaryrefslogtreecommitdiffstats
path: root/Lib/socket.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-07 15:46:19 (GMT)
committerGuido van Rossum <guido@python.org>2002-08-07 15:46:19 (GMT)
commite9f6614ea3b236851b536f6650cd6abe3f289dcb (patch)
tree43c161e4dea84de01a37a41f577f95dc0b21d085 /Lib/socket.py
parent21f675826e135695181e978c40605d3db92cc86b (diff)
downloadcpython-e9f6614ea3b236851b536f6650cd6abe3f289dcb.zip
cpython-e9f6614ea3b236851b536f6650cd6abe3f289dcb.tar.gz
cpython-e9f6614ea3b236851b536f6650cd6abe3f289dcb.tar.bz2
"Unbuffered" mode of class _fileobject wasn't actually unbuffered,
and this broke a Zope "pipelining" test which read multiple responses from the same connection (this attaches a new file object to the socket for each response). Added a test for this too. (I want to do some code cleanup too, but I thought I'd first fix the problem with as little code as possible, and add a unit test for this case. So that's what this checkin is about.)
Diffstat (limited to 'Lib/socket.py')
-rw-r--r--Lib/socket.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index 515d477..e59e6d9 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -174,11 +174,14 @@ class _socketobject:
class _fileobject:
"""Implements a file object on top of a regular socket object."""
- def __init__(self, sock, mode='rb', bufsize=8192):
+ def __init__(self, sock, mode='rb', bufsize=-1):
self._sock = sock
self._mode = mode
if bufsize <= 0:
- bufsize = 512
+ if bufsize == 0:
+ bufsize = 1 # Unbuffered mode
+ else:
+ bufsize = 8192
self._rbufsize = bufsize
self._wbufsize = bufsize
self._rbuf = [ ]