]> granicus.if.org Git - python/commitdiff
Support sizehint in _fileobject.readlines, as documented.
authorMartin v. Löwis <martin@v.loewis.de>
Tue, 19 Sep 2000 11:25:58 +0000 (11:25 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Tue, 19 Sep 2000 11:25:58 +0000 (11:25 +0000)
Lib/socket.py

index b28de1d39cad92d463f815b660ea1f89dacd0def..7658c0735d07da8a8ba62bd887a38ec440351022 100644 (file)
@@ -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