summaryrefslogtreecommitdiffstats
path: root/Lib/socket.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2000-09-19 11:25:58 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2000-09-19 11:25:58 (GMT)
commit6df27f8d1cdc723f4442cf44e9235cb8e7f38942 (patch)
tree11902193d341118f9d29df30e8366b8dcfcee4fd /Lib/socket.py
parent543f2438ba8fb67dc779a3cc10d61e27aea00818 (diff)
downloadcpython-6df27f8d1cdc723f4442cf44e9235cb8e7f38942.zip
cpython-6df27f8d1cdc723f4442cf44e9235cb8e7f38942.tar.gz
cpython-6df27f8d1cdc723f4442cf44e9235cb8e7f38942.tar.bz2
Support sizehint in _fileobject.readlines, as documented.
Diffstat (limited to 'Lib/socket.py')
-rw-r--r--Lib/socket.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index b28de1d..7658c07 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -228,10 +228,14 @@ class _fileobject:
data, self._rbuf = self._rbuf[:i], self._rbuf[i:]
return data
- def readlines(self):
+ def readlines(self, sizehint = 0):
+ total = 0
list = []
while 1:
line = self.readline()
if not line: break
list.append(line)
+ total += len(line)
+ if sizehint and total >= sizehint:
+ break
return list