summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido van Rossum <guido@google.com>2012-11-10 16:21:21 -0800
committerGuido van Rossum <guido@google.com>2012-11-10 16:21:21 -0800
commit2cf437b13b447b4773e64819d5488d02c602761d (patch)
treef93bf7e423609209a290b45c658eaff8ade607f0
parent84b59833a6efd4c2694a14560ab46b00cb071fef (diff)
downloadtrollius-git-2cf437b13b447b4773e64819d5488d02c602761d.tar.gz
readexactly() should stop on EOF.
-rw-r--r--sockets.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/sockets.py b/sockets.py
index 6c1be4b..13eeaac 100644
--- a/sockets.py
+++ b/sockets.py
@@ -201,8 +201,10 @@ class BufferedReader:
"""COUROUTINE: Read exactly n bytes, or until EOF."""
blocks = []
count = 0
- while n > count:
+ while n > count and not self.eof:
block = yield from self.read(n - count)
+ if not block:
+ break
blocks.append(block)
count += len(block)
return b''.join(blocks)