Author: Brian Kearns <[email protected]>
Branch: use-file-star-for-file
Changeset: r73146:ae483af51c0d
Date: 2014-08-29 00:31 -0400
http://bitbucket.org/pypy/pypy/changeset/ae483af51c0d/
Log: pass size to rfile.readline
diff --git a/pypy/module/_file/interp_file.py b/pypy/module/_file/interp_file.py
--- a/pypy/module/_file/interp_file.py
+++ b/pypy/module/_file/interp_file.py
@@ -192,29 +192,7 @@
@unwrap_spec(size=int)
def direct_readline(self, size=-1):
stream = self.getstream()
- return stream.readline()
- if size < 0:
- return stream.readline()
- else:
- # very inefficient unless there is a peek()
- result = StringBuilder()
- while size > 0:
- # "peeks" on the underlying stream to see how many chars
- # we can safely read without reading past an end-of-line
- startindex, peeked = stream.peek()
- assert 0 <= startindex <= len(peeked)
- endindex = startindex + size
- pn = peeked.find("\n", startindex, endindex)
- if pn < 0:
- pn = min(endindex - 1, len(peeked))
- c = stream.read(pn - startindex + 1)
- if not c:
- break
- result.append(c)
- if c.endswith('\n'):
- break
- size -= len(c)
- return result.build()
+ return stream.readline(size)
@unwrap_spec(size=int)
def direct_readlines(self, size=0):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit