summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-25 22:19:38 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-25 22:19:38 (GMT)
commitb57f108b03df332d276a224c92e32cee13a042f2 (patch)
tree954924ef9693e020c58d90999bdb548af8f45f9f /Lib
parente9d44ccb2279a49a69277d38e956731675f1b556 (diff)
downloadcpython-b57f108b03df332d276a224c92e32cee13a042f2.zip
cpython-b57f108b03df332d276a224c92e32cee13a042f2.tar.gz
cpython-b57f108b03df332d276a224c92e32cee13a042f2.tar.bz2
Issue #12175: BufferedReader.read(-1) now calls raw.readall() if available.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/_pyio.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index 74047bf..265edab 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -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: