mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
"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.)
This commit is contained in:
parent
21f675826e
commit
e9f6614ea3
2 changed files with 40 additions and 8 deletions
|
@ -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 = [ ]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue