Author: Brian Kearns <bdkea...@gmail.com>
Branch: use-file-star-for-file
Changeset: r73510:a2cb5424ebf5
Date: 2014-09-12 14:06 -0400
http://bitbucket.org/pypy/pypy/changeset/a2cb5424ebf5/

Log:    retry when necessary in file.readinto

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
@@ -437,10 +437,18 @@
         # XXX not the most efficient solution as it doesn't avoid the copying
         space = self.space
         rwbuffer = space.writebuf_w(w_rwbuffer)
-        w_data = self.file_read(rwbuffer.getlength())
-        data = space.str_w(w_data)
-        rwbuffer.setslice(0, data)
-        return space.wrap(len(data))
+        ntodo = rwbuffer.getlength()
+        ndone = 0
+        while ntodo:
+            w_data = self.file_read(ntodo)
+            data = space.str_w(w_data)
+            nnow = len(data)
+            if nnow == 0:
+                break
+            rwbuffer.setslice(ndone, data)
+            ndone += nnow
+            ntodo -= nnow
+        return space.wrap(ndone)
 
 
 # ____________________________________________________________
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to