Issue #12175: BufferedReader.read(-1) now calls raw.readall() if available.

This commit is contained in:
Victor Stinner 2011-05-26 00:19:38 +02:00
parent e9d44ccb22
commit b57f108b03
5 changed files with 48 additions and 11 deletions

View file

@ -944,6 +944,12 @@ class BufferedReader(_BufferedIOMixin):
# Special case for when the number of bytes to read is unspecified.
if n is None or n == -1:
self._reset_read_buf()
if hasattr(self.raw, 'readall'):
chunk = self.raw.readall()
if chunk is None:
return buf[pos:] or None
else:
return buf[pos:] + chunk
chunks = [buf[pos:]] # Strip the consumed bytes.
current_size = 0
while True: