diff options
| author | Guido van Rossum <guido@google.com> | 2012-11-10 16:21:21 -0800 |
|---|---|---|
| committer | Guido van Rossum <guido@google.com> | 2012-11-10 16:21:21 -0800 |
| commit | 2cf437b13b447b4773e64819d5488d02c602761d (patch) | |
| tree | f93bf7e423609209a290b45c658eaff8ade607f0 | |
| parent | 84b59833a6efd4c2694a14560ab46b00cb071fef (diff) | |
| download | trollius-git-2cf437b13b447b4773e64819d5488d02c602761d.tar.gz | |
readexactly() should stop on EOF.
| -rw-r--r-- | sockets.py | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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) |
