[pypy-svn] r47280 - pypy/dist/pypy/module/_file

arigo at codespeak.net arigo at codespeak.net
Mon Oct 8 12:25:28 CEST 2007


Author: arigo
Date: Mon Oct  8 12:25:26 2007
New Revision: 47280

Modified:
   pypy/dist/pypy/module/_file/app_file.py
Log:
file.readlines(0) in CPython is equivalent to file.readlines().


Modified: pypy/dist/pypy/module/_file/app_file.py
==============================================================================
--- pypy/dist/pypy/module/_file/app_file.py	(original)
+++ pypy/dist/pypy/module/_file/app_file.py	Mon Oct  8 12:25:26 2007
@@ -149,7 +149,7 @@
                 self.stream.unlock()
             return ''.join(result)
 
-    def readlines(self, size=-1):
+    def readlines(self, size=0):
         """readlines([size]) -> list of strings, each a line from the file.
 
 Call readline() repeatedly and return a list of the lines so read.
@@ -161,7 +161,9 @@
             raise TypeError("an integer is required")
         self.stream.lock()
         try:
-            if size < 0:
+            # NB. this implementation is very inefficient for unbuffered
+            # streams, but ok if self.stream.readline() is efficient.
+            if size <= 0:
                 result = list(iter(self.stream.readline, ""))
             else:
                 result = []



More information about the Pypy-commit mailing list