diff --git a/Lib/socket.py b/Lib/socket.py index b28de1d39ca..7658c0735d0 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