[pypy-commit] pypy use-file-star-for-file: use rfile.read(n) logic instead
bdkearns
noreply at buildbot.pypy.org
Fri Aug 29 07:20:12 CEST 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch: use-file-star-for-file
Changeset: r73149:35cbd34bdf5b
Date: 2014-08-29 00:57 -0400
http://bitbucket.org/pypy/pypy/changeset/35cbd34bdf5b/
Log: use rfile.read(n) logic instead
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
@@ -161,27 +161,7 @@
@unwrap_spec(n=int)
def direct_read(self, n=-1):
stream = self.getstream()
- if n < 0:
- return stream.read()
- else:
- result = StringBuilder(n)
- while n > 0:
- try:
- data = stream.read(n)
- except OSError, e:
- # a special-case only for read() (similar to CPython, which
- # also loses partial data with other methods): if we get
- # EAGAIN after already some data was received, return it.
- if is_wouldblock_error(e):
- got = result.build()
- if len(got) > 0:
- return got
- raise
- if not data:
- break
- n -= len(data)
- result.append(data)
- return result.build()
+ return stream.read(n)
@unwrap_spec(size=int)
def direct_readline(self, size=-1):
More information about the pypy-commit
mailing list