summaryrefslogtreecommitdiff
path: root/Lib/io.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-03-07 05:23:25 +0000
committerGuido van Rossum <guido@python.org>2007-03-07 05:23:25 +0000
commit00efeadbcf2bfdeb805eecbb6d486b0bf93c3738 (patch)
tree6edb8f8c0cdd997f6b59e801b08cf6e91071370d /Lib/io.py
parent01a2752d19d0ad615c989b8d742a736ca8d51a57 (diff)
downloadcpython-git-00efeadbcf2bfdeb805eecbb6d486b0bf93c3738.tar.gz
Change the specs for readinto() -- it should *not* shorten the buffer to
the amount of data read.
Diffstat (limited to 'Lib/io.py')
-rw-r--r--Lib/io.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/io.py b/Lib/io.py
index d6ee186b97..db0ba7e87d 100644
--- a/Lib/io.py
+++ b/Lib/io.py
@@ -132,7 +132,8 @@ class RawIOBase:
set not to block and has no data to read.
"""
b = bytes(n.__index__())
- self.readinto(b)
+ n = self.readinto(b)
+ del b[n:]
return b
def readinto(self, b):
@@ -200,8 +201,10 @@ class FileIO(RawIOBase):
def readinto(self, b):
# XXX We really should have os.readinto()
- b[:] = os.read(self._fd, len(b))
- return len(b)
+ tmp = os.read(self._fd, len(b))
+ n = len(tmp)
+ b[:n] = tmp
+ return n
def write(self, b):
return os.write(self._fd, b)
@@ -303,7 +306,10 @@ class BytesIO(BufferedIOBase):
return b
def readinto(self, b):
- b[:] = self.read(len(b))
+ tmp = self.read(len(b))
+ n = len(tmp)
+ b[:n] = tmp
+ return n
def write(self, b):
n = len(b)